Posts

Showing posts from March, 2015

php - Using cURL in a loop -

i'm writing script in unspecified number of files need uploaded via curl requests remote api. however, script hangs , times out. strangely enough, requests successful (the files uploaded), script unable continue. here's loop: foreach ($paths $path) { $ch = curl_init($path); curl_setopt($ch, curlopt_httpheader, array('x-auth-token: '.$token, 'content-length: '.filesize($path)); curl_setopt($ch, curlopt_put, true); curl_setopt($ch, curlopt_infile, fopen($path, 'r')); curl_setopt($ch, curlopt_infilesize, filesize($path)); echo curl_exec($ch); } i believe has loop. i've tried adding curl_close within loop, doesn't solve problem. ideas? put timeout in curl foreach ($paths $path) { $ch = curl_init($path); curl_setopt($ch, curlopt_httpheader, array('x-auth-token: '.$token, 'content-length: '.filesize($path)); curl_setopt($ch, curlopt_put, true); curl_setopt($ch, curlopt_infile, fopen($path, 'r

linker - Error: C++ unresolved external symbol -

Image
this question has answer here: what undefined reference/unresolved external symbol error , how fix it? 27 answers i using 2 c files written others in c++ project in visual studio 2008 (actually, provided free online polygon intersection library). the 2 files downloaded gcp.h , gcp.c. copied gcp.h , gcp.c project directory. linker gave me error: unresolved external symbol: void __cdecl gpc_polygon_clip(enum gpc_op,struct gpc_polygon *,struct gpc_polygon *,struct gpc_polygon *) below how wrote code uses library: static int poly_intersection(convex_polygon& poly1,convex_polygon& poly2,convex_polygon& rp) { if(!poly1.is_convex() || !poly2.is_convex()) return 1; // construct 1st convex polygon gpc_vertex *gvp1 = new gpc_vertex[poly1.size()]; gpc_vertex v1; (unsigned int n = 0; n < poly1.size(); n++) { v1.

sql server 2008 error: 26 - error locating server/instance specified -

this arun chennai. have developed first application in wpf (c#) vs 2008 & sql server 2008. works fine on system. after deployment, won't work on other systems. it shows following error message. system.data.sqlclient.sqlexception - network related or instance specific error occurred while establishing connection sql server. server not found or not accessible. verify instance name correct , sql server configured allow remote connections.(provider: sql network interfaces, error: 26 - error locating server/instance specified). i have gone through google , done following steps no use. server name : ecare432\sqlexpress instance name : sqlexpress app.config has: <connectionstrings> <add name="timetracker.properties.settings.myecareconnectionstring" connectionstring="data source=ecare432\sqlexpress;initial catalog=myecare;persist security info=true;user id=sa;password=ecare123@" providername="system.data.s

javascript - Ajax request to send file from jsp to servlet -

following been done using struts framework jsp <html:form action="/uploaddrawing" method="post" enctype="multipart/form-data"> <input type="file" name="attachfile" class="regi_textbox"/> <input type="submit" name="button" class="update_but" value="upload file" /> </html:form> form private formfile attachfile; public formfile getattachfile() { return attachfile; } public void setattachfile(formfile attachfile) { this.attachfile = attachfile; } action class formfile attachfile = uploaddrawingform.getattachfile(); this works fine me , need using ajax request (jsp-servlet), following tried no success--- jsp <script> function dynamicupload() { alert("function played"); var fd = new formdata($("attachfileform")); fd.append( 'file', input.files[0] ); alert(fd); $.ajax({ url: 'uploaddrawingser

javascript - how to center modal window with body hidden after scroll? -

Image
i have model dialog, while model dialog open setting body overflow:hidden makes model window display half only. onclose resetting body overflow. body height more window size , scrolled open modal dialog. how center display modal dialog? as option, can create function position modal depending on window size, this: something this: function repositionmodal(modal){ var windoww = $(window).width(), windowh = $(window).height(), modalw = modal.width(), modalh = modal.height(); if (modalw>windoww) modal.width(windoww); if (modalh>windowh) modal.height(windowh); modal.css({ "top": (windowh-modalh)/2)+"px", "left": (windoww-modalw)/2)+"px" }); } then call function when modal invoked, and, on window resize $(window).resize(function(){ if($(".my-modal").is(:visible)){ repositionmodal($(".my-modal")) } })

android - Launching an activity from the ListView -

public class listitem { public int sname; public int s_img; public string sid; } class xyz extends listactivity { . . . protected void onlistitemclick(listview l, view v, int position, long id) { //super.onlistitemclick(l, v, position, id); toast.maketext(listpage.this,items.get(position).sid,toast.length_short).show(); intent intent = new intent(v.getcontext(),displayscheme.class); startactivityforresult(intent,0); } } i wish start new activity above xyz class. activity should start when 1 of items on list clicked. in next activity, wish display further details of "listitem" object viz. s_img , sname; there way pass on clicked listitem object next displayscheme activity ? coz there no way in next activity find out item clicked in earlier activity. in advance. .............. edited ............... protected void onlistitemclick(listview l, view v, int position, long id) { //super.onlistitemclick(l, v, position, id);

java - Recovery deleted log files at logback worked fine on Windows but didn't work on Linux SUSE -

i using slf4j + logback 1.0.12 application logging infrastruction. run application on both windows xp , linux suse os. have scenario following: i deleted log files when application running. on windows xp logback recovery mechanism worked fine , after passing seconds (about 10 seconds) log files generate again on linux suse log files don't generate again. my question : why logback recovery mechanism has different behavior on 2 os? under linux, if process writes file , target file removed, process continues quietly write ghost file. error condition not trigger exception. this answers why recovery process behavior depends on os.

.net - Get the currently executing method name of current thread -

i using background worker process big files in loop lasting hours. in gui, show progressed file label, , progressbar control. of time ok. my problem is; sometimes, (maybe locked or corrupt files, although handled everthing in try catches), after hours, current file name , progressbar value doesn't change on gui (for ex. @ 10000 th. file), although gui still responsive me...that is, not gui freeze issue. doesn't background worker finished (i handled both reportprogress , completed events correctly)..and unfortunately, keeps @ state, kill , restart program, again stucks @ same file. so; want understand (at method, or line) code got stuck...try catch blocks doesnt give me clue.. to achieve this, planning put button on gui, , when got stuck on file, press button , it'll give me debug information, containing executing (stucked namely) method name , line number if possible... stacktrace etc. not solution, since when use it, gives me trace of method wrote in... any i

c# - Error in creating a table in mySQL -

i tried of suggestions still same error. have error in sql syntax; check manual corresponds mysql server version right syntax use near ''' (size int(5))' @ line 1 here code: try{ query = "create table @name (size int(5))"; mysqlcommand cmd = new mysqlcommand(query, con); cmd.parameters.add("@name", mysqldbtype.varchar, 30).value = txtboxname.text; con.open(); cmd.executenonquery(); con.close(); } catch (exception) { throw; } { if (con.state == connectionstate.open) { con.close(); } } i think intended use backticks `` escape table name used single quotes instead. query = "create table `"+ txtboxname.text + "`(size int(5))";

ruby on rails - Installing Passenger with NGINX as non-root -

i setting server not going use root install rvm,ror, nginx, etc. logon user id , run: \curl -l https://get.rvm.io | bash -s stable --rails --autolibs=enabled rvm, ruby , rails installed nicely. rvm -v ruby -v rails -v all return latest version numbers, planned now installing passenger nginx gem install passenger then preparing /opt/nginx folder sudo mkdir /opt/nginx sudo chmod 777 /opt/nginx as complaining cant create folder (as not root) coming to: passenger-install-nginx-module it stops with: compiling passenger support files... # /home/myapp/.rvm/wrappers/ruby-2.0.0-p0/rake nginx:clean nginx release=yes rake aborted! cannot load such file -- rubygems/builder whats next? you using ruby 2.0. ruby 2.0 supported since phusion passenger 4. phusion passenger 3 doesn't support it. phusion passenger 4 going released next week, can grab release candidate 6 gem install passenger --pre .

jquery - How to clean memory of browser in javascript from objects and classes? -

i making quest game 3 scenes. player can move scene scene , go back. (like known classic quests: neverhood,machinarium,the curse of monkey island) each scene have it's own objects, classes , bags of graphic elements. here how scripts 1 scene. <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="js/jquery.gamequery-0.5.0.2.js"></script> <!-- //////////////////////////////////////////////// /////////// charecters //////////////////// /////////////////////////////////////////////////////////////// --> <script type="text/javascript" src="js/charecters/player.js" id="player_anime"></script> <script type="text/javascript" src="js/charecters/mama.js" ></script> <!-- ////////////////////////////////////////////

dom - Get last node in XML using DOMDocument PhP -

i've made class reads value , node name of value , combines array use simple , quick access config in xml. solution works if ill give bottom node, xml looks this. <?xml version="1.0" encoding="iso-8859-2"?> <settings> <const> <inscript>true</inscript> <title>template</title> </const> <meta> </meta> <db> <user>user</user> <pass>pass</pass> <host>host</host> <name>name</name> </db> <path> <style> <css>/template/view/www/style/</css> <img>/template/view/www/style/img</img> </style> </path> </settings> now want example whole db node , return array node name wold key , node value, value. im stuck @ this. heres made far. class config { private static $xml = "lib/config/settings.xml"; private static $xmlroot = "settings"

regex - PHP - Match two strings ignoring span tags -

i looking function matches string string b (ignoring span tags) a) shopping <span>stylish</span> rugs area b) shopping stylish rugs area function should return true if match found else false, in above case should return true. thanks you can use strip_tags() remove tags string. $a = 'shopping <span>stylish</span> rugs area'; $b = 'shopping stylish rugs area'; var_dump(strip_tags($a) == $b); // outputs true

matlab - using quiver with two dimentional array -

Image
i have 2 dimentional array of x,y. first row x adn second row y. trying use quiver on array no success. if know how plot, great. thanks! is asking ? define 2d array (each column represents components of vector ) myarray = [1 2 3 4; 5 6 7 8]; extract coordinates of 4 vectors: u = myarray(1,:); v = myarray(2,:); define origin starting point 4 vectors: x = zeros(1,4); y = zeros(1,4); and call quiver function 2d vectors: quiver(x,y,u,v)

iphone - Marking face and eyes on image -

i working on app detects face , marks eyes , mouth on image.i have detected face ,eyes , mouth using cidetector position of eyes , face returns respect original image not according view of imageview on have mark faces , eyes i.e example have image of 720 *720 position of face , eyes retuns respect size of 720 *720.but problem ..i have show eyes , face annotated on image view of size 320 * 320. please advice me how can map postion of face returned cidetector position of face on image view. you can solve considering imageview size image size ratio . following simple , used solve problem. //'returnedpoint' position of eye returned cidetector cgfloat ratio = 320/ 720.0; //it like, cgfloat ratio = yourimageview.frame.size.width/ yourimage.size.width; cgpoint pointonimageview = cgpointmake((ratio * returnedpoint.x), (ratio * returnedpoint.y));

PHP: Why is this forced mime download adding 2 extra empty lines? -

i have php script wrote create .txt tab delimited file. need have forced downloaded web browser. this, when compare file source forced downloaded on contain 2 blank lines. here code: // force download of tab del .txt file web browser: header('content-type: application/download'); header("content-disposition: attachment; filename=$tab_del_file"); header("content-length: " . filesize($tab_del_file)); $fp = fopen($tab_del_file, "r"); fpassthru($fp); fclose($fp); linux shell command compare 2 files , show there blank lines: $ diff example.txt /tmp/example.txt 25a26,27 i sftp'ed downloaded example.txt /tmp directory diff on server. why 2 blank lines being added downloaded version , fix? thanks! as php code looks ok , not produce new lines, can have 1 reason. have closing ?> tag , new lines @ end of file: ?> <--- empty line <--- empty line note content outside php tags not par

jvm - In Java, can operations on object fields bypass the stack? -

java heap stores objects, , stack stores primitive data , object reference. consider a.a = b.b , a.a , b.b int . in understanding, jvm first value of a.a heap stack, , put value b.b on heap. seems the way change data on heap put value stack. my question is: there way operate data on java heap without stack? e.g., copy value of a.a direct b.b without stack operation. if "it depends on implementation of jvm", question dalvik. when considering jit, things complicated. think question java compiler, not jvm if thinking of javac should assume no optimisation , gives in byte code literal translation of code, stack based. in fact byte code using stack more example suggests. operations like push b getandpushfield b push popandsetfield i.e. instead of 1 stack operation, there notionally 3. the jit on other hand might optimise away not using register value. depending on processor // r3 contains a, r7 contains b, // starts @ 14th byte // b

How to add a method to a javascript object? -

this question has answer here: javascript add method object 4 answers i have js constructor: function myobj(){ this.type = "triangle"; } how add method like: triangle.mymethod(); you can use prototypes: // standard canvas object function canvasobj(canvas, x, y, w, h, fill){ this.x = x||0; this.y = y||0; this.w = w||0; this.h = h||0; this.objects = []; this.ctx = context_for(canvas); this.init(canvas, fill); }; // initial set-up of canvas canvasobj.prototype.init = function(canvas, fill){ position_element(canvas, this.x, this.y); resize_canvas(canvas, this.w, this.h); draw_rect(this.ctx, 0, 0, this.w, this.h, fill); };

Handling custom url for http protocol in Android -

Image
when use custom scheme (for example myhttp) works expected, if use http , not handle, , every time browser opens host (eg:192.168.1.111). how can solve problem? my manifest.xml <intent-filter> <action android:name="android.intent.action.view" /> <category android:name="android.intent.category.default" /> <category android:name="android.intent.category.browsable" /> <data android:scheme="http"/> <data android:host="192.168.1.111"/> </intent-filter> my activity: public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); final intent intent = getintent(); log.i("mytag", "here--01"); } give intent filter higher priority default browser: http://developer.android.com/guide/topics/manifest/intent-filter-element.html#priority <intent-fi

javascript - JS: How to reset index inside a for-loop so it loops again without lots of timeout errors? -

i'm working on custom js thumbnail changer , works. want loop thumbnails indefinitely. @ moment goes until i==thumbs , stops. here codesnipped: for (var = 1; <= thumbs; i++) { timer[i] = settimeout("thumbchange('" + image_id + url + + '.jpg' + "')", * 100 * 10); } what want is, if i reaches thumbs (the last thumbnail), reset i 1 , play for loop again. can't work. i tried lots of things including following, crashes browser because of timeouts: can somehow around timeout problem completely? for (var = 1; <= thumbs; i++) { timer[i] = settimeout("thumbchange('" + image_id + url + + '.jpg' + "')", * 100 * 10); if (i == thumbs) { = 1; cleartimeout(timer[i]); continue; } } alternatively use setinterval automatically loop forever or until clear it. note in setinterval , settimeout should use functions not evaluation strings. var img = 0

How to go Next Activity directly after Login in facebook SDK 3.0 in android -

i using facebook sdk 3.0 when login facebook come login screen go next activity want go directly next activity. this code :- if (session.isopened()) { token = session.getaccesstoken(); log.i("tag", "access token" + token); request.executemerequestasync(session,new request.graphusercallback() { @override public void oncompleted(graphuser user, response response) { if (user != null) { id = user.getid(); log.i("tag", "user id " + user.getid()); log.i("tag", "email "+ user.asmap().get("email")); try { url image_value = new url("http://graph.facebook.com/"+id+"/picture?type=large" ); profpict=bitmapfactory.decodestream(image_value.openconnection().getinputstream());

css - SCSS: Assigning two values to a variable -

i using this mixin generate media queries. mixin works inserting 2 values (a min width , optional max width): @include respond-to(300px,500px) { .this-is-not-in-ie-either { color: green; } } the trouble max/min width values difficult remember. rather insert key word variable. e.g. $mob: 0, 480px; $tab: 480px, 940px; however, scss misunderstands min width being "0, 480px" , max-width being "undefined". is possible have variable holds 2 values. i know use 2 key words (e.g. $mob-min, $mob-max), rather use one. when write this: $mob: 0, 480px; @include respond-to($mob) { .this-is-not-in-ie-either { color: green; } } what you're doing passing list first argument mixin: @include respond-to($mixins-first-arg: (300px,500px)) { .this-is-not-in-ie-either { color: green; } } what need write this: @include respond-to($mob...) { .this-is-not-in-ie-either { color: green; } }

php - Begin with OOP by using classes as a collection of methods? -

is wise start object-oriented php using classes collection of methods? there drawbacks approach? i know oop more this, php-projects small take advantage of oop has offer. on other hand, projects becoming big update/maintain procedural programming. i have read many topics oop , once in while says "oop more collection of functions" (or along these lines). made me think: may true, may chance dive world of oo-programming doing that. so, smart first step start using , learning oop? or there serious drawbacks need know about? your question real broad, deserves simple answer can memorize , keep while continue journey world of object oriented analysis , design (ooad). so, smart first step start using , learning oop? or there serious drawbacks need know about? as can imagine, not possible answer question directly. smart , not depends lot of our own abilities. e.g. persons might smart, because helps them stop errors , way go. others, might complete desaster,

store - vhdl compare new input with old input -

how do it? i new , sure easy enough can't seem figure out how here pseudo code port(x,y: in std_logic_vector (2 downto 0) -- 3 bit input counted eg ("000", "001", "010"... "111", "000" ...) q_out : out integer); -- example signal temp_q_out: integer; when x (or y) increments -- part can't temp_q_out <= temp_ q_out + 1; case temp_q_out when 0 q_out <= 7 when 1 q_out <= 12 when 2 q_out <= 4 when others q_out <= 100 how make temp_q_out count when x or y increments , @ no other time? want output q_out 7 until x or y changes 12 till x or y changes again 2. happens output becomes 100 straight away. any @ appreciated cheers guys :-) i don't think there safe way want asynchronous logic. assuming want synthesize this, need clock input. then, can add process stores previous values of x , y , , checks whether new value equal old value or not. here's example: pro

java - Error in Log Cat -

hi new in programming , have error in log cat. log cat shows 'fatal exception main' , application has stopped unexpectedly.i trying deal several days. application supposed show battery information 05-02 22:01:11.836: i/process(521): sending signal. pid: 521 sig: 9 05-02 22:18:54.743: d/dalvikvm(550): gc_external_alloc freed 1238 objects / 82472 bytes in 181ms 05-02 22:18:55.654: w/resourcetype(550): no package identifier when getting value resource number 0x00000032 05-02 22:18:55.664: d/androidruntime(550): shutting down vm 05-02 22:18:55.664: w/dalvikvm(550): threadid=1: thread exiting uncaught exception (group=0x4001d800) 05-02 22:18:55.744: e/androidruntime(550): fatal exception: main 05-02 22:18:55.744: e/androidruntime(550): java.lang.runtimeexception: unable resume activity {vader.batterydroid/vader.batterydroid.pageinfo}: android.content.res.resources$notfoundexception: string resource id #0x32 05-02 22:18:55.744: e/androidruntime(550): @ android.app.activitythre

jQuery - Getting href from <a> -

i have jsfiddle here - http://jsfiddle.net/q73nd/3/ and demo here - http://www.ttmt.org.uk/forum/thumb/ i want sequentially load thumbnails , load bigger image of first thumbnail above. my problem can't href large image <a> i have vars <a> , imgcounter. i'm trying use these href console.log(link[imgcounter]).attr('href'); how href here? link jquery object, link[imgcounter] dom element. either use .eq [docs] element jquery object // jquery object link.eq(imgcounter).attr('href') // or .prop('href) or access dom element's href property // dom element link[imgcounter].href

Vim goes whack with tmux -

Image
nerdtree goes whack in tmux session in picture. same problem exists when windows split. using powerline time vim status goes whack(in picture see middle portion of status line) in tmux. wrong? i figured solution after long time, looking @ dotfile repo in github. single line of code made communication between vim , tmux smooth. in .tmux.conf file, add line set-window-option -g utf8 on

Assembler and C programming linux -m32 (char-byte from register in assembler) -

i'm new assembly programming, wrote function in c need call function in assembly. seems register wants give 4 characters (bytes) instead of one, want. ignore code after jump, since jump skip part of code until make work properly. this supposed part of own simplified version of sprintf in c. removed of code things work. it's supposed return first parameter % . so, when call assembler function in c, can write printf("%s", res); (or %c in example) , prints % : .globl printpercent # name: printpercent # synopsis: simplified sprintf # c-signature: int printpercent(unsigned char *res, unsigned char *format, ...); # registers: %eax: first argument # %ebx: second argument printpercent: # sprinter pushl %ebp # start of movl %esp, %ebp # function movl 8(%ebp), %eax # first argument movl 12(%ebp), %ebx # second argument loop: movb $37, %bl # low

jquery - html string into css - how to? -

i using plax jquery plugin, uses html-string: data-xrange="" data-yrange="" here's fiddle of project: http://jsfiddle.net/4krdl/ i responsive, i've did. problem now, when window minimized, data-xrange="" data-yrange="" -string makes elements move much, because of window size. i not great @ jquery here's question(s): possible adjust data-xrange="" data-yrange="" either css or jquery? , how done? if element has id (or class - doesn't matter), jquery , change attribute: $('#your-element') .attr('data-xrange', 'new value') .attr('data-yrange', 'new value'); // can dynamically redefine range of layer // running plaxify() on again. $('#your-element').plaxify();

java - Spring application context : access web.xml context-params? -

greetings , is there way values web.xml context-param spring context? for example define value in web.xml : <context-param> <param-name>compass-index</param-name> <param-value>file:///home/compass/index</param-value> </context-param> and want assign value bean-property as: <bean ...> <props> <prop key="compass.engine.connection"> ${from web.xml context-param?} </prop> </props> </bean> thanks in advance? yes - servletcontextpropertyplaceholderconfigurer this article explains details. in short, need: <bean class="org.springframework.web.context.support.servletcontextpropertyplaceholderconfigurer"> </bean> and use properties like: <bean ...> <property name="compassindex" value="${compass-index}" /> </bean> or @value("${compass-index}")

objective c - how would i move a folder or the contents from one place to another Via code in Xcode? -

im trying make mac app copies , pastes folder location can find tutorial on how go along , make app mac per pose app makes easy move mod files games file system. yes know theres lots of apps goes same want make own. structure theres 6 nstextfields 3 mods folders , 3 games folder system (mod's parts path, mod's plugin path, mod's plugin data path, game's parts path, game's plugin path , games's plugin data path). ive looked on stackflow , google , couldn't find on tutorial on how maybe im looking in wrong places. game manly ksp (kerbal space program) what did googled? need simple gui application 6 labels, 6 textfields , 1 button. there 1 function linked button. function use data textfields , nsfilemanager 's copyitematpath:topath:error: method. google "osx first app" or "xcode textfield tutorial" details on how create app textfield , button.

ruby on rails 3.2 - Case statement in Slim -

is there way write case statement in slim following example. made changes stackoverflow question: how write switch statement in ruby case when 1..5 = "it's between 1 , 5" when 6 = "it's 6" when string = "you passed string" else = "you gave me #{a} -- have no idea that." end i tried following generates error. = case @taxon.name = when "wedding cakes" div.taxon-descripiton wedding cake description this told ... syntax error, unexpected tivar, expecting keyword_when ; @output_buffer.safe_concat(("<when>\"weddin... = used when want render something, when want call ruby logic without rendering in view should use - : - case @taxon.name - when "wedding cakes" div.taxon-descripiton wedding cake description i not sure solve problem though, have considered moving logic decorator anyway?

servicestack - StringMapTypeDeserializer (null) - Property '_' does not exist on type -

deployed new service , started getting above error. service works, error reported in logs. 2013-05-03 09:56:36,455 [51] warn servicestack.servicemodel.serialization.stringmaptypedeserializer (null) - property '_' not exist on type 'services.web.statuslist' here 2 types: public class statuslist : ireturn> { public string search { get; set; } public int limit { get; set; } public int page { get; set; } } public class comboitemresult { public int id { get; set; } public string text { get; set; } } and actual service simple linq query. said, works when call api. above error in logs. version 3.9.43 - ideas? that's not issue. it's warning states "_" parameter doesn't exist. parameter set jquery ajax requests eliminate browser cache, e.g.: http://yourhost/api/service?_=1367679839904 for more details see: https://github.com/servicestack/servicestack/blob/master/src/servicestack.client/serialization/string

authentication - How I can create new user from Java class to GlassFish? -

i'm creating basic web application user can register , login. there registration, login , login error page. i'm using glassfish server authentication. i know there possible way create new user java class or servlet when user created, saved 'file' realm of glassfish? more specific here's want do: create user using entity class defined. save user entity database. create new user username , password glassfish file realm. this far have got requirement working quiet neat because must done manually everytime when want create new user. there anyway automate process? i found solution this. solution need create jdbc realm in glassfish , config giving required information such jndi, user group table, user name column, password column, groups table , etc. note: can't file realm, since in file realm save user details file , not read there.

sql - C# Reporting via query -

hi have code here sqlconnection con = new sqlconnection(properties.settings.default.storedbconnection); sqldataadapter da = new sqldataadapter(); private void form1_load(object sender, eventargs e) { string test = datetime.now.tostring("yyyy-mm-dd"); var dept = properties.settings.default.giftdepartment; messagebox.show(""+test+""); sqlcommand cmd = new sqlcommand("select deptno,deptsales,deptcustomers storesalesdetail deptno="+dept+" , procdate>="+test+"", con); sqldataadapter da = new sqldataadapter(cmd); dataset1 ds = new dataset1(); da.fill(ds); reportviewer1.localreport.datasources.clear(); reportviewer1.localreport.datasources.add(new microsoft.reporting.winforms.reportdatasource("dataset1", ds.tables[1])); this.reportviewer1.refreshreport(); } sample data in table 2013-05-03 00:00:00.000,2,120.0000,1,1

JQuery mouse event issue -

i use jquery 1.9.1, , want bind mousewheel event, cant judge mouse or mouse down. event search information google, shows $(document).bind('mousewheel', function(event, delta){ console.log(event); console.log(delta); return false; }); but not work in chrome browser, me solve problem. thanks.

java - sort images by how detailed they are -

i'm looking java package allow me sort images how detailed are. create service scan images , filter out non-interesting images. i'm aware there no absolute way of doing make best effort. thanks! use opencv quite powerful library play images. here sample algorithm you. convert image rgb grayscale image. sum color of image pixel pixel// there sum() method automatically sums. divide result numpixel(=height*width)//there may methods mean() standard deviation of pixels// if stddev > thresh "interesting image"

c# - LDAP with Custom Membership Provider -

i'm in bit of pickle here. want authenticate users through ldap , automatically create accounts users when log in first time. so far i've created custom membership provider & i'm able log in ldap credentials. next step have in mind capture username , store in local database, creating new user. problem is, createuser method requires database items don't need such 'isapproved' or 'islockedout'. don't want store user passwords if possible , authenticate directly ldap store. to cut chase, best option? stick current custom membership provider & have additional database fields don't require implement custom membership user + custom membership provider (the long route) iprincipal & iidentity? any feedback appreciated. thanks! p.s. i'm using ef code first mvc 4. i've managed figure out. decided use default database fields, stuck custom provider , used createuser method add new users database.

mysql - Friends my Friends recently add -

im building platform users can connect other users (social platform) i have table called friends , saving connections user_id | friend_id | request | add_date now need write sql query recent friends specific user's friends added or not friends of user. user must accepted. think of news feed , see friends added (the new add person can friend or not) so far have works when friend added people have. select user_main_id frmname, friend_id type_id, add_date date friends friend_id in (select friend_id friends (friend_id='$user_id' or user_main_id='$user_id') , request=1 , friend_id!=$user_id) , request=1 , friend_id!=$user_id , user_main_id!=$user_id order date desc maybe there better why approach this. suggestions? appreciated thanks. connection bilateral, no difference between user_id , friend_id. designed names , had carried forward. sample record 96618 50683 1 2013-05-08 13:44:31 96618 1230 1 2013-04-03 18:28:51 1

java - How to create a checked exception and use it in the header of a method? -

for example: int method1() throws new myexception { // here causes myexception's exception. } i know should extend exception first. how trigger exception according method's state ? i want able throw myexception whatever reason choose, similar how filenotfoundexception thrown when file isn't found. minor correction required int method1() throws exception { // based on validation logic throw new myexception(); } update:- want handle file not found exception int method1() throws exception { try { file handling code } catch(filenotfoundexception ex){ throw new myexception();// if want throw checked 1 otherwise below throw new runtimeexception();// unchecked ones } }

How to spawn multiple instances of node.js on one machine to listen for different subdomains? -

this question has answer here: how route multiple domains multiple node applications? 3 answers for subdomain a.abc.com b.abc.com c.abc.com i want run same duplicate of node.js script them. have 1 machine unfortunately. can suggest how may overcome this? if have 3 "handlers", ie function (req, res) signature, can following on single server: http.createserver(function (req, res) { switch (url.parse(req.url).hostname) { case 'a.abc.com': handlera(req, res) break case 'b.abc.com': handlerb(req, res) break case 'c.abc.com': handlerc(req, res) break default: res.statuscode = 404 res.end() break } }) you don't need reverse proxy unless need every handler on own process, ie if have lot of load

php - Copy image from URL to Web Server File System -

trying build form uploading images via url , have copied there server. searching follwoing threads: copy image remote server on http copy file remote server or url how copy remote image website directory? i've tried this: $pic = submitted image url $pic = submitted image name . ".jpg" copy($pic, $_server['document_root'] . '/mydir/' . $picname); results in: warning: copy(mydir/mypic.jpg) [function.copy]: failed open stream: no such file or directory in /home/user/public_html/mysite.ca/upload.php on line 42 this: $fp = fopen($_server['document_root'] . '/mydir/' . $picname, "w"); fwrite($fp, $pic); fclose($fp); results in: warning: fwrite() expects parameter 1 resource, boolean given in /home/user/public_html/mysite.ca/upload.php on line 47 warning: fclose() expects parameter 1 resource, boolean given in /home/user/public_html/mysite.ca/upload.php on line 48 directory permissions 777, no

java - How to access subclass static methods from Class token? -

the concept i'm having trouble how can pass token (such apple.class ) method, , access subclass's static methods can retrieve generic information subclass?(in case generic image of apple) here's java-like psudocode: abstract class food { } class apple extends food { static image getimage(){ return (generic image of apple); } } class onion extends food { static image getimage(){ return (generic image of onion); } } void arraymanager(class<? extends food> foodtoken){ useimage(foodtoken.getimage()); // <-- can't access static methods class token storetype(foodtoken); } //... executing code ... arraymanager(apple.class); arraymanager(onion.class); the executing code needs tell arraymanager() kinds of foods wants stored. arraymanager() method displays simple generic image , stores token later reference. can't find way generic image of specific subclass. if arraymanager() method wanted instantiate passed in token,

c# - How do I find all assemblies containing type/member matching a pattern? -

i have folder (possibly, nested sub-folders) containing thousands of files, of them dlls, , of dlls .net assemblies. need find assemblies containing types/members matching pattern (e.g. "*collection" , or "create*" ). best (fastest) way this? it ok suggest open-source libraries long usage not require open source code. maybe api useful you: http://cciast.codeplex.com/ microsoft research common compiler infrastructure (cci) set of libraries , application programming interface (api) supports of functionality common compilers , related programming tools. cci used applications create, modify or analyze .net portable executable (pe) , debug (pdb) files. or can load assembly.loadfrom(path) , call assembly.getexportedtypes()

html - How do I get a label on the same line as a Datebox input field? -

Image
this embarrasing. im making use of datebox module , i'm trying align label next input examples in provided link. i'm expecting along lines of this: but this: this html: <div name="activities" id="activities"> <label for="activity-1">activity 1</label> <input name="activity-1" id="activity-1" type="date" data-role="datebox" data-options='{"mode": "durationflipbox", "overridedurationorder": ["h","i"], "overridedurationformat": "%dl:%dm"}'/> </div> i've tried setting styles in css #activities { display: inline-block; vertical-align: right; } but i'm not getting expected result given above. what doing wrong? update seems html being inserted when loading page final result looks this: i apologize inserting image instead of code, can't seem copy html

c# - Phone Number Regex -

i need regular expression phone number includes country code, area code , phone number.the phone number format should like: 001-253-3478887 or 90-312-4900203 . try not work. should correct format? how can phone number info? (\(\d{3}-))?\d{3}-\d{4} ^((\d-\d{3})|(\d{1,3}))\-\d{3}-\d{7}$ this regex match country codes. country codes of 1 , 1-684 won't valid in other answers. prevent country codes such 1-42 being allowed, since time there should separator in country code when it's 4 digits long. if end getting 4 digit country codes without separator, use following instead: ^((\d{4})|(\d{1,3}))\-\d{3}-\d{7}$

python - models.DateTimeField(auto_now_add = True) -

i have problem models.datetimefield, because i´m méxico , in settings.py use this: time_zone = 'america/mexico_city' but when add register in mysql database, says register added @ 18:00 (4 hours later, because here, in mexico city 14:00) titulo = models.charfield(max_length = 60) contenido = models.charfield(max_length = 140) fecha = models.datetimefield(auto_now_add = true) if enable use_tz = true, django uses utc times in database. why seeing time 4 hours ahead -- utc time. https://docs.djangoproject.com/en/dev/topics/i18n/timezones/ django has helpers take utc , convert when display in view. try getting object db uses datetimefield , try in view {{ value }} datetime: {% load tz %} {% localtime on %} {{ value }} {% endlocaltime %} {% localtime off %} {{ value }} {% endlocaltime %} you might have install pytz requirement if haven't done already: pip install pytz

Macro want to use symbol instead of string in clojure -

so trying make haskell lambda syntax, , macro i've got: (defmacro / [& all] (let [args (take-while #(not (= %1 "=>")) all) argcount (count args) expr (last (split-at (+ argcount 1) all))] `(fn ~(vec args) (~@expr)))) (reduce (/ x y "=>" + x y) [1 2 3]) this works enough, last thing i'd make don't need "=>" can use => any tips how might make => valid symbol can parse in context i'm referring? compare name of symbol against string: (defmacro / [& all] (let [args (take-while #(not (= (name %1) "=>")) all) argcount (count args) expr (last (split-at (+ argcount 1) all))] `(fn ~(vec args) (~@expr))))

javascript - Click on an object, get another object? -

on click objects id. the id 'about-me'. now in on click function want target object that's called 'content-about-me'. how can this? ive tried no luck: $('.sub-nav').on('click', function(){ $('#content-'$(this).attr('id')); }); you have concatenate id prefix content- : $('#content-' + this.id); i replaced $(this).attr('id') equivalent shorter this.id . keep in mind instead of doing this, might idea have full id of "other" element stored somewhere on click target. example: <div class="sub-nav" id="foo" data-other-element="content-foo">...</div> and do $('.sub-nav').on('click', function(){ var $other = $("#" + $(this).attr('data-other-element-')); }); this code dry , if decide change id tagging scheme js code not need change well.

javascript - Changing div content on page load -

i'm looking solution, in div content changes on page load, randomly. javascript image on page load. have made further notes in code below. i randomize content images javascript on page load, here it's divs , i'm not sure how change content inside them. <div class="row bslots"> <div class="grid_4 fl"> /* code change */ /* example once <div class="hello"><p>hi</p></div> , other <iframe="link"/> */ </div> <div class="grid_4 fr"> <script>widget2(); /* don't mind this, loading actual js image randomizer here */</script> </div> </div> can achieved without using js? if not, i'd appreciate basic example fiddle :) yes achieved without javascript. depends on serverside-technology use. create template , insert serverside ransom image-tags. possible too, via javascript. if want use jquery, lik

How to reset Codemirror editor? -

i reset contents of codemirror editor. ideally, should clear textarea, remove marks , clear history. what's best way achieve this? cm.setvalue(""); cm.clearhistory(); // cm.cleargutter("gutterid"); if have gutters

django - How to import dajaxice? -

i'm nooby django , tried many hours simple example of dajaxice running, don't seem find right way files. i did , redid installation , tried find answers in numerous similar questions on stackoverflow this one , this one . i put {% dajaxice_js_import %} in header of myapp_index.html prints out as: <script src="/static/dajaxice/dajaxice.core.js" type="text/javascript" charset="utf-8"></script> but cannot find file: improperlyconfigured: storage backend of staticfiles finder doesn't have valid location. and fails: get /static/dajaxice/dajaxice.core.js http/1.1" 500 59 strangely enough dajax loads: <script type="text/javascript" src="{% static /static/dajax/jquery.dajax.core.js" %}"></script> here's folder structure: myproject ----manage.py ----myproject --------settings.py --------urls.py ----myapp --------ajax.py --------urls.py

How to specify the file path in which to download using python -

urllib.request.urlretrieve ("http://bogoroditsa.tk/grant's%20libraries/", "extrafunctionality.py") how specify, using command above, file path in download file? currently, code above downloads file in same path program being run in. specify download path, how do so? instead of "extrafunctionality.py" can provide full path: urllib.request.urlretrieve ("http://bogoroditsa.tk/grant's%20libraries/", "/home/foo/extrafunctionality.py")

spring security with velocity? -

i have application pages not in jsp velocity, , isn't running spring either... want integrate spring security it, couldn't find documentation... searcher in springsource documentation documentation , couldn't find do.is possible start with? if so, how can it? i tried prepare spring-security-context.xml <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.or