Posts

Showing posts from March, 2011

c# - Debugging issue (VS2010) when using dynamic keyword -

while debugging compiler (mostly) written in c#, noticed following issue, tried map simplified code fragment: public class program { public abstract class base { public abstract void foo(); } public class : base { public override void foo() { console.writeline("a"); } } public class b : base { public override void foo() { console.writeline("b"); } } public static void printout(base obj) { printoutimpl((dynamic)obj); } public static void printoutimpl(a aobj) { aobj.foo(); } public static void printoutimpl(b bobj) { bobj.foo(); } public static int main(string[] args) { b bobj = new b(); printout(bobj); return 0; } } basically, there 2 implementations of printout(..). dynamic keyword used determine corresponding implementation @ runtime. when i&

export - how save image with better or specificresolution in gui matlab? -

i trying save image command getframe resolution low, can not give zoom. for i'm using code: [arq,dir] = uiputfile('*.jpg','output files'); filename=fullfile(dir,arq); f=getframe(handles.axes1); [x,map]=frame2im(f); imwrite(x,filename,'jpg'); i need save in jpg , need save label (x,y) in graph. how can this? there command better getframe?

ruby - Net::ftp getbinaryfile() saving to file vs saving to variable -

using following ftp_download method works, if change ftp.getbinaryfile(file,localdir,1024) #=> saves file localdir to ftp.getbinaryfile(file) #=> returns nil i nil returned. according to http://www.ruby-doc.org/stdlib-2.0/libdoc/net/ftp/rdoc/net/ftp.html#method-i-getbinaryfile inilf set localfile nil above, data should retrieved , returned method. doing wrong? def ftp_download(domain,remotedir,filename_regex,user=nil,pwd=nil) ftp = net::ftp::new(domain) if user && pwd ftp.login(user, pwd) end ftp.chdir(remotedir) filelist = ftp.nlst(filename_regex) filelist.each |file| localdir=file.join(remotedir,file) localdir=localdir[1..-1] if localdir[0]="/" fileutils.mkdir_p(file.dirname(localdir)) ftp.getbinaryfile(file,localdir,1024) end ftp.close end if @ getbinaryfile method signature notice default value second parameter ( localfile ) not nil file.basename(remotefile) getbinaryfile(remotefi

jquery - Separate output of multiple JavaScript objects -

i'm trying separate couple of objects filtering keys. example may want output data of "yar" , "foo" objects in first table , rest in second table. this results in one complete table: console.log(data); var firsttable = 'yar foo'.split(' '); for(var = 0; < data.length; i++) { for(var key in data[i]) { html = '<tr data-item="' + key + '"></tr>'; } $('table#one tbody').append(html); } the result i'm after: <table> <tbody> <tr data-item="yar"></tr> <tr data-item="foo"></tr> </tbody> </table> <table> <tbody> <tr data-item="bar"></tr> <tr data-item="rawr"></tr> </tbody> </table> console.log(data) returns: 0: object foo: object lorem: array[2] 0: "1" 1: "2" 1: object

ruby on rails - Redis and sidekiq ECONNREFUSED -

i deploy rails app , redis server (on port 13160 on same server. after try launch app returns me: redis::cannotconnecterror (error connecting redis on 127.0.0.1:13160 (econnrefused)): the function stops in code is updatesworker.perform_async the thing when write rails_env=production rails runner updatesworker.perform_async rails app works.

ajax - Get a distant text file with Javascript without Jquery -

this question has answer here: origin not allowed access-control-allow-origin 21 answers i'm looking content of text file in javascript parse after. know how jquery, used call ajax function jsonp, but, time without framework. i did code lot of try nothing succeed. here last version : var url = 'https://url.com/videoslist.txt'; var xhr = new xmlhttprequest(); xhr.onreadystatechange = process; xhr.open("get", url, true); xhr.send(); function process() { if (xhr.readystate == 4) { console.log(xhr.responsetext); } } the code seems ok browser (chromium) returns me : > xmlhttprequest cannot load > https://url.com/videoslist.txt. origin > http://localhost:8888 not allowed access-control-allow-origin. cross-site scripting not allowed under default security settings.. code work if requested url on same domain page cam

websphere - EAR cannot find EJBs in other EAR (WAS shared lib issue) -

i've got ejb set in entity-layer-ear: <session> <ejb-name>doctordaoimpl</ejb-name> <business-local>mypath.doctordao</business-local> <ejb-class>mypath.doctordaoimpl</ejb-class> <session-type>stateless</session-type> </session> according logs, ear , ejbs start fine. have facade (e.g. doctordao) in shared libs, , entity layer ear has implementations (eg. doctordaoimpl). now when deploy doctor service, has data-service.jar who's doctordataejb injects doctordao. but error saying: the mypath.doctordao ejb reference in doctordataejb component in data-service.jar module of doctor application not resolved. nested exception is: com.ibm.ejs.container.ejbnotfoundexception: ejb interface mypath.doctordao not present in application doctor now, realise indeed, ejb not present in doctor application. present in entity-layer-ear. i've seen link similar, imagine must wor

Working around Duplicate association path bug in Nhibernate with Query Over -

i've got bit of code tries access same association path twice , they're same aliases because i'm using query objects, have them in 2 different places , not sure how alias. may code can clear confusion: var privateblogquery = new blogquery() .byuser(1) .removehidden() .fetchuserdetails(); //<-------- in blog query object class: ------> /// gets private blogs user has permissions view public blogquery byuser(int userid) { var authorisedusers = null; this.left.joinqueryover(r => r.authorisedusers, () => authorisedusers) .where(r => r.user.id == userid); return this; } /// removes private blogs user has marked hidden public blogquery removehidden() { var authorisedusers = null; this.left.joinqueryover(r => r.authorisedusers, () => authorisedusers) .where(r => !r.ishidden); return this; } /// loads details of users have permission /// view private blog public blogquery fetchuserdetails(

Highcharts Dynamic Chart (Updating over certain interval) PHP+MySql Example -

Image
i'm trying use this demo make work php & mysql after interval updated values database. when use // using random value using javascript setinterval(function() { var x = (new date()).gettime(), // current time var y = math.random(); series.addpoint([x, y], true, true); }, 5000); i get but when try putting ajax function like var t; setinterval(function() { var x = (new date()).gettime(), // current time $.ajax({ type:'post', url:'blahblah.php', success:function(data) { t = data; // data random numeric value } }); series.addpoint([x, t], true, true); }, 5000); the chart turns blahblah.php echo rand(10, 99); i'm not able determine why line disappears on every ajax call. plotting of points not correct. returned values greater 10, can see in second chart, plotting range -2 8 i don't seem find appropriate mysql example wo

eclipse - Issues using Search and replace in Aptana. Any options? -

Image
i having hard time getting use search function in aptana(eclipse). i try search "workspace", consider open files, not whole project. when this, starts search through 2,900 files have in whole project. maybe it's me. maybe doing wrong. maybe there's setting can change make workspace choice work actual workspace or maybe it's bug. use search feature most, , it's frustrating me. are there plugins, or options can make better, or replace functions normally? if there's no way change it, think whole search selection box needs overhaul. ability set working set, other that, , searching whole project , search seems project. i think should have functionality this; project (all files in project, ie: full cms have) working set (i have of these - works awesome plugins) workspace (files in actual workspace, not searching whole project) file(s) (called selected resources now.seems ok individual file) the current search set individual or open files seem

Devexpress Tiles' content display issue -

i have user control: <usercontrol.resources> <resourcedictionary> <resourcedictionary.mergeddictionaries> <resourcedictionary source="/userinterface;component/skins/mainskin.xaml" /> </resourcedictionary.mergeddictionaries> <converters:widgetwidthconverter x:key="widgetwidthconverter" /> <converters:tilesizeconverter x:key="tilesizeconverter" /> <converters:listcounttovisibilityconverter x:key="listcounttovisibilityconverter" /> <views:subplantmainstaticcontrol x:key="subplantmainstaticcontrol" /> <views:subplantmainactualcontrol x:key="subplantmainactualcontrol" /> </resourcedictionary> </usercontrol.resources> <dxlc:tilelayoutcontrol background="{x:null}" x:name="tilecontrol" margin="10"

java.security.AccessControlException: access denied ("java.awt.AWTPermission" "accessClipboard") -

when load applet exception java.security.accesscontrolexception: access denied ("java.awt.awtpermission" "accessclipboard") . have googled couple of hours , have seen answers like, adding permissions in java policy - strictly internal process. need work in machines. adding applet tag instead of object - didn't work me. keytool used sign applets - have added custom certificate sign applets. still getting exception. please out guys. you can try using javascript within java privileged methods: http://blog.pengoworks.com/index.cfm/2008/2/19/accessing-privileged-methods-in-a-java-applet-via-javascript

python: how to call a constructor in a module in a package in another package directly -

this question has answer here: a python module , package loading confusion 1 answer i porting matlab code python. need work packages , modules in case. relevant package directory structure looks this: toppackage __init__.py subpackage __init__.py module.py ... in script use package, can work this: from toppackage.subpackage.module import someclass s = someclass() but prefer working this: import toppackage %somewhere @ beginning of file s = toppackage.subpackage.module.someclass() i see done in numpy. not find in documentation. how can that? thanks in advance. you need import contained packages in __init__.py files. you can import packages inside toppackage/__init__.py example: import toppackage.subpackage.module or can import each directly contained package, in toppackage/__init__.py : from . import sub

c# - SelectNodes with Filter -

here xml: <instrument recordcount="3" > <department id = 18384, sequence=1> <instrumentdata statuscode="1" roletype="ed" style="x" dataother='data'> </department> <department id = 18465, sequence=2> <instrumentdata statuscode="2" roletype="cd" style="s" dataother='data'> </department> <department id = 16473, sequence=3> <instrumentdata statuscode="1" roletype="cd" style="t" dataother='data'> </department> </instrument> i want @status attribute ='1' or '2' , not @roletype='e' , 'f' , @style ='s' , 't' each node. i have following statement, not bring correct results. xmlnodelist nodelist = root.selectnodes(@"//department[instrumentdata/@status='1' or department[instrumentdata/@status='1

jquery does not link to html -

i new html , jquery,however have written html file , have added jquery reference in eclipse. both files (html , js) @ same location in eclipse. when run html, expect see jquery functions in output not show up, html output seen. why happening? there other way can see animation have put in through jquery or linking issue? below html , js files. test.html: <!doctype html> <html> <head> <title>behold!</title> <link rel='stylesheet' type='text/css' href='http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css'/> <script type='text/javascript' src='script.js'></script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script> </head> <body> <div id="menu"> <h3>jquery</h3> <div> <p>jquery javascript lib

couchdb - Ruby on rails & Couchrest model: use existing views -

i'm having issues couchdb , couchrest model. i have running system existing views in couchdb (they working fine). want use them in ruby on rails project couch rest model. want define them with: design view :by_name end everytime run code designdocument overwritten default views couchrest model. does know how "use" them, without changing in designdocument of database? thanks lot! according couchrest model docs: http://www.couchrest.info/model/view_objects.html it has configuration option: auto_update_design_doc, set true default. when view requested quick design document sent ensure date latest version defined in model. setting option false can use existing views. need deal view updating yourself.

how to pop git stash without triggering an auto-merge -

the short version of question this: how can pop git stash without triggering auto-merge? now longer version... consider following toy example of alternative git stash ... + git pull ... + git pop . first, git status shows modification in working directory tracked file foo . # on branch master # changes not staged commit: # (use "git add <file>..." update committed) # (use "git checkout -- <file>..." discard changes in working directory) # # modified: foo # no changes added commit (use "git add" and/or "git commit -a") now, in order reset working directory clean state, pre-requisite running git pull , temporarily rename modified file foo (to untracked name), , restore version of foo in head ... % mv foo foo.$(date +%y%m%dt%h%m%s) % git checkout foo % git status # on branch master # untracked files: # (use "git add <file>..." include in committed) # # foo.20130508t110014 nothing added co

Binary representation of float in Python (bits not hex) -

how string binary ieee 754 representation of 32 bit float? example 1.00 -> '00111111100000000000000000000000' you can struct package: import struct def binary(num): return ''.join(bin(ord(c)).replace('0b', '').rjust(8, '0') c in struct.pack('!f', num)) that packs network byte-ordered float, , converts each of resulting bytes 8-bit binary representation , concatenates them out: >>> binary(1) '00111111100000000000000000000000' edit : there request expand explanation. i'll expand using intermediate variables comment each step. def binary(num): # struct can provide float packed bytes. '!' ensures # it's in network byte order (big-endian) , 'f' says should # packed float. alternatively, double-precision, use 'd'. packed = struct.pack('!f', num) print 'packed: %s' % repr(packed) # each character in returned string, we'

javascript - Updating Chosen Dynamically -

i'm using chosen plugin , got 10 000 options in dropdown. after user selects option want reset chosen it's default option. when liszt-update gets triggered takes 5 seconds dropdown render (as contains many options). there way around it? my code: $('#chosen_orgs').val('0').trigger('liszt:updated'); thanks. you manually update original select instead. $('#chosen_orgs, #original_select_id').val('0'); also, fyi, select2 more well-developed fork of chosen, , syntax conversion simple.

ant - JUnit jar in Jenkins build not seen -

i have build exported svn failing on 'test' target in build.xml. looks jenkins cannot see junit.jar getting following error: "java.lang.noclassdeffounderror: junit/framework/testlistener" i installed xunit plug-in , didn't seem work. have junit4 installed on unix host path being set in ant build.xml file (this exact build works in different build enviroment not in jenkins). there place need set junit path in jenkins, such under "inject enviroment variables build"? turns out using 1.9.0 causing issue, set ant build 1.7.0 , completed

jsf - How do I exclude servlet-filters from having to be serialized? -

i converted beans viewscoped instead of requestscoped . however, since had add serialized beans, getting 2 java.io.notserializableexception exceptions. this web.xml : <filter> <filter-name>primefaces fileupload filter</filter-name> <filter-class>org.primefaces.webapp.filter.fileuploadfilter</filter-class> </filter> <filter> <filter-name>loginfilter</filter-name> <filter-class>com.company.rews.webclient.controller.loginfilter</filter-class> </filter> <servlet> <servlet-name>faces servlet</servlet-name> <servlet-class>com.company.rews.webclient.controller.myfacesservletwrapper</servlet-class> <load-on-startup>1</load-on-startup> </servlet> the first place reports exception somewhere inside super.service(req, res) : public class myfacesservletwrapper extends myfacesservlet { @override public void service(servletrequest request, servletre

javascript - Jquery UI Draggable Containment -

i have image can drag around container using jquery ui. i using draggable("option", "containment", [x1, y1, x2, y2]) set draggable containment works perfectly. i have written zoom slider zooms image, recalculates containment works well. however when zoom out image, may sit outside of newly calculated containment area, position doesn't updated until start drag again on element, snaps within containment area , can continue drag it. i want element's position update zoom in out if falls outside of containment area. looking simulating drag event after zooming couldn't work properly. is there way of refreshing position of element using jquery ui draggable plugin? thanks

javascript - Pass Options from CollectionView to Recursive CompositeView -

i'm doing extremely similar tree structure described in article: http://lostechies.com/derickbailey/2012/04/05/composite-views-tree-structures-tables-and-more/ the idea have collection of root nodes in collection view (treeroot) each root node has recursive composite view (treeview). jsfiddle showing simplest working example tree structure aricle can found here: http://jsfiddle.net/hoffmanc/nh9j6/ i want modify example options can passed each tree view, regardless of in tree structure. here (only modified) jsfiddle: http://jsfiddle.net/ql4ae/1/ the js code in modified example is: // recursive tree view var treeview = backbone.marionette.compositeview.extend({ template: "#node-template", tagname: "li", initialize: function(){ // grab child collection parent model // can render collection children // of parent node this.collection = this.model.nodes; console.log(this.options.msg); // undefined

jquery - Flexslider not working with carabiner - codeigniter library -

there problem flexslider , codeigniter's carabiner library. combining js , css on website flexslider not being combined. if included seperately works fine. error having $(...).flexslider not function here doing carabiner not working. $js = array( array('http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js', '', true, false), array('js/jquery.flexslider-min.js', '', true, false) ); $this->carabiner->js($js); if include flexslider script <script type="text/javascript" src="/assets/js/jquery.flexslider-min.js"></script> that works fine. guess may due type="text/javascript" mentioned here is there way can combine flexslider js other js files in carabiner ? hi need set base uri in config check in carabiner.php config file find //$config['base_uri'] = 'http://www.example.com/'; just remove comment , put site address. 2nd way can se

jvm - What tool should I use to decompile Java byte code to Java source code? -

if had decompile java byte code java source code, tool use? http://www.varaneckas.com/jad/ the tool called jad instructions here: https://www.owasp.org/index.php/decompiling_java_bytecode

c++ - Generating all permutations with repetition -

how generate possible permutations of n (given) distinct items taken r @ time item can repeated number of times? combinatorics tell me there n^r of them, wondering how generate them c++/python? treat permutation r -digit number in n -based numerical system. start 000...0 , increase 'number' one: 0000, 0001, 0002, 000(r-1), 0010, 0011, ... the code quite simple.

Unknown Error Connecting To SQL Server in c# -

let me add quick explanation post: i using visual studio , if create connection database works. can query database through database designer (the 1 see tables , can create new queries) , data processes correctly. however using route getting same sql exception. me says in visual studio not set correctly wrong. i using following code connect database on server (with using system.data.sqlclient; @ top): sqlconnection thisconnection = new sqlconnection(); thisconnection.connectionstring = "data source=192.168.0.0,1433;" + "initial catalog=test-db;" + "user id=username;" + "password=password;"; thisconnection.open(); and getting following error: at system.data.sqlclient.sqlconnection.onerror(sqlexception exception, tdsparserstate state) @ system.data.sqlclient.sqlinternalconnection.onerror(sqlexception exception, td

bytearray - Reading bytes from large files in Java cause Java heap space error -

awhile ago seeking on code below , started working on again. basically, i've narrowed error down size of file causing error: exception in thread "main" java.lang.outofmemoryerror: java heap space the line right below error in stack trace is: at java.util.arrays.copyof(arrays.java:2786) i can pass program large directory thousands of smaller files, file on 50 mb size tends crash. haven't traced exact size program crashes on know @ least 50 mb file causes issues. below primary snippets , stack trace tells my code breaking. private void handlefile(file source) { fileinputstream fis = null; try { if(source.isfile()) { fis = new fileinputstream(source); handlefile(source.getabsolutepath(), fis); } else if(source.isdirectory()) { for(file file:source.listfiles()) { if(file.isfile()) { fis = new fileinputstream(

Data is not displaying on php page from phpmyadmin -

helo evry1 want display data phpmyadmin table php page problem tht not displaying here code <?php include('config.php'); $res = mysql_query("select * accord"); while($row = mysql_fetch_assoc($res)) { $id=$row['id']; $rupes=$row['rs']; $mob=$row['mobilen']; $carmodel=$row['modelcar']; } ?> pkr:<?php echo $rupes;?> here code plz there might 2 problems 1) have issue config.php 2) query has issue try putting die this mysql_query("select * accord") or die(mysql_error());

google api - How to correctly setup Oauth 2 Authentication in YouTube V3 API -

i have console app pulls video view counts data using youtube v3 api. using oauth 2 authentication , having issues. i executed application on 2 different servers @ different times. one machines authenticates , returns following message logs: 2013-05-08 09:51:45,691 [8] info dotnetopenauth.messaging.channel - prepared outgoing accesstokenrefreshrequest (2.0) message https://accounts.google.com/o/oauth2/token: refresh_token: 1/m4pjx978kbegkqtf6tvsjdfczej1na6nbtakhhhqkjs grant_type: refresh_token client_id: 1085346326111.apps.googleusercontent.com client_secret: hhh5wfqtrdxml54rnzaughna the other doesn’t authenticate , assuming waiting permission submit youtube data api requests on user's behalf: 2013-05-08 09:44:59,442 [31] info dotnetopenauth.messaging.channel - prepared outgoing enduserauthorizationrequest (2.0) message https://accounts.google.com/o/oauth2/auth : response_type: code client_id: 1085346326111.apps.googleusercontent.com redirect_uri:serve

cross browser - CSS3 media queries not working on Safari on iPod/iPhone -

i developing responsive design website. website optimized iphone , ipod (both having width 640px). i using following css3 media queries: @media screen , (max-width: 640px) { .display-none-mobile{ display: none; } } @media screen , (min-width: 641px) { .display-none-desktop{ display: none; } } above code works great on desktop browsers when shrink browser width 640px. code not work when try test website on ipod using safari browser. i changed css3 media queries @media screen , (max-device-width: 640px) { .display-none-mobile{ display: none; } } @media screen , (min-device-width: 641px) { .display-none-desktop{ display: none; } } now, responsive design worked safari on ipod messed layouts on other desktop browsers. css3 media queries totally ignored ochrome, ie, ff on desktop (for width 640px). so have figured out there related

CSS background-position calculated from left? I want it RIGHT -

i need allocate background image div, thing needs positioned right , not usual left in css. when defining background-position , can read, , right, or big percentage (which calculated left side of screen anyway works) and.. that's it. cannot use pixels , go fix distance right side of container. right here? so, there work-around this? less if helps? theoretically, can have set right , somehow decrease couple of pixels then. we have margin-right:+-px, padding-right:+px, not background-position-right:+-px ? background-position: right 20px; https://developer.mozilla.org/en-us/docs/css/background-position jsbin example: http://jsbin.com/ixejey/1/ update: oops, may have misunderstood question. above positions background image right side , 20px top--but not set distance away right side. don't think can @ time css alone. for instead of using background image on element directly, wrap element inside wrapper div, add second div hold "background" image ,

html - Add css rule specific to component with multiple classes -

i have following html code: <li id=treemenu:2 class="ui-treenode ui-treenode-leaf ui-treenode-unselected" role=treeitem sizset="false" data-nodetype="default" data-rowkey="2" sizcache0014053099738481567="771 85 282"> <span aria-expanded=false aria-checked=false class="ui-treenode-content ui-tree-selectable" aria-selected=false sizset="false" sizcache0014053099738481567="771 85 282"> <span class=ui-treenode-leaf-icon></span> <div class="ui-chkbox ui-widget" sizset="false" sizcache0014053099738481567="771 85 282"> <div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default"> <span class="ui-chkbox-icon ui-c"></span> </div> </div> <span></span> <span class="ui-treenode-label ui-corner-al

AngularJS: Why do custom directives default to being attribute-only? -

egghead.io has great explanation of directive restrictions in angularjs. custom directive can defined follows: angular.module("app", []).directive("blah", function () { return { restrict: "a", template: "blah directive. nothing see here." }; }); this creates call attribute directive (due restrict: "a" ) purposes of asking question. angular's default restriction on custom directive , , directive can used like: <div blah> <!-- content of directive --> </div> when want create custom directive, however, go element directive , like: <blah> <!-- content of directive --> </blah> how former attribute directive better latter element directive , why chosen default? this opinion, only: there 3 possible ways define directive in html - attributes, elements , classes. classes lax , confusing, , best practice separate logic style. element directives stri

jsp - Set parameter of font color from javascript -

i need show text <reg id:> in red color if reg id null or empty. current implementation on alert, color not changed. <html> <head> <script type="text/javascript"> function validateform() { var stu_regid = document.forms["detail"]["regid"].value; if ((null == stu_regid) || (stu_regid == "")) { alert("reg should not left blank"); // here change color red document.getelementsbyname("font_regid").innerhtml = "red"; return false; } } </script> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>insert title here</title> </head> <body> <%!string font_regid = new string();%> <form name="detail" action="reportgenerator" method="get" onsubmit="return validateform()&

sqlite - Implementing database from UML -

i modeled uml diagram involves associations. let's code is: public class seller{ private int idseller; private string name; private string passw; private list<phone> phones = new arraylist<phone>(); public seller() { } public seller(int idseller, string name, string passw, list<phone>phones) { super(); this.idseller = idseller; this.name = name; this.passw = passw; this.phones = phones; } //getters , setters } and public class phone { private int idphone; private string description; private string number; //will have chars in public phone() { } public phone(int idphone, string description, string number) { super(); this.idphone = idphone; this.description = description; this.number = number; } //getters , setters } i don't want limit numbers of phones sellers can have, excerption of whole code.