Posts

Showing posts from March, 2011

java - BeanCreationException : Injection of autowired dependencies failed -

i have 2 classes in 2 different projects, , have difficulties autowire field. in project pack, have computation class : package fr.aaa; @component public class computation { @autowired @qualifier("curvedao") curveaccess curvedao; public static void main(string[] args) { applicationcontext context = new classpathxmlapplicationcontext("classpath*:applicationcontext.xml"); } } in project db, have curveaccess interface : package com.bbb public interface curveaccess { // methods } implemented curvedao class : package com.bbb.impl @repository("curvedao") @transactional("cvatxmanager") public class curvedao implements curveaccess { // methods } my applicationcontext.xml file pack project : <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:...

Duplicate events in passenger, in websocket-rails -

i using phusion passenger version 4.0.35 my websocket_rails.rb file websocketrails.setup |config| config.log_level = :debug config.log_internal_events = false if rails.env.production? config.standalone = true else config.standalone = false end config.synchronize = false end in normal controller using this connection1 = websocketrails.users[one_user_id] connection1.send_message :online, @reply.to_json(:methods => required_methods) connection2 = websocketrails.users[another_other_user_id] connection2.send_message :online, @reply.to_json(:methods => required_methods) in client side var socket_path = document.domain + ":3001" + '/websocket' var dispatcher = new websocketrails(socket_path) dispatcher.bind('online', function(data){ ................. .................................. } problem response twice while calling send_message on controller both th user gets response twice. another thing works great in development in normal serv...

c++ - Extra curly braces while initializing a string -

according question what string array[] = ""; mean , why work? want ask difference between s1 , s2 in code below: int main() { const char* s1 = { "hello" }; // strange work followed const char* s2 = "hello"; // ordinary case return 0; } why curly braces permitted? reference c++ standard useful. in c++98 (and c++03) pretty simple; in clause 8.5: 14 - if t scalar type, declaration of form t x = { }; equivalent t x = a; in c++11 covered list-initialization (8.5.4p3): [...] if initializer list has single element of type e , either t not reference type or referenced type reference-related e, object or reference initialized element [...] i think same question initializing scalars braces .

Java | retrieving data -

i have made tower defense game , there 1 thing bothers me. have set starting value of money cannot value carry on next level. ideas? public void define() { room = new room(); save = new save(); store = new store(); if(level == 1){ coinage = 50; health = 100; } if(level == 2){ coinage = 40; health = 100; } if(level > 2){ coinage = 30; health = 100; } if(level > 8){ coinage = 0; } hmm tried this: public static int coinage = 0, health = 100; and then if(level == 1){ coinage += 50; } if(level == 2){ coinage += 40; } i sure doing wrong here. when second level comes starting value still 40. how fix that? here a link full code ! if coinage money, can set global variable outside of define() function. let keep track of how money player has. instead of setting value direct number can instead add existing value. in example of level 2, coinage += 50...

Azure worker role where are input endpoints declared? -

i have azure worker role deployed staging. (azure sdk 2.2). when deployed via publish in visual studio 2013 noticed number of input endpoints had increased 3 five! when looked in endpoints tab of worker role properties, there no input endpoints declared! after doing lot of googling bing, have been unable find reference these input endpoints have come from. i trying swap instance staging production , not swap, number of input endpoints different between staging , production. both instances run fine, not using endpoints anyway. any ideas these endpoints declared , how can delete ones don't want? endpoints specified in servicedefinition.csdef (properties of cloud project). endpoints seeing because published project vs2013 "enable remote debugging" selected (a new feature in vs2013 , azure sdk 2.2). endpoints facilitate attaching remote debugger. deselect option , republish.

javascript - Redrawing google chart -

hello guys developing web application google chart . want redraw chart on each times user makes selection , here code //loading google api google.load("visualization", "1", { packages: ["corechart"] }); google.setonloadcallback(drawallcharts); function drawallcharts() { //sending server request $.post("index.php", { type: "result" }, function (data, status) { handleresponse(data, true) }); } //this function handles response of server json string function handleresponse(jsonstring, init) { //parsing json string object var obj = json.parse(jsonstring); var arraydata = objtostrin(obj); //converting obj array console.log(arraydata); drawdistchart(arraydata, init); } //this function draws first chart function drawdistchart(arraydata, init) { //preparing data var da...

JavaScript countdown timer: Calculate how many seconds until midnight EST -

i'm using 24 hour countdown timer runs in javascript. currently, uses seconds base measurement. have 86400 listed here calculate how many seconds left until midnight each day, est (-5). please demonstrate how might define value , insert "time" variable? i've seen other variations of i'm having trouble getting work specific script. thank in advance. <script type="application/javascript"> var mycountdown1 = new countdown({ time: 86400, // 86400 seconds = 1 day width:200, height:55, rangehi:"hour", style:"flip" // <- no comma on last item! }); </script> you can subtract unix timestamp of now, unix timestamp of midnight: var = new date(); var night = new date( now.getfullyear(), now.getmonth(), now.getdate() + 1, // next day, ... 0, 0, 0 // ...at 00:00:00 hours ); var mstillmidnight = night.gettime() - now.gettime(); var mycountdown1 = new countdown({ time: mstillmidnight / 1000, /...

Pingdom restful API C# -

i having trouble using pingdoms api i have generated key application , added header of request. keep getting 401 errorcode :( networkcredential nc = new networkcredential("my_email", "my_password", "https://api.pingdom.com/2.0/checks"); credentialcache cc = new credentialcache(); cc.add("https://api.pingdom.com/2.0/checks", 443, "basic", nc); httpwebrequest request = httpwebrequest)webrequest.create("https://api.pingdom.com/2.0/checks"); request.proxy = new webproxy("my_proxy",true); //i'm behind strict firewall... request.headers.add("app-key", "my_appkey"); request.contentlength = 0; request.credentials = cc; request.preauthenticate = true; request.method = "post"; httpwebresponse response = (httpwebresponse)request.getresponse(); im pretty lost :( whatever get: an unhandled exception of type 'system.net.webexception' occurred in system.dll additional inform...

twitter bootstrap 3 - MVC5 and Bootstrap3: Html.EditorFor wrong class? How to change? -

i noticed mvc 5 using different class input fields when using editorfor. think lower version of bootstrap, current class doesn't add up. i'm talking this: <div class="form-group"> @html.labelfor(model => model.contact.cellphoneno, new { @class = "control-label col-md-4"}) <div class="col-md-8"> @html.editorfor(model => model.contact.cellphoneno) @html.validationmessagefor(model => model.contact.cellphoneno) </div> </div> which results this: <div class="form-group"> <label class="control-label col-md-4" for="contact_cellphoneno">cellphoneno</label> <div class="col-md-8"> <input class="text-box single-line" id="contact_cellphoneno" name="contact.cellphoneno" type="text" value=""> <span class="field-validation-valid...

How to use Finverse in Matlab? -

when using finverse code in matlab there might not unique answer that, how can use if choose 1 of these? here documentation of finverse can of course found using doc finverse . it mentioned there no warning if inverse not unique, , not mentioned 1 chosen in case. hence think safe assume cannot instruct matlab on inverse choose. if required, not able use standard implementation.

vb.net - vb net load multiple datagrid at n one form and automatic progress bar -

Image
i have 2 datagrid , 2 button in 1 form.. if click go!, left datagrid filled data.. and if click mining!, surely right datagrid filled.. but problem when click mining button, right datagrid filled, but left datagrid's data automatically unloaded , resulting right datagrid loaded data.. here's screenshot so need 2 datagrid display data @ same time.. is possible that? and 1 more question there simple way automatically display progress bar when click mining button, because when clicked it, run executequery took long time completed, it's 10 60 seconds.. so show program not hang, it's still working on progress completed.. only simple circle progress bar do, mean there's no need display estimated time complete.. said before, it's show program working on progress not hang and way i'm using vb.net , mysql.. before updated code if ..... getcmd= "insert node(...) select ..." cmd = new mysqlcommand(getcmd, conn.connect) cmd.exe...

android - Scroll to a specific view in scroll view -

i have added scrollview , subchilds inside scrollview. @ point need scroll specific view. <scrollview> 1. <linearlayout> <textview></textview> <textview></textview> </linearlayout> 2. <linearlayout> <textview></textview> <textview></textview> </linearlayout> 3. <linearlayout> <textview></textview> <textview></textview> </linearlayout> 4. <linearlayout> <textview></textview> <textview></textview> </linearlayout> 5. <linearlayout> <textview></textview> <textview></textview> </linearlayout> 6. <linearlayout> <textview></textview> <textview></textview> </linearlayout> 7. <linearlayout> <textview></textview> <textview></textview> </linear...

c# - Web API actions to be distinguishable only by their parameter types? -

in asp.net web api, how can 2 actions, both routed same url , same http method, distingushable different parameter types? i'd able post either single json object or json array of objects. i'm expecting work this: [httppost] public virtual object post([frombody]idictionary<string, object> values) { //add new object collection } [httppost] public virtual ienumerable<object> post([frombody] idictionary<string, object>[] array) { return array.select(post); } however, if , attempt call either actions, error: multiple actions found match request have @ attribute routing library. allows define routes each action in web api. has been packaged part of web api 2.0: [post("first url here")] public virtual object post([frombody]idictionary<string, object> values) { //add new object collection } [post("second url here")] public virtual ienumerable<object> post([frombody] idictionary<string, object...

java - Passing System.out.println(); as an argument in a method -

i want pass system.out.println(); argument compiler won't allow me return void type argument. here want for. public class array { public static void main(string args[]) { a(data()); } static void a(e) { system.out.println(e); } static void data() { ... } } so want a(data()); after compiled this. a(data()) = system.out.println(data(){...}); eventually want shorthand system.out.println() . what doing here not passing system.out.println() argument; trying pass argument system.out.println() try changing return type of data() string , or int , or other void , , return of type it. also change parameter type of e in function definition of a() match return type of data() . after make these changes, calling a(data()); print out. example: public static void main(string args[]) { a(data()); } // shorthand system.out.println static void a(string e) { system.out.println(e); } // method returns dat...

c# - Configuring resiliency settings Entity Framework 6.02 -

i'm trying configure resiliency settings ef6.02. have application in 1 point of execution writes log entry database. application not depending on sql-server if server not respond, want application abandon insert query (through savechanges of dbcontext) , continue execution immediately. using default settings, debug log outputs ten "a first chance exception of type 'system.data.sqlclient.sqlexception' occurred in system.data.dll" after ten tries, throws exception , code continues. want 1 try , example 2 s command timeout. according documentation on msdn, default resiliency method sql server is: defaultsqlexecutionstrategy : this internal execution strategy used default. strategy not retry @ all, however, wrap exceptions transient inform users might want enable connection resiliency. as documentation mentions, strategy not retry @ all. still have ten retries. have tried create class inherits dbconfiguration have not found documentation on how c...

c++ - Why is "Start Debugging" so much slower than "attach to process" in VC2010? -

i have program holds sveral mb (up gb) in hash tables (boost::unordered_map / unordered_set) etc. when use "start debugging" in vc2010, freeing such table may take incredibly long (several minutes), have terminate process. if start same binary without debugging freeing done in fraction of second. in both cases use same optimized release x64 build. i read 2 existing questions topic: what difference between start debugging , attach process , what's advantage 'attach process' compared 'start debugging'? but dont answer question: done more when start debugging, , there way turn off? need detection of access violations , possibility set breakpoints etc. being unable pass through deallocations etc. real problem. using "start without debugging" , later attaching process not making things easier. when start program running windows debug heap enabled. nice, adds lots of pointer checking automatically invoke break when heap corrupte...

How to add a new .cpp file to, and then build, a c++ library for Android? -

i'm making unity3d plugin this c++ library android. ive gotten work in windows opening visual studio project library makers provided, adding new .cpp file api code , building dll. i'm wondering how can add new .cpp file library , build android. far have installed android sdk , ndk on machine ubuntu , built original library using ndk-build (as per these instructions) i'm guessing not simple copying .cpp file folder , building there androidmanifest.xml files , on. the androidmanifest.xml file not pertinent ndk build. you need find appropriate android.mk file. may need add file name local_src_files in make file, although may have set compile .cpp files in directory or more intelligent along lines. is, after all, regular make file. see here info on android.mk file specifics. edit: i suppose should add local_src_files preceding relevant include $(build_shared_library) library intend build. each make file may contain arbitrary number of targets, althoug...

c++ - Run c scrips from a shell script -

i have shell script #!/bin/csh @ x = 1 while ($x <= 2) nohup ./prog1 && ./prog2 & @ x ++ end i want run sequentially 2 times prog1 , prog2 compiled trough makefile. how can it? script right? if do chmod u+x test.csh ./test.csh i error ./prog1: /usr/lib64/libstdc++.so.6: version `glibcxx_3.4.11' not found (required ./prog1) this makefile gslflags := `pkg-config --cflags gsl` libgsl := `pkg-config --libs gsl` cflags = -o3 -fopenmp libomp = -lgomp dist.o:dist.cxx g++ -wall -c dist.cxx prog1.o:prog1.cxx g++ -wall -c prog1.cxx $< ${gslflags} ${cflags} prog1:prog1.o dist.o g++ ${cflags} -o $@ $^ ${libgsl} prog2.o:prog2.cxx g++ -wall -c prog2.cxx $< ${gslflags} ${cflags} prog2:prog2.o dist.o g++ ${cflags} -o $@ $^ ${libgsl} it appears search path standard c++ library set differently in csh vs. when run command line. linking standard libraries statically should make library search path irrelevant: chang...

python - django - import error: no module named views -

i've been racking brains , can't figure out why there should import error when 'views' imported. following message when visit index page: " request method: request url: http://127.0.0.1:8000/moments/ django version: 1.6.1 exception type: importerror exception value: no module named views exception location: c:\python27\lib\site-packages\django\utils\importlib.py in import_module, line 40 " here urls.py from django.conf.urls import patterns, url moments_app import views urlpatterns = patterns('', url(r'^$', "views.index", name='index'), url(r'^$', "views.choose_dataset", name='choose'), url(r'^get_moments/', "views.get_moments", name='get_moments'), url(r'^learn/$', "views.learn", name='learn'), url(r'^(?p<moment_id>\d+)/$', "views.detail", name='detail'), ) i have module named...

java - Errors with Google Glass bar code projects -

i trying create bar code scanner app google glass similar ones out there zbar, barcodeeye, or zxing. when download projects github , import them eclipse workspace become riddled errors. examples zxing project. https://github.com/zxing/zxing for zxing, inside benchmarkactivity.java file benchmarktask.execute(asynctask.thread_pool_executor); *execute errored out in benchmarkasynctask.java multiformatreader reader = new multiformatreader(); *multiformatreader not recognized it seems errors eclipse not recognizing types , methods declared developer, lead me think may not have right sdk's installed. seems strange me though, because have glass sneak peek installed. , yes have tried importing.

The parameterized query expects the parameter which was not supplied c# SQL -

i new in sql , c# , encountered sql error. the parameterized query '(@pid nvarchar(4000),@desc nvarchar(4000),@cat nvarchar(4000),@p' expects parameter '@pid', not supplied. i need help. thanks! public void insertrecord() { sqlcommand cmd = new sqlcommand("insert products values (@pid, @desc, @cat, @price, @scode)", mycon); cmd.parameters.addwithvalue("@pid", productid); cmd.parameters.addwithvalue("@desc", description); cmd.parameters.addwithvalue("@cat", category); cmd.parameters.addwithvalue("@price", price); cmd.parameters.addwithvalue("@scode", suppliercode);//corrected "key codes" mycon.open(); cmd.executenonquery(); mycon.close();//added these lines of codes } you must check every parameters if null. if are, have pass dbnull.value . sqlparameter pidparam = command.parameters.addwithval...

c# - show popup when we click marquee in asp.net -

i using marquee displaying news , announcement. can tell me how can show popup. when click marquee in asp.net. you can using jquery ui. example: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>jquery ui dialog - default functionality</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.9.1.js"></script> <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css"> <script> $(function() { $( "#dialog" ).dialog(); }); </script> </head> <body> <div id="dialog" title="basic dialog"> <p>this default dialog useful displaying information. dialog window can moved, resized ...

php - inheritance and external files. How do I go about it? -

i have 3 files. vehicleclass.php motorbikeclass.php (extends vehicleclass) index.php my question is... how connect 3. on index page, have have include 'classes/vehicleclass.php'; do need have include motorbike class or extend (inheritence) cover this? you can let php autoload files, registering own autoload function. if have, in example, class files in directory docroot . 'classes' (docroot being document root), can use function (example): function class_loader($class) { include docroot . 'classes/' . $class . '.class.php'; } spl_autoload_register('class_loader'); now if try create object of class 'foo', try include file docroot . '/classes/foo.class.php' before creating object. might want extend function bit, eg. lowercase file names ( include docroot . 'classes/'. strtolower($class) .'.class.php'; ). way can place class foo in foo.class.php.

c# - Implicit (bool) and == operator override - handle if statements correctly -

i have custom class implement both == , implicit boolean operator. is correct way handle possible, if ==/!= statements , expected result? this: public class foo { public bool result { get; set; } public static bool operator ==(bool @bool, foo foo) { return equals(foo, @bool); } public static bool operator !=(bool @bool, foo foo) { return notequals(foo, @bool); } public static bool operator ==(foo foo, bool @bool) { return equals(foo, @bool); } public static bool operator !=(foo foo, bool @bool) { return notequals(foo, @bool); } public static bool operator ==(foo foo, foo foob) { return equals(foo, foob); } public static bool operator !=(foo foo, foo foob) { return notequals(foo, foob); } public static implicit operator bool(foo foo) { try { return foo.result; } catch { return false; } } private static bool equals(foo foo...

android - Context for getDefaultSharedPreferences() in database function file -

i have file, have functions database , 1 query need preferences getdefaultsharedpreferences() , don’t know how can context easily. here fragment of file: public class database { private sqliteopenhelper openhelper; public cursor getvzkazy(long uzivatel) { sqlitedatabase db = openhelper.getreadabledatabase(); int limit = preferencemanager.getdefaultsharedpreferences(this).getint("limit", 100000); return db.query(tb_name_vz, columns_vz, null, null, null, null, column_id_vz + " desc", string.valueof(limit)); } } you'll need pass context when instantiating the database class. add public constructor class database: public class database { private context mcontext; public database(context context) { mcontext = context; } } then use mcontext, passing "this" won't work it's of type database , expects type context, that'll produce compilation error.

c++ - What is the equivalent of unsigned long int in c#? -

i have c struct defined follows: typedef struct { unsigned long int a; } test; i want create c# equivalent of struct? any help? confusing me "unsigned long int" at least 32-bit , mean, it's either 32-bit, 64-bit or 16-bit, right? you want uint or ulong depending on int or long was on native c platform: c# uint 32 bits c# ulong 64 bits the at least , platform dependency necessary concern in c because translated machine code , c developed many architectures varying word sizes . c# on contrary defined against virtual machine (exactly java or javascript ) , can abstract hardware's word size in favor of 1 defined language's standard vm (the clr in c#). differences between vm , harware word size taken care of vm , hidden hosted code.

Remove jquery slider bar outer border -

Image
im trying remove outer border of bar , cant seem figure out no matter what. ive looked others on , ive tried. here sample <div id="vertical-slider"></div> .ui-slider .ui-slider-handle { margin-left: .2em; cursor: hande; position: absolute; height: 1.em; width: 1.em; z-index: 2; outline: 0px; outline: none; } .ui-slider .ui-slider-handle:focus { outline: none; } .ui-slider-handle { outline: none; } i know 1 of "damn took" solutions :d #vertical-slider { border:0; } worked me jsfiddle example

How to pass variable into field id javascript -

i'm pretty new stuff - i've got code that's working, not elegant: function cost(){ var runningcost=0 if (document.getelementbyid('field_280_0').checked==true) { runningcost=100; } else { if (document.getelementbyid('field_281_0').checked==true) { runningcost=runningcost+12 } if (document.getelementbyid('field_282_0').checked==true) { runningcost=runningcost+12 }if (document.getelementbyid('field_283_0').checked==true) { runningcost=runningcost+12 }if (document.getelementbyid('field_284_0').checked==true) { runningcost=runningcost+12 }if (document.getelementbyid('field_285_0').checked==true) { runningcost=runningcost+12 }if (document.getelementbyid('field_286_0').checked==true) { runningcost=runningcost+12 }if (document.getelementbyid('field_287_0').checked==true) ...

jquery - How to validate email live using javascript and change textbox background color -

Image
my java code: <script type='text/javascript'> $(document).ready(function () { $('#email').keyup(function() { var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-za-z\-0-9]+\.)+[a-za-z]{2,}))$/; if (re.test($(this).val())) { $(this).css("background-color", "green"); } else { $(this).css("background-color", "red"); } }); }); </script> my html: <p><b>email address:</b> <input type="text" name="email_address" id="email" /> </p> i looking live-update type of effect user types, not click-away affect. nothing seems work, have used similar code change values of other text-boxes in live-fashion. sorry if repeated question. thank yo...

javascript - Highcharts Redrawing images based off of chart width -

i'm drawing redraw images on highcharts based off of width. ive made progress still cant redraw these images within values stay on chart. http://jsfiddle.net/jimbob25/v446c/ i've attached fiddle shows problem. code below part of solution far. //line 18 redraw: function () { //gets called when chart resizes var offset = (750 - chart.chartwidth); initdrawing(chart, offset); console.log(offset); } //line 96 call initdrawing function on initial load draws arrows var offset = (750 - chart.chartwidth); initdrawing(chart, offset); //line 99, have call init drwaing , pass in offset know how far redraw. have remove each of arrows after each redraw. function initdrawing(chart, offset) { var renderer = chart.renderer; $("#goal1").remove(); $("#goal2").remove(); here's version of code instead of doing calculations , trying place images using chart.renderer , adds t...

java - Change from one Activity to another -

so trying implement to-do list when click on item on list-view need go activity. code: textview tvitem = (textview) findviewbyid(r.id.tvitem); tvitem.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { intent = new intent(new intent(mainactivity.this, itemview.class)) ; startactivity(it); } please help to go ne next activity add onitemclicklistner: intent intent = new intent(this, activitytwo.class); this.startactivity (intent); all saving of tha activity must made on overriden method @override public void onsaveinstancestate(bundle savedinstancestate) { super.onsaveinstancestate(savedinstancestate); savedinstancestate.putboolean("myboolean", true); savedinstancestate.putdouble("mydouble", 1.9); savedinstancestate.putint("myint", 1); savedinstancestate.putstring("mystring", "welcome android"); // etc. } the savedinstancestate bundle pa...

c# - Questioning received JSON structure -

i'm using beta api ( http://developer.riotgames.com/api/methods ) returns json exposed methods. i've been able use json.net deserialize of these return values far. however, today consumed 1 of function returns json valid in opinion not correct. you're wondering, why don't ask on beta forum? have haven't received answer far , in general intrigues me. a snippet of json return: "1001": { "name": "boots of speed", "plaintext": "slightly increases movement speed", "group": "bootsnormal", "description": "<... } the problem have structure id used "group" without identifier. able use decently if had "itemid" : "1001" but doesn't have that. don't mind manually parsing i'd first know whether or not json correct (not valid). do agree not clean way of creating json block contains list of elements or missi...

creating XML output in PHP -

i trying create xml file output in php remote phone book on ip phone, here code have: <?php $conn=mysql_connect("localhost","user","********"); mysql_select_db("db_name",$conn); header("content-type: text/xml"); header("connection: close"); header("expires: -1"); ?> <yealinkipphonedirectory> <?php $output='<yealinkipphonedirectory>\n'; $sql="select * contacts "; $rs=mysql_query($sql,$conn); while($result=mysql_fetch_array($rs)) { $output .= "<directoryentry>\n"; $output .= "<name>mobile:</name>\n"; $output .= "<telephone>" . $result["mobile"] . "</telephone>\n"; $output .= "</directoryentry>\n"; } $output='</yealinkipphonedirectory>\n'; echo '$output'; ?> but error message: this page contains following errors: error on line 3 @ co...

How can I resize an uploaded image in PHP -

Image
this question has answer here: php upload , resize image 4 answers i using code users can upload images site $allowed_filetypes = array('.jpg','.gif','.bmp','.png','.jpeg','.jpg','.png','.bif','.gif','.jpeg'); // these types of file pass validation. $max_filesize = 524288; // filesize in bytes (currently 0.5mb). $uploadpath = "/home/path/to/file/files/avatars/$_session[user]"; $posted9 = hash('md5',$_session["user"]).$ext; /* not security mind you. */ // upload file specified path. $f = file_put_contents( $upload_path . $posted9, file_get_contents('php://input') ); if($f) $m="avatar updated<br/>"; // worked. else $m="there error during file upload. please try again....

javascript - Whats wrong with my statement in js.php file -

trying simple html change ternary operator. page loads fine , thing missing in html #np_msg element. not sure wrong here. code snippet from form.js.php var toprighttext = <?php echo ($company_id==69) ? 'please add organization.' : 'please add nonprofit.'; ?> jquery('#np_msg').html(toprighttext).show(); html appears <div class="donationrequestformright"> <div class="donationrequestinputwrap clearfix"> <label class="donationrequestlabel" for="donationrequest_nonprofit"> organization <span>*</span> </label> <input type="text" class="donationrequestinputbox correct" name="general[np_name]" id="donationrequest_nonprofit" value=""> <input type="hidden" name="general[np_id]" id="np_id" value="0...

list - css pseudo class stops working when in different tag -

i'm stomped on 1 , don't know terms search for...(at least ones tried isn't turning close i'm looking for) what i'm trying use css expand/collapse list using checkbox (no javascript, manager's request). problem i'm running works if it's under same tag list. example below this works: --head-- <style type="text/css"> .hide:checked ~ #list { visibility: collapse; } </style> --body-- <div> <input type="checkbox" class="hide" checked="checked"> hide <table id="list"> <tr> <td>test</td> </tr> <tr> <td> <ol > <li>item 1</li> <li>item 2</li> <li>item 3</li> </ol> </td> </tr> </table> </div> but doesn't --head-- <style type="text/css...

c# - advice for SQL query with row values as columns -

what best way go returning result set distinct zone values columns below basic select query? select weight, base_rate, zone rates modeid = 984 here table: rates table: id int modeid int base_rate decimal zone varchar weight decimal i tried creating pivot query accomplish this, far have been unsuccessful. ideas? should manipulating results in c# code instead? results put gridview. this result set like weight zone1 zone2 zone3 zone4 5 5.50 5.65 5.75 6.00 10 5.55 6.00 7.00 8.00 15 7.50 8.00 9.00 10.00 here failed attempt @ creating pivot query. select * ( select weight, base_rate, zone rates modeid=984 ) d pivot ( max(weight) zone in (select distinct zone d) ) piv; sql server not allow using select statement list of columns pivot. columns names must know @ run-time. if have limited number of values, need hard code query: select weight, zone1, zone2, zone3, zone4 ( select weight, base_rate, zone ...

linux - What is the use of various Qt platform plugins? -

i doing cross compiling of qt5.2 application arm based target (ti am335x evm) , failing display on platform. after doing google’ing found if launched with: ./helloworld -platform eglfs it show (full screen, worked)! i started looking @ platform options, found: android, eglfs, linuxfb, minimalegl, windows, xcb, cocoa, ios, offscreen, qnx, directfp, kms, minimal, openwfd i’m wondering for. assume, example, if wanted run application on android device i’d have pass -platform android , they’re not obvious me. is there listing anywhere of when each of these parameters should used? for example, eglfs stand for? , why did need use linuxfb didn’t work? (i have thought linux frame buffer how wanted launch application since running on embedded linux) if linuxfb plugin doesn't work, possibly didn't correctly configure framebuffer device on system. maybe directf layer running, may want try directfb plugin instead. if wish avoid having specify platform o...

Java HashMap Sepator and Fields -

i want use separtor , different fields in hashmap, trying write program find duplicate firstname , lastname fields in data add sequction number, check firstname && lastname in records if firstname && lastname found duplicate add seqnumber in feilds 0,1,2,3.. if didn't find duplicate 0 i write code working fine.. but, checking line.. instead of fields, need check 2 fields firstname , lastname.. please me!! here inputdata file:- have data file like: custmernumber,firstname,lastname,address1,city 123456789,abcd,efgh,12 spring st,atlanta 2345678,xyz,lastname,16 sprint st,atlanta 232345678,abcd,efgh ,1201 sprint st,atlanta 1234678,xyz,lastname,1234 oakbrook pkwy,atlanta 23556,abcd,efgh,3201 sprint st,atlanta 34564,robert,parker,12032 oakbrrok,atlanta i want output data file like: custmernumber,firstname,lastname,address1,city,**seqnumber** 123456789,**abcd,efgh**,12 spring st,atlanta,**0** 232345678,**abcd,efgh** ,1201 sprint st,atlanta,**1** 23556,**...

C++ How to declare pointer to 2D array -

this question has answer here: declaring pointer multidimensional array , allocating array 6 answers i have portion of code goes (assume types int ): for(int = 0; < h; ++i) { for(int = 0; < h; ++i) { if(...) { = b[i][j] } else { = c[i][j] } } } i write check if condition once. how go in declaring pointer 2d array adequately (variable d in example below) ? if(...) { d = b; } else { d = c; } for(int = 0; < h; ++i) { for(int = 0; < h; ++i) { = d[i][j] } } combining @madsciencedreams' answer , @grijesh chauhan comment, following seems work: double a[1000][1000]; double (*b)[1000][1000] = &a; and access value: double = (*b)[i][j];

php - How do i properly create a function in a helper file in codeigniter -

i trying learn code igniter , creating helper files. have functions_helper.php file located in applications/helpers folder: <?php if ( ! defined('basepath')) exit('no direct script access allowed'); function __construct() { parent::__construct(); $this->load->model('user','',true); } if (!function_exists('check_status')){ function check_status() { $ci = & get_instance(); $result=$ci->user->get_status(); //this line 14!! if($result) { $status_array=array(); foreach($result $row) { $status_array=array( 'source' => $row->status, 'current' => $row->id ); if ($status_array['current'] == 1) { $status_array['current'] = "live"; } else { $status_array['current'] = "amazon down"; } $ci->session->set_userdata('st...

ios - How do I add a Touch Event to this UIScrollView Infinite Scroll Picker? -

i'm using infinitescrollpicker github https://github.com/seitk/infinitescrollpicker/ in project. way works right when scroll menu stops on selection automatically loads storyboard scene. want change have tap on menu image in order load storyboard scene instead of happening on selection. how that? i think relevant code infinitescrollpicker.m need change. i'm thinking sort of gesture recognizer i'm not sure or how add code below. // disable scrolling when snapping new location dispatch_queue_t queue = dispatch_get_main_queue(); dispatch_async(queue, ^ { [self setscrollenabled:no]; [self scrollrecttovisible:cgrectmake(newx, 0, self.frame.size.width, 1) animated:yes]; dispatch_async(dispatch_get_main_queue(), ^ { sel selector = @selector(infinitescrollpicker:didselectatimage:); if ([[self firstavailableuiviewcontroller] respondstoselector:selector]) { #pragma clang diagnostic...

ssl - How can I generate a self-signed certificate with SubjectAltName using OpenSSL? -

i trying generate self-signed certificate openssl subjectaltname in it.while generating csr certificate, guess have use v3 extensions of openssl x509. using : openssl req -new -x509 -v3 -key private.key -out certificate.pem -days 730 can me exact syntax? can me exact syntax? its 3 step process, , involves modifying openssl.cnf file. might able command line options, don't way. find openssl.cnf file. located in /usr/lib/ssl/openssl.cnf : $ find /usr/lib -name openssl.cnf /usr/lib/openssl.cnf /usr/lib/openssh/openssl.cnf /usr/lib/ssl/openssl.cnf on debian system, /usr/lib/ssl/openssl.cnf used built-in openssl program. on recent debian systems located @ /etc/ssl/openssl.cnf you can determine openssl.cnf being used adding spurious xxx file , see if openssl chokes. first, modify req parameters. add alternate_names section openssl.cnf names want use. there no existing alternate_names sections, not matter add it. [ alternate_names ] dns....

Quick PHP regex for digit format -

i spent hours figuring out how write regular expression in php need allow following format of string pass: (any digit)_(any digit) which like: 219211_2 so far tried lot of combinations, think 1 closest solution: /(\\d+)(_)(\\d+)/ also if there way limit range of last number (the 1 after underline) amount of digits (ex. maximal 12 digits), nice. i still learning regular expressions, appreciated, thanks. the following: \d+_\d{1,12}(?!\d) will match "anywhere in string". if need have either "at start", "at end" or "this whole thing", want modify anchors ^\d+_\d{1,12}(?!d) - must @ start \d+_\d{1,12}$ - must @ end ^\d+_\d{1,12}$ - must entire string demo: http://regex101.com/r/jg0ez7 explanation: \d+ - @ least 1 digit _ - literal underscore \d{1,12} - between 1 , 12 digits (?!\d) - followed "something not digit" (negative lookahead) the last thing important ot...

bufferedreader - An error with reading a file - java -

i can't seem change quantities of recipe. please help. i'm beginner java. after enter new serving number, prints 'a read error has occur'? import java.util.scanner; import java.io.filewriter; import java.io.bufferedwriter; import java.io.filereader; import java.io.bufferedreader; public class task2recipe{ private static string recipe; private static int newservingnumber; public static void main(string []args){ scanner userinput = new scanner(system.in); system.out.println("hello. if write new recipe, please type in 'write', if change recipe, please type in 'read'."); string option = userinput.next(); userinput.nextline(); if(option.equals("write")){ write(); } if(option.equals("read")){ read(); } } public static void write(){ try{ filewriter task2recipe = new filewriter("c:/year 11/gcse computing/a453/task 2/recipe.txt"); ...

testing - Executing test on remote agent fails with "Target machine actively refused it" -

i attempting run tests on remote agent using test controller on same remote machine. have set testsettings file follows: <remotecontroller name="machinename" /> <execution location="remote"> <agentrule name="allagentsdefaultrole"> </agentrule> when tell mstest execute selected test in release or debug mode, builds project , returns "failed queue test run 'run name': no connection made because target machine actively refused it." visual studio 2013 has been installed on controller/agent machine, , agent, controller, , client can communicate successfully. default ports being used communication (6901 , 6910), , telnet able connect. how test executing successfully? found answer. agents cannot debug remotely, , while build executing against in above post "release" (in 1 instance), still attempting debug. if select test , click "run" instead, executes on remote agent.

byte - java.util.zip.ZipException when adding a ZipEntry to a ZipOutputStream without a ZipInputStream -

i attempting add zipentry zipoutputstream running problems when trying write bytes. i got zipentry hashmap maps file names zipentries . chose method because dealing large zipinputstream , want able access contents easier looping through inputstream , looking file , getting zipentry . this causes problem when try write bytes after added entry. solutions have found far have needed zipinputstream . here code: zipentry ze = entryhash.get(pathtostring(path)); zos.putnextentry(ze); zos.write(new byte[(int)ze.getsize()]); // problem here zos.closeentry(); the error getting is: java.util.zip.zipexception: invalid entry compressed size (expected 389 got 12 bytes) @ java.util.zip.zipoutputstream.closeentry(zipoutputstream.java:248) how can fix exception? you need create new zipentry add zipoutputstream. code doesn't make sense. you're not copying old zipentry output technique, you're writing array of 0 bytes of same size. have read old zipentry ,...

algorithm - 0/1 knapsack and dynamic programming -

in http://en.wikipedia.org/wiki/knapsack_problem , dp is: // input: // values (stored in array v) // weights (stored in array w) // number of distinct items (n) // knapsack capacity (w) j 0 w m[0, j] := 0 end 1 n j 0 w if w[i] <= j m[i, j] := max(m[i-1, j], m[i-1, j-w[i]] + v[i]) else m[i, j] := m[i-1, j] end if end end i think switching order weight loop , number loop not impact optimal solution. right? say for j 0 w 1 n thanks. you correct. value of m[i,j] depends on values both smaller , js. situation changing lop order matters when 1 of elements can increase. example, if m[2,2] depends on m[1,3] need calculate first row comlpetely before moving second row.