Posts

Showing posts from May, 2010

verilog - how can I reduce mux size -

module memory_module (input clk,input[0:6] address,input [0:7]data_input, input read_write,output [0:7] data_output,input enable,output ready); reg ready; reg [0:7] data_output; reg [0:7] memory [127:0]; initial begin ready=0; end @(posedge clk) begin if(enable) begin ready=0; if(read_write) begin data_output[0:3]= memory[address][0:3]; data_output[4:7]= memory[address][4:7]; end else begin memory[address][4:7]=data_input[4:7]; memory[address][0:3]=data_input[0:3]; end ready=1; end else ready=0; end endmodule here simple verilog code memory module design (i want make code more efficient) also when write data_output[0:7]= memory[address][0:7]; creates 8x1 mux by writing

jquery - What's the best way to sort function inputs based on type in Javascript? -

i've got function several inputs, optional in calling function. each input of different type, such string, array, or number. code this: function dostuff(str, arr, num){ if typeof(str) != 'undefined' { $('#stringdiv').text(str)} if typeof(arr) != 'undefined' { for(var i=0; < arr.length; i++){ $('<li>').text(arr[i]).appendto('#arrayul') } } if typeof(num) != 'undefined' { $('#numberdiv').text(num)} } jquery(document).ready(function() { dostuff("i'm string", [1,2,3,4,5], 7) }) i can account fact arguments might optional, not fact that, if missing arr , numeric argument ( num ) come second, not third. to around this, can dump inputs array, , sort through array , of each type, in this fiddle. seems sloppy, and, based on number of libraries i've seen in functions, seems there's better way. there better way this? or looping through arguments

android - how to put data in two different table using two different activity -

here in application in first activity using following code storing data mysql. java code: public class mainactivity extends activity { edittext et; button b; inputstream is; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); et = (edittext) findviewbyid(r.id.edittext1); b = (button) findviewbyid(r.id.button1); b.setonclicklistener(new view.onclicklistener() { @override public void onclick(view arg0) { // todo auto-generated method stub string name = et.gettext().tostring(); arraylist<namevaluepair> params = new arraylist<namevaluepair>(); params.add(new basicnamevaluepair("name", name)); try { httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://10.0.2.2/insert1.php"); httppost

suppress one of the options from help when using optparse in python -

consider following: parser.add_option("-f", "--file", "--secret", action = "append", type = "string", dest = "filename", default = [], = "specify files") i hide --secret option user when invoked. can in following way? parser.add_option("-f", "--file", action = "append", type = "string", dest = "filename", default = [], = "specify files") parser.add_option("--secret", action = "append", type = "string", dest = "filename", default = [], = "specify files") am missing hidden issue doing so?if so, can suggest alternative way achieve this. try help=suppress_help trick (see docs ): from optparse import optionparser, suppress_help parser.add_option("-f", "--file", action = "append", type = "string", dest = "filename", default = [], = "spe

emacs - Gnus: How to archive emails according to the account they were written from? [gcc-self not working as expected] -

i have 2 mail accounts, foo.bar@uni.edu , foo.bar@gmail.com . archive messages send either 1 in corresponding "sent mail" folder ( nnimap+foo.bar@uni.edu:sent items , foo.bar@gmail.com:[google mail]/sent mail ). i tried set (setq gnus-message-archive-group '(("uni" "nnimap+foo.bar@uni.edu:sent items") ("gmail" "nnimap+foo.bar@gmail.com:[google mail]/sent mail") )) but not set gcc (new messages don't have gcc; solution here?). went (setq gnus-message-archive-group "nnimap+foo.bar@uni.edu:sent items") sets gcc correctly (for main account foo.bar@uni.edu ) if open new message in *group* via m . i tried use gcc-self via gnus-parameters archive sent mails correctly: (setq gnus-parameters `((,(rx "nnimap+foo.bar@uni.edu") (gcc-self . "nnimap+foo.bar@uni.edu:sent items")) (,(rx "nnimap+foo.bar@gmail.com") (gcc-self . "foo.bar@gma

c# - DevExpress XtraGrid is not visible even after I set Visible = true -

i'm using devexpress' tools on current winforms project. page i'm working on has grid sub-agencies visible or not depending on flag called isparentagency . if agency parent agency, grid should visible of agency's sub-agencies. if not, grid should invisible. no matter do, though, can't seem grid visible. after i've given data source, forced initialize, , populated columns. i've tried going right ahead , setting subagenciesgridcontrol.visible = true . no matter has visible set false (even when debugging line after subagenciesgridcontrol.visible = true ). here's code i'm using set grid , toggle visibility (i'm using mvp pattern on top of winforms): subagenciesgridcontrol.datasource = model.subagencies; subagenciesgridcontrol.forceinitialize(); subagenciesgridview.populatecolumns(); subagenciesgridcontrol.visible = model.isparentagency; how can grid visible? adding controls, shown in comments. if you're using layoutcontrol t

generics - How to interpret "public <T> T readObjectData(... Class<T> type)" in Java? -

i have java code. public <t> t readobjectdata(bytebuffer buffer, class<t> type) { ... t retval = (t) summaries; return retval; how interpret code? why need public <t> t instead of public t ? how give parameter 2nd argument ( class<t> type )? this declares readobjectdata method generic, 1 type parameter, t . public <t> ... then return type t . ... t readobjectdata(... without initial <t> , generic type declaration, symbol t undefined. in parameter list, class<t> type 1 of parameters. because return type , parameter both reference t , ensures if pass in class<string> , return string . if pass in class<double> , return double . to pass in parameter, pass in class object, e.g. string.class .

c - Compiling ANTLR 3C for AIX -

i'm not familiar compiling c, if don't give enough information, let me know need me post! here's summary: need run antlr in target language of c on old ibm aix computer. gave on compiling ibm cc/make utils , got version of gcc (4.2) , gnu make on machine. issue is, while configure script detect correct architecture, not seem respond appropriately. the specific version of antlr using version 3.2, c target. actual detected target powerpc-ibm-aix-5.3.0.0 here's i've done. first glaring error see added "-m32" flag options. okay, can remove makefile simple enough, in case gcc should default -maix32. second issue: error giving me path stdio.h , saying "error: duplicate 'unsigned'". okay, configure made "define" statement in auto-generated antlr3config.h file... can comment out, , error goes away. third issue... i'm stuck. /opt/freeware/bin/make all-am make[1]: entering directory `/scrubber/libantlr3c-3.2' if /

asp.net mvc - How to use a global variable in MVC -

i want create single instance of class should available controllers. it's bit shopping cart in system 1 user. have been using session state times out after while , that's problem. i'd consider using application state , wiring in global.asax. how things done in mvc or there approach fits better framework? use singleton. have class class method return if detects has allocated. other allocate , return itself. go here info on how. http://www.johnwordsworth.com/2010/04/iphone-code-snippet-the-singleton-pattern/

scala - Compiler error when specifying main class in Akka microkernel? -

here's project definition in build.scala . when go run sbt run or sbt dist same compiler error of not found: value distmainclass . it's quite annoying since checked akka-microkernel-plugin project find distmainclass right there in release 2.0. i'm using 2.0.5, , exists in 2.1.0, too. lazy val servicekernel = project( id = "tracker-kernel", base = file("."), settings = defaultsettings ++ akkakernelplugin.distsettings ++ seq( librarydependencies ++= dependencies.servicekernel, distjvmoptions in dist := "-xms512m -xmx2g -xx:+useconcmarksweepgc -xx:+cmsclassunloadingenabled -xx:parallelgcthreads=2", outputdirectory in dist := file("target/s.tracker-dist"), distmainclass in dist := "namespace.servicekernel" //says not found ) ) any ideas source of issue? thanks! as found out issue you've forgot import missing setting like: import akka.sbt.akkakernelplugin.distmai

ruby on rails - Rolify abilities returning false -

i'm experiencing strange issue using rolify (click tutorial i'm following) rails: can method not seem work, therefore rendering user privileges unuseable. below ability.rb file , console output problem demonstrated. class ability include cancan::ability def initialize(user) user ||= user.new # guest user (not logged in) if user.has_role? :admin can :manage, :all else can :read, :all end end end console tests ( $ rails console ) user = user.find(2) user.add_role "admin" user.has_role? :admin => **true** ability = ability.new(user) ability.can? :manage, :all => **false** ability.can? :read, :all => **false** i checked in database , relationships set correctly. i'm running rails 3.2.13. the problem gem conflict either canard or declarative_authorization . disabling both , restarting rails server solved issue. perhaps others have gone down same path in trying these different gems.

Google Spreadsheet importXML function -

<xml> <category date="5/21/2012"> <item>14</item> </category> </xml> in cell a1 have following function: =importxml("http://www.site.com/file.xml", "//@date") and loads attribute values of name "date". now in b1 want load "item" has date in a1. know following wrong idea of trying go: =importxml("http://www.site.com/file.xml", "//@date["&a&row()&"]/item") thank in advance. solution: =importxml("http://www.site.com/file.xml", "//category[@date='"&indirect("a"&row())&"']/item")

php - How to reach a joined field with Symfony 2? -

i have joined query: $query = $this ->getem() ->getrepository("movementheader") ->createquerybuilder('d') ->leftjoin('movementdetail', 'stockmovementdetail', 'with', 'stockmovementdetail.movementid = d.id') now how reach "movementdetail" ? since question vague i'm going answer generally. if want more specific information, please provide more specific information. assuming movement header has field linked movementdetail entity (let's call movementdetail). following : $query = $this ->getem() ->getrepository("movementheader") ->createquerybuilder('mh') ->select('mh','md') ->innerjoin('mh.movementdetail','md') ->where(/* in cause, can select ever want mh or md*/) ->setparameters(array(/* ... */)) here examples of can use : ->where('mh

c++ - Ignoring a line beginning with a '#' in command prompt -

i writing code requires me ignore comment lines (i.e, lines beginning # sign) till end of line. i'm using linux code in c++. e.g: in case of adding 2 numbers. xxx@ubuntu:~ $ ./add enter 2 numbers added 1 #this first number 2 #this second number result: 3 so comment line can anywhere. has ignore entire line , take next value input. #include <iostream> using namespace std; int main() { int a,b; cout<< "enter 2 numbers added:\n"; while(cin >>a >>b) { if (a == '#'|| b == '#') continue; cout << "result: "<<a+b; } return 0; } from have shown, think might want. int main() { string comment; int nr1,nr2; // read first number. should first 1 always. no comment before number! cin >> nr1; // see if can read second number successfully. means integer. if(cin >> nr2) { } // otherwise clear cin , read rest of comment line

javascript - How to handle async getJSON to copy json objects? -

this question has answer here: how return response asynchronous call? 21 answers how assign/clone received json object defines javascript object booksjson ? need make booksjson accessible , visible functions. var booksjson = {}; function getbooks(){ $.getjson( "bookstore.json", function( json ) { $.each(json.books, function(i, json){ renderentity(json); }); booksjson = json; // clone objects }); } update: new code: var booksjson = {}; function getbooks(){ return $.getjson( "bookstore.json" ); } $(document).ready(function(){ getbooks(); getbooks().done(function(json) { $.each(json.books, function(i, json){ renderentity(json); }); booksjson = json; alert(json.stringify(booksjson)); }); }); it has nothing cloni

performance - why is lift framework so slow? -

i learning lift framework. used project template git://github.com/lift/lift_25_sbt.git , started server container:start sbt command. this template application displays simple menu. if use ab apache measure performance, pretty bad. missing fundamental improve performance? c:\program files\apache software foundation\httpd-2.0.64\apache2\bin>ab -n 30 -c 10 http://127.0.0.1:8080/ benchmarking 127.0.0.1 (be patient).....done server software: jetty(8.1.7.v20120910) server hostname: 127.0.0.1 server port: 8080 document path: / document length: 2877 bytes concurrency level: 10 time taken tests: 8.15625 seconds complete requests: 30 failed requests: 0 write errors: 0 total transferred: 96275 bytes html transferred: 86310 bytes requests per second: 3.74 [#/sec] (mean) time per request: 2671.875 [ms] (mean) time per request: 267.188 [ms] (mean, across concurrent requests) transfer rate

linq to sql - "Cannot insert explicit value for identity column..." even though I'm not -

i have function: private static void saveresource(strategicplanningdbdatacontext ctx, resourcemodel resource, int impliedid) { var existing = ctx.resources.firstordefault(r => r.id == resource.id) ?? new resource(); existing.impliedid = impliedid; existing.hasaccepted = resource.hasaccepted; existing.isprimary = existing.isprimary; existing.userid = resource.userid; if (existing.id == default(int)) { ctx.resources.insertonsubmit(existing); ctx.submitchanges(); resource.id = existing.id; } } i'm getting cannot insert explicit value identity column in table 'resource' when identity_insert set off. message when hit ctx.submitchanges() new resource . resource.id identity (obviously). it's 0 when come function (because created it, , int s have have default value. i've tried deleting table dbml , re-adding several times, keep

java - Creating a multicolored board -

i create multicolored board, starting first square black, blue, red, , yellow, squares being filled diagonally , there no empty colored squares. know algorithm wrong, have not clue how fix it. currently, code prints out this import javax.swing.jframe; import javax.swing.jpanel; import java.awt.color; import java.awt.dimension; import java.awt.graphics; import java.awt.graphics2d; import java.awt.insets; public class grid extends jpanel { private static final long serialversionuid = 1l; public static final int grid_count = 8; private color[] colors = { color.black, color.yellow, color.red, color.blue }; private int colorindex = 0; public void paintcomponent(graphics g) { super.paintcomponent(g); graphics2d graphics = (graphics2d) g; graphics.setcolor(color.black); dimension size = getsize(); insets insets = getinsets(); int w = size.width - insets.left - insets.right; int h = size.height - insets.top - insets.bottom; int sqrwidth = (int)

ios - Mimic Apple's iBooks pages? -

i'm trying find solution display ton of formatted text in iphone/ipad app. absolute user-friendly way use paginated view, apple's ibooks does. data located in core data, book-long text should formatted headers ( , few table-like elements , images). have far tableview job, makes scrolling , breeze, due reuse of table cells etc., isn't preferred visual style (plus, want display magazine-like columns on ipad version). now if wanted implement uipageviewcontroller-driven solution (plus page "scrubber" on bottom), i'd need pre-render pages that a) jumping next pages using scrubber , b) showing current section of text in scrubber subview possible. so core text powerful enough fill amount of views in matter of seconds (like ibooks -> can see dots on bottom getting darker after quick jumping becomes available) or need reconsider concept? don't want end wasting amount of coding because of unforeseeable memory/processing power issues... many thanks

jquery - Append to body then remove - can't get it to remove -

i've simple modal window appends body - clicking close button should remove thought no. i've tried $(this).remove(); , took out button not appended text - have gone wrong? $(function(){ var qrcodediv='<div id="qrblock"><a href="#" class="closeqr">x</a></div>' $(".add").click(function(){ $('body').append(qrcodediv); }); $('a.closeqr').live("click", function() { $('body').remove(qrcodediv); }); }); .remove() not accept arbitrary html string . such syntax useful creating elements, that's not .remove() does. change $('body').remove('#qrblock') or $('#qrblock').remove() . note code in question insert multiple elements same id when click callback runs more once, which big no-no , lead undefined behavior.

c# - bind variable to .net textbox.text property -

im trying simple variable bind control text box cant life of me working. here scenario 2 forms 1 datagrid , , other 2 textboxes. when click on datagrid pass variables textboxes in form1. have tried no results. in form1 public string mytext { { return tuidinput.text; } set { tuidinput.text = value; } } then form 2 when try set value try this. private void selectuser(object sender, datagridviewcelleventargs e) { userpicked.tuid = datagridview1.rows[datagridview1.currentcell.rowindex].cells["spriden_id"].value.tostring(); userpicked.name = datagridview1.rows[datagridview1.currentcell.rowindex].cells["spriden_last_name"].value.tostring(); form1 form1 = new form1(); form1.mytext = userpicked.tuid } i got example here http://social.msdn.microsoft.com/forums/en-us/csharpgeneral/thread/7308639f-640b-48bf-8293-abcbfd2292d8/ however not update textbox? should doing differentely? what im doin

powershell v3.0 - Remove the last pipe from a text file -

objective: need remove last | file, if last \w character in file. why following syntax append instead of replacing? [io.file]::readalltext(".\example.txt") -replace '`|$','' > .\example.txt i tried [io.file]::readalltext(".\example.txt") -replace '\|$','' > .\example.txt ...which doesn't anything, seems. not surprisingly, equivalent get-content doesn't work either: (get-content .\example.txt) | foreach-object {$_ -replace '$\|', ''} | set-content .\example.txt i assume issue parsing pipe, uncertain how compensate it. thanks in #powershell on freenode, have now. $content = get-content example.txt; if ($content[-1] -eq '|') { $content.substring(0,$content.length-1) > example.txt }

windows - RegisterClassEx crashes - C++ -

i working windows library, i'm new it, i'm gettin error googled enough , don't know what's going on. here code: lresult callback wbwindow::st_wind_callback(hwnd hwnd, uint message, wparam wparam, lparam lparam) { // code callback static function return 0; } wbwmresult wbwindow::create() { // put in class values our window class_window_instance.cbsize = sizeof(wndclassex); class_window_instance.lpfnwndproc=wbwindow::st_wind_callback; class_window_instance.lpszclassname = window_name; class_window_instance.style = null; class_window_instance.cbclsextra = 0; class_window_instance.cbwndextra = 0; class_window_instance.hbrbackground = (hbrush)(color_window+1); class_window_instance.hcursor = loadcursor(null, idc_arrow); class_window_instance.hicon = loadicon(null, idi_application); class_window_instance.hiconsm = loadicon(null, idi_application); class_window_instance.hinstance = main_instance; class_window_instance.lpszmenuname = null; if(!registerclassex(&clas

javascript - Prepend object using jquery and disappear -

i writing javascript file using jquery in order inject input box on html page. however, when inject input on page , within few second input box disappear. wondering why happen. function injectarea(data) { $('#test').prepend('<input type="text" class="input-block-level" placeholder=" " value="hi">'); } p.s. m using twitter bootstrap. not sure if causes problem. when call function this: $(document).ready(function(){ $(#button).click(injectarea); }); this html: <form class="form"> <button id ="button" class="btn btn-large btn-primary">update profile</button> </form> this fiddle shows there nothing wrong prepend or way using it. issue must come elsewhere. guess may have ajax callback fires few seconds after call overriding change making #test . fiddle: http://jsfiddle.net/jy43a/ update: you said: for reason page refresh itse

java - jetty hangs on when accessing ServletRequest methods in async context -

i running code given in answer question- servlet-3 async context, how asynchronous writes? instead of response.getwriter().write(some_big_data); i've changed line servletrequest req= ctx.getrequest(); response.getwriter().write(req.getcontenttype()); now, request timing out. how can access request object? i'm assuming having problems using code snippet within own thread after startasync() call. per servlet 3.0 spec, section 2.3.3.4, access request , response objects not thread-safe. in fact, depending on state of object lifecycle, request , response objects can recycled. it encouraged grab need request , response objects before startasync() , use references own thread. in other words, use of ctx.getrequest() , response.getwriter() should done before startasync()

vba - Word Macro to determine whether document contains highlighting -

i'm trying write macro displays popup when user clicks save (i have sub filesave() ) if document contains highlighting. far, works great message box. unfortunately can't figure out conditions use if statement check whether document contains highlighting or not. can me few lines of vba this? you need search highlighted text within document content in way: sub searchanyhighlight() dim hilirng range set hilirng = activedocument.content hilirng.find .highlight = true .execute end if hilirng.find.found 'to inform found msgbox "you can't close active document" 'to remove highlighted area <-- added after edition hilirng.find .replacement.highlight = false .execute "", replace:=wdreplaceall, forward:=true, _ replacewith:="", format:=true end end if end sub

git - How to move issue within GitHub organization? -

with github organization can see all issues in 1 place url example https://github.com/organizations/nodeclipse/dashboard/issues how move issue within github organization? related: general approach: github-2-github issues import how move issue on github repo? there no official way it. but, there scripts read in issues , recreate them in repo, one: https://github.com/collective/collective.developermanual/blob/master/gh-issues-import.py but in our org, close issue (with moved message) , manually recreate it.

c# - Set style properties to a div in listview -

i have page listview, has div. div has different background color according database info: <asp:listview id="lvwpostart" runat="server" datasourceid="odsadvanced" groupitemcount="3" onitemdatabound="lvwpostart_itemdatabound"> <emptydatatemplate> <p>no matches.</p> </emptydatatemplate> <layouttemplate> <table style="border: none"> <asp:placeholder id="groupplaceholder" runat="server"></asp:placeholder> </table> </layouttemplate> <grouptemplate> <tr> <asp:placeholder runat="server" id="itemplaceholder"></asp:placeholder> </tr> </grouptemplate> <itemtemplate> <td> <!--heeeeeeeere's div!!! -->

Python Nested Function Variable Assignment -

this question has answer here: python variable scope error 10 answers i'm trying along following lines in python3: i = 1337 def g(): print(i) = 42 g() but following error unboundlocalerror: local variable 'i' referenced before assignment i think understand error message means, why case? there way circumvent this? in 2 words - when given variable name not assigned value within function references variable looked up. use global - , in such case python in global scope: i = 1337 def g(): global print = 42 g() you can read more on variable scopes in pep-0227

javascript - jQuery/Check if image is wrapped in a list item -

this question has answer here: jquery check if parent has id 3 answers i'm using javascript , jquery make light box, , have simple function wraps each image, inside container div, list item, want check see if they're wrapped in list items or not. know of way it? something this: $('img, div.lbcontainer').each( function() { //other stuff if ( $(this).parent() = li) { // not sure of syntax $img.unwrap(); } else { $img.wrap('<li id="images_lb"></li>'); } }); you can check parent , length: if ($(this).parent("li").length) { // parent li } else { // wrap }

javascript - Declarative dojox.grid.datagrid's header has onclick event? -

is possible have onclick in dojox.grid.datagrid's header. i tried calling function in header's onclick.. doesn't work. <div class="claro" id="cvsd" name="datagrid" onclick="getconnect('inner__cvsd');setwidgetproperty(this.id,'xy','inner__cvsd');" ondblclick="editcustomgrid(this.id)" onmouseup="setdocstyle(this.id)" style="height: 200px; left: 44px; position: absolute; top: 114px; width: 950px;"> <table class="claro" dojotype="dojox.grid.datagrid" id="inner__cvsd" rowselector="10px" style="height: 180px; width: 400px;"> <thead> <tr> <th field="column1" id="column1_2" width="100px" onclick="getconnect();"> column1 </th> </tr> </thead> </table> <

dns - IP address in HTTP_HOST -

i have drupal site use domain access module works using inbound http_host variable.i have create subdomain's also.to make module work $_server['http_host'] variable should have domain name in .but getting ip address of our server.so site not working properly.i getting main site.but subdomains not working.all pointing main site. my site on our server , asked our host point our domain name 172.xx.xxx/drupal.our subdomains pointed 172.xx.xxx/drupal. when type domain name showing site http_host has ip in it.we have vps host plan.what should make work properly. please help. thing looks easy. required tell domain host provider point sub - domains 172.xxx. ip / drupal. some examples. a.yourdomain.com => actuall point 172.xxx/drupal. b.yourdomain.com => actuall point 172.xxx/drupal. c.yourdomain.com => actuall point 172.xxx/drupal. after domain access module automatically take care of sub-domain wise access content. note: technically domain access mod

php - Magento 1.7 sorting by ordered quantity - bestseller products issues -

there several cases reported standard solution(s) query not work (similar questions on abunding,with no definitive solution whatsoever). what 1 retrieve collection of "bestsellers" use query builder: $storeid = mage::app()->getstore()->getid(); $collection = mage::getresourcemodel('reports/product_collection'); $collection->setvisibility(mage::getsingleton('catalog/product_visibility')->getvisibleincatalogids()); $collection = $collection ->addfieldtofilter('*') ->addorderedqty() ->addstorefilter() ->setstoreid($storeid) ->setorder('ordered_qty', 'desc') ->setpagesize(10) ->setcurpage(1); now, $collection result holds bogus values , it's missing important attributes altogether (no name, price, etc.). cannot try this core-code workaround in 1.7. could please post solution magento 1.7 verified/certified/tested? (or

compiler construction - Accessing a Python object from Java Code in Jython 2.5 -

i have application using jython 2.1. in app using jythonc convert python scripts java classes , include these classes in webapp other. able assign package name python scripts , access these classes other java class. now plan migrate jython 2.5. jython 2.5 has removed support jythonc. tried use jython -m compileall /path/to/my/python/scripts. when compiled bytecode files in same folder. each of files have names myclass$py.class (where python file myclass.py). my questions - first of can access these classes in normal java class? if so, class name should use ? when use new myclass() code not compile. is there way, can assign / force package name or class name generated bytecode compileall? note - i need upgrade jython 2.5 because need newer versions of python supports. i stick pre-compiling python code bytecode, want optimizations on bytecode. recommended object factory method last resort. assuming object factory approach not allow me process generated bytecode.

jquery - How do i remove all option from multiselect2side select box? -

i used jquery multiselect2side select box. used below code add option $("#myselect").multiselect2side('addoption', {name: opiontitle, value: libraryvalue[i].uri, selected: false}); in same way, want remove option select box. used below jquery script remove. not working $("#myselect").empty(); after empty need destroy , again initialize plugin. hope works you. $('#myselect').empty().multiselect2side('destroy'); $('#myselect').multiselect2side();

c# - Windows authentication in connection string (ASP .Net Application) -

i had common windows account app , db servers applicationadmin. want set both servers different windows account. created 2 windows account on same domain applicationapp , applicationdb both servers , activeted on respective servers. my application using windows authentication in connection string. when disabling applicationadmin account sql server on db server getting error " login failed user 'domain\applicationadmin'. reason: account disabled". due reason can't delete old applicationadmin account domain. how can change default windows authentication connection string takes self. want query string takes windows authentication domain\applicationapp have added sql server @ db server. in sort have 2 active windows account on app server , connection string taking old authentication required take newly configured user's authentication.

c# - WPF How to listen to a BindingBase object? -

i want create special datatrigger inheriting triggerbase<frameworkelement> . similar datatrigger , property of type bindingbase has been defined in mydatatrigger class. how can listen in order trace changes? public class mydatatrigger : triggerbase<frameworkelement> { ... /// <summary> /// [wrapper property bindingproperty] /// <para> /// gets or sets binding produces property value of data object. /// </para> /// </summary> public bindingbase binding { { return (bindingbase)getvalue(bindingproperty); } set { setvalue(bindingproperty, value); } } public static readonly dependencyproperty bindingproperty = dependencyproperty.register("binding", typeof(bindingbase), typeof(mydatatrigger), new frameworkpropertymetadata(null)); } update: the main problem

mysql - Trouble with a simple inner join for multiple tables -

edit: made little change. added table db_supplier (supplier_id, supply_speed_id) , changed lookup_supply_speed (supplier_id, supplier_speed) lookup_supply_speed (supplier_speed_id, supplier_speed) my tables: db_supply ----------------------------------------------- | supplier_id | supply_type_id | itm_id | stock | |-----------------------------------------------| | 1 | 1 | 33 | 3 | |-----------------------------------------------| | 2 | 2 | 28 | 1 | ----------------------------------------------- db_supplier ---------------------------------------- | supplier_id | supply_speed_id | etc... | |----------------------------------------| | 1 | 1 | | |----------------------------------------| | 2 | 2 | | ---------------------------------------- lookup_supplier_name ----------------------------- | supplier_id | supplier_name | |-------------------------

angularjs - How can I defer view rendering until some data is loaded from an external source? -

my app needs load data $rootscope external source when initializes. since data external source, time required load data not guaranteed. want defer rendering of view until after data loaded successfully. there way achieve this? note not using angular routing app. here simplified demo there isn't clean way prevent view rendering until async operation completes without using route resolves, program custom directive same work. however, if strictly user experience, using ngshow work swimmingly: <div ng-show="user.name"> <!-- content won't visible until data set --> </div> here's updated plunker: http://plnkr.co/edit/mxoqnwhvyp9aoxg0qooc?p=preview

How to load XML data file into Hive table? -

while loading xml data file hive table got following error message: failed: semanticexception 7:9 input format must implement inputformat. error encountered near token 'storesxml'. the way loading xml file follows : **create table storesxml 'create external table storesxml (storexml string) stored inputformat 'org.apache.mahout.classifier.bayes.xmlinputformat' outputformat 'org.apache.hadoop.hive.ql.io.hiveignorekeytextoutputformat' location '/user/hive/warehouse/stores';' ** location /user/hive/warehouse/stores in hdfs. load data inpath <local path xml file stored> table storesxml; now,problem when select column table storesxml ,the above mentioned error comes up. please me it.where going wrong? 1) first need create single column table create table xmlsample(xml string); 2) after need load data in local/hdfs hive table like load data inpath '---------' table xmlsample; 3) next

jQuery fade out elements as they scroll off page, fade back as they scroll back on -

i want elements fade out scroll off top of page, , fade in scroll onto page. wrote code works, looking more elegant solution. here solution have working on jsfiddle: http://jsfiddle.net/wmmead/jdbhv/3/ i find shorter, more elegant piece of code, can't quite work out. maybe array , each() method? if put class on divs instead of id, gets lot shorter, fade out @ once. want each box fade out scrolls off page. html <div id="box1"></div> <div id="box2"></div> <div id="box3"></div> <div id="box4"></div> <div id="box5"></div> <div id="box6"></div> css #box1, #box2, #box3, #box4, #box5, #box6 { width: 100px; height: 100px; background: orange; margin:100px auto; } #box6 { margin-bottom:600px; } jquery var box1top = $('#box1').offset().top; var box2top = $('#box2').offset().top; var box3top = $('#box3').offset()

java - Test cases for the below function -

i not familiar unit tests came across question in interview. can me unit test cases , explain output. know need pass parameters negative cases? unit test function uses following parameters: reversestring(originalstring, stringtobereversed, stringreverseto, max) reversestring(originalstring, stringtobereversed, stringreverseto, max) you need matrix test cases, have test each combination string parameters of empty strings, nulls, depending on implementation evtl. strings contain non english values. for integer parameter negative, 0 , positive numbers, depending on max means maby should test big number exceeds maximum linit if exists. the things mentioned may have tested in combination each other. example null original string negativ integer, depend on implementation, if have such loop has combined condition of 2 parameters combination should tested.

c# - New Thread inside a Thread in WinRT -

i performing functionality in threadpool. inside thread, linq query executed. takes more time because, in query selects collection of class has bool property checked 2 collection. collection.select(item => new myelement { isactive = this.checkisactive(collection1, collection2, item), value = item, name = item != null ? item.tostring() : "empty" }).tolist<myelement>(); checkisactive method---- private bool checkisactive(list<object> collection1, list<object> collection2, object item){ if (collection1.contains(item) && !collection2.contains(item)) return false; return true;} can optimized? idea? can use new thread above execution in new thread? can use thread or await return type method?

android - tagging a list of gerrits as a label -

is there way tag list of gerrits label...after tagging,if repo sync of label,these gerrits should synced workspace..is there option dat?has done before?any advice on appreciated. commands used repo sync $repo init -u git://git.server.com/platform/manifest.git -b refs/tags/label -m versioned.xml #eg sync label <code snippet> $ repo sync # syncing code to create tag: repo forall -c "git tag -a -m \" [ tag description ] \" [ tag-name ] " push tags remote repository: repo forall -c "git push origin [tag-name]"

locking - How to lock a file in Actionscript? -

using actionscript 3.0, how can lock file? i'd write highscores file , place game on server, don't want things go wrong when 2 players submit highscore @ same time. openasync() method of filestream suffice this? thanks shaunhusain: when placing project on webserver, swf-file sent client machine , processed there, each user of flash app/game have own high scores list on own machine. in order handle scores being submitted you'll need php, believe mysql handle concurrency issues you. other server side languages , databases work equally well, 2 know , documented , free.

Java - is it bad practice not to have a class constructor? -

i want make helper class deals formatting (i.e. has methods remove punctuation , convert between types, reformatting names etc.). doesn't seem need fields - purpose passed things convert , return them, reformatted. bad practice leave out constructor? if so, should constructor doing? looking @ this link , noticed class describes lacks constructor. is bad practice leave out constructor? yes - because unless specify any constructors, java compiler give constructor same visibility class itself. assuming methods static - seems unless want polymorphism - should make class final , give private constructor, other developers don't accidentally create instance of class, when pointless. when thinking api, time can remove ability developers stupid, :) so like: public final class helpers { private helpers() { } public static string formatdate(date date) { // etc } } note taking polymorphism out of equation, you're removing possibi

php - Input Type Radio Button Undefined Index -

$sel=""; $suc=""; $gend=""; $male=""; $female=""; $selected_radio=""; if(isset($_post['save'])) { $e=0; $selected_radio = $_post['gender']; if($selected_radio!="") { if ($selected_radio == 'male') { $male = 'checked'; } else if ($selected_radio == 'female') { $female = 'checked'; } } else { $sel="select gender"; $e=1; } if($e==0) { $suc="success"; $male =""; $female =""; } } without selecting option/radio button, when click "save" (submit button)., showing "undefined index: gender" . error msg appearing "select gender" . when select 1 option(male/female), appearing msg.( "success" ). so please me find solution $sel=""; $suc=""

.net - Creating Automatic Skype Listener -

Image
i need build skype listener server 1 of project. will: 1. host 8 different dummy skype accounts. 2. accounts have associated: (a) recorded audio files (b) pre-recorded video files 3. skype call of these skype accounts automatically initiate pre-recorded audio or video depending upon call type. problem: 1. unable install more 1 skype client on 1 machine. required if install virtual webcam , need change video source virtual web cam , play pre-recorded video. if don't install more 1 client, playing same video calls contact 2.how automate call recieving on skype. there uri initiating call none receiving call. 3. a wish : can integrate receiving call event of skype kick our .net code? any immediate highly appreciated regards raj in skype desktop (windows) can setup automatic answering of incoming calls in call settings (advanced). and start multiple instances, use skype.exe /secondary , it'll allow many instances want. you cannot integrate .net, or other

producer - Exception in thread "main" java.lang.NoSuchMethodError: scala.Tuple2._1$mcI$sp()I -

properties props = new properties(); props.put("zk.connect", "localhost:2181"); props.put("serializer.class", "kafka.serializer.stringencoder"); producerconfig config = new producerconfig(props); producer producer = new producer(config); producerdata data = new producerdata("test-topic", "test-message"); producer.send(data); i trying execute code got exception in thread "main" java.lang.nosuchmethoderror: scala.tuple2._1$mci$sp()i exception. added scala related jar file.plese suggedt me ?????? i faced same issue. check classpath see if sbt-launch.jar preceding scala-library.jar. both of them have same class; scala.tuple2 scala-library correct one. after placing scala-library.jar higher in classpath solved issue. thanks, hussain

ios6 - iCarousel integration to app having Tab bar controller in iOS 6.1 -

i integrate icarousel app single view application.but when add tab bar controller , place icarousel code in 1 tab bar item viewcontroller.but not work(items displayed not scrolled).what problem here. i created icarousel below: icarousel *categorysubview = [[icarousel alloc]initwithframe:cgrectmake(0,200, 300, 125)]; categorysubview.autoresizingmask = uiviewautoresizingflexiblewidth | uiviewautoresizingflexibleheight; categorysubview.delegate = self; categorysubview.datasource = self; categorysubview.type=icarouseltyperotary; [self.view addsubview:categorysubview]; i using following delegae , data source methods: -(nsuinteger)numberofitemsincarousel:(icarousel *)carousel { return 5; } - (uiview *) carousel:(icarousel *)carousel viewforitematindex:(nsuinteger)index reusingview:(uiview *)view{ uiview *sampleview=[[uiview alloc]initwithframe:cgrectmake(0, 0, 250, 300)]; sampleview.backgroundcolor=[uicolor whitecolor]; uilabel *labelis=[[uil

python - HDFStore: table.select and RAM usage -

i trying select random rows hdfstore table of 1 gb. ram usage explodes when ask 50 random rows. i using pandas 0-11-dev, python 2.7, linux64 . in first case ram usage fits size of chunk with pd.get_store("train.h5",'r') train: chunk in train.select('train',chunksize=50): pass in second case, seems whole table loaded ram r=random.choice(400000,size=40,replace=false) train.select('train',pd.term("index",r)) in last case, ram usage fits equivalent chunk size r=random.choice(400000,size=30,replace=false) train.select('train',pd.term("index",r)) i puzzled, why moving 30 40 random rows induces such dramatic increase in ram usage. note table has been indexed when created such index=range(nrows(table)) using following code: def txtfile2hdfstore(infile, storefile, table_name, sep="\t", header=0, chunksize=50000 ): max_len, dtypes0 = txtfile2dtypes(infile, sep, header, chunksize) pd.

r - Line search fails in training ksvm prob.model -

following invalid probability model large support vector machines using ksvm in r : i training svm using ksvm kernlab package in r. want use probability model, during sigmoid fitting following error message: line search fails -1.833726 0.5772808 5.844462e-05 5.839508e-05 -1.795008e-08 -1.794263e-08 -2.096847e-12 when happens, resulting value of prob.model(m) vector of probabilities, rather expected parameters of sigmoid function fitted on these probabilities. causes error , how can prevent it? searching error message yielded no results. reproducible example: load(url('http://roelandvanbeek.nl/files/df.rdata')) ksvm(label~value,df[1:1000],c=10,prob.model=true)->m prob.model(m) # works should, prints list containing 1 named list # below, non-working problem, unfortunately takes hour due large # sample size ksvm(label~value,df,c=10,prob.model=true)->m # line search fails prob.model(m) # vector of values looking @ source code, this line throws err

echo json_encode($data,TRUE) is not going back to the ajax function in codeigniter -

my code is <script> $("#saveexpense").click(function(){ alert('i in jquery function'); $.ajax({ type:'get', url: "<?php echo site_url('expenses/addexpense');?>", datatype: 'json', data:$('#addexpenseform').serialize(), success: function(response) { comsole.log(response); var curlen = response.length; var htm = curlen+"| &nbsp;"+response[curlen-1].category+"| &nbsp;"+response[curlen-1].amount+"| &nbsp;"+response[curlen-1].comments+"| &nbsp;edit/delete<br />"; $("#showexpenses").append(htm); } }); }); my controller function addexpense(){ if(!$this->session->userdata('logged_in')) redirect('expenses','refresh'); $this->expenses_model->addexpense(); $data=$this->exp

c# - Extract images through database -

i working on extracting images database(sql server 2008) im using wpf application , using grid_loaded event load pages. examples have found using combo box select id of image , displaying it. not want use combo box. i have few lines of code have worked on , found on internet, appreciated if helps me! private void loadimages() { try { string connstr = @"server=ctgpjlpc21\sqlexpress;database=testing;trusted_connection=true;"; using (sqlconnection conn = new sqlconnection(connstr)) { conn.open(); using (sqldataadapter adapter = new sqldataadapter("select * test_table", conn)) { dset = new dataset(); adapter.fill(dset); } datatable dt = dset.tables[0]; foreach (datarow row in dt.rows) { if (dset.tables[0].rows.count == 1)

javascript - window.onpopstate on page load -

i'm playing window.onpopstate , , there thing annoys me little bit: browsers tend handle popstate event differently on page load. chrome , safari emit popstate event on page load, firefox doesn't. source i tested it, , yeah, in chrome , safari 5.1+ popstate event fired on page load, not in firefox or ie10. the problem is, want listen popstate events user clicked back or forward button (or history changed via javascript), don't want on pageload. by other words want differentiate popstate event page load other popstate events. this tried far (i'm using jquery): $(function() { console.log('document ready'); settimeout(function() { window.onpopstate = function(event) { // here }, 10); }); basically try bind listener function popstate late enough not bound on page load, later. this seems work, however, don't solution. mean, how can sure timeout chosen settimeout big enough, not big (because don't want

iphone - Word cut off in TTTAttributedLabel -

Image
i using tttattributedlabel when try show link cut word center can see in attached image word "fun" cut off after word "f" , "un" appears on next line. want full word should show on first line or in next line. help. if ([_label iskindofclass:[tttattributedlabel class]]) { tttattributedlabel *tttlabel=(tttattributedlabel *)_label; [tttlabel setdelegate:self]; [tttlabel setdatadetectortypes:uidatadetectortypelink|uidatadetectortypephonenumber]; [tttlabel setlinebreakmode:nslinebreakbywordwrapping]; [tttlabel settext:attributedtext]; if ([dic objectforkey:@"texttolink"]!=nil) { [tttlabel addlinktourl:[nsurl urlwithstring:[dic objectforkey:@"hyperlink"]] withrange:[text rangeofstring:[dic objectforkey:@"texttolink"] options:nscaseinsensitivesea

android - DatePickerFragment an cleaning project -

i have datepickerfragment in android project: public class uses extends fragmentactivity { @override public void oncreate(bundle savedinstancestate) { //code } public class parkinglisthttp extends asynctask<string, void, string> { //code } @override protected void onpostexecute(string result) { //code } public void returnuses(string date) { //code } public void selectdate(view v) { dialogfragment newfragment = new datepickerfragment(); newfragment.show(getsupportfragmentmanager(), "datepicker"); } public class datepickerfragment extends dialogfragment implements datepickerdialog.ondatesetlistener { @override public dialog oncreatedialog(bundle savedinstancestate) { // use current date default date in picker final calendar c = calendar.getinstance(); int year = c.get(calendar.year); int month = c.get(calendar.month); int day = c.get(calendar.day_of_month);

php - OPERATION WITH UNIX DATE -

im making sql this: select * post date between :date1 , :date2 date2 going today date php time(); (unix format). need take date2 minus 7days ( 1 week) , date2 minus 1 month. (this choosen user on form). the problem can't operation unix dates work. $date2 = time(); $date1 = $_get['fromdate']; $query = "select * post date between :date1 , :date2"; html form select id=fromdate> <option value=<?php echo time()-604800>week</option> /select> $today = time(); $oneweekago = time() - (60 * 60 * 24 * 7); // 60 seconds, 60 minutes, 24 hours, 7 days $onemonthago = time() - (60 * 60 * 24 * 30); // 60 seconds, 60 minutes, 24 hours, 30 days or more exact $onemonthago: $date = date_create(); // datetime object of today date_modify($date, "-1 month"); // 1 month ago $onemonthago = date_timestamp_get($date); // unix time