Posts

Showing posts from August, 2010

python - Trouble with django upload_to callable -

i'm working on uploading file dynamic path based on model instance. here sample code: class test(models.model): def _upload_to(instance, filename): return '/'.join([instance.username.name, filename]) username = models.foreignkey(usermodel) #defined elsewhere file = models.filefield(upload_to=_upload_to) and test it: >>> t = test(file="myfile.txt") >>> t.save() but doesn't seem put in right path, still get: >>> t.file.url /media/myfile.txt when should be /media/someusername/myfile.txt what wrong in example? your test isn't testing right thing. upload_to callable called when upload file, name implies, not when save model. need try actual upload: perhaps try through admin site. when do, run problems because python think function instance method, because have defined inside class. you'll need take outside of class, or decorate @staticmethod .

prolog - Evaluating Factorial -

i trying write prolog function evaluate factorial of number. factorial(1, 1). factorial(x, y) :- factorial(a, b), y b * x, x-1. the first bit base-case, factorial of 1 1. it works fine 1! , 2!, number above throws. 12 ?- factorial(3,x). error: is/2: arguments not sufficiently instantiated first, version not work 1 or 2 suggest. , there 0 , too. answers, have not asked next answer: ?- factorial(1, f). f = 1 ; error: is/2: arguments not sufficiently instantiated so localize problem? throw in false : factorial(1, 1). factorial(x, y) :- factorial(a, b), y b * x, false , a x-1 . ?- factorial(2, y). error: is/2: arguments not sufficiently instantiated still same problem. must (is)/2 culprit. let's pull false further: factorial(1, 1) :- false . factorial(x, y) :- factorial(a, b), false , y b * x , a x-1 . there 2 remarkable things now: fragment loops! , should evident why: there nothing between head , recursive

ios - Unable to get subclassed UITableViewCells to display data from successfully queried Parse objects -

this question has been answered; thank jsksma2. i cannot data fill rows in tableview, though data , can hard-code tableview display static amount of dummy text. have hunch issue relates initwithstyle vs initwithcoder subclassed uitableviewcells. in subclass of uitableviewcontroller called "giveitemstableviewc", during viewdidload querying parse objects each called "pfgiveitem". these , add each 1 global variable, mutable array called "mygiveitems". log these, , looking for, part working. giveitemstableviewcontroller - (void)viewdidload { [super viewdidload]; pfquery *query = [pfquery querywithclassname:@"giveitem"]; [query wherekey:@"giver" equalto:[pfuser currentuser]]; [query findobjectsinbackgroundwithblock:^(nsarray *objects, nserror *error) { if (!error) { self.mygiveitems = [[nsmutablearray alloc]init]; (pfobject *object in objects) { pfgiveitem *newgiveit

java - Android Keystore getEntry() and generateKeyPair() throw Exceptions sometimes -

my android app need encrypt file can decrypt , read later. should not decrypt-able else other app, user. following how doing encryption , decryption. works of time, times users failing. not specific particular handset (nexus7, samsung, motorola, htc -- types reporting issue), not users experiencing it. users occasionally. here relevant code: encrypt() { keystore ks = keystore.getinstance("androidkeystore"); final keystore.privatekeyentry entry; if (!ks.containsalias(cert_alias)) { calendar cal = calendar.getinstance(); date = cal.gettime(); cal.add(calendar.year, 50); date end = cal.gettime(); keypairgenerator kpg = keypairgenerator.getinstance("rsa", "androidkeystore"); kpg.initialize(new keypairgeneratorspec.builder(getapplicationcontext()) .setalias(cert_alias) .setstartdate(now) .setenddate(end) .setserialnumber(biginteger.valueof(1))

mysql - What to store an IP as in Java -

i connecting java program mysql database, need ip connect it. hard coding ip bad idea made config. problem not sure store ip in variable. looked around lot of places int, don't see how can correct because integers don't have decimals. should do? edit: answer mattias f more appropriate situation. being said, i'll explain why you've heard ip address can stored in integer. an ipv4 address consists of 4 octects, or 4 bytes of data. incidentally, that's how information 32-bit integer can hold. here methods go both ways: public static int ipstringtointeger (final string ip) { int value = 0; final string[] parts = ip.split ("\\."); (final string part : parts) value = (value << 8) + integer.parseint (part); return value; } public static string ipintegertostring (int ip) { final string[] parts2 = new string[4]; (int = 0; < 4; i++) { system.out.println ("value : " + (ip & 0xff));

XSLT: how do I parse a document to retain only interesting nodes, along with all parents, at any depth? -

given document below: <root> <a> <b> <c>sometext</c> </b> <b> <d/> </b> <b> <e> <f>some interesting__text more</f> </e> </b> </a> <h> <g>another piece of very_interesting__text</g> </h> </root> i following out: <root> <a> <b> <e> <f>some interesting__text more</f> </e> </b> </a> <h> <g>another piece of very_interesting__text</g> </h> <interesting>interesting__text</interesting> <interesting>very_interesting__text</interesting> </root> essentially, need out parent nodes of node contains interesting text, can matched using regex \w+__\w+ . bonus, interesting pieces added somewhere @ end of document. the nodes can contain interesting p

cmd - make command fails when launched via CreateProcess but command line on Windows 7 -

i'm witnessing weird behavior make.exe on windows 7. if launch directly command line "make -j8 some-component-name", command succeed. if launch same c program using createprocess(.......) inheriting environment, etc parent, see fails below error message: make[4]: *** create_child_process: duplicatehandle(in) failed (e=6). stop. here's have tried far -- of them anyway didn't help. through createprocess() both 32-bit , 64-bit cmd.exe have been tried launch make command. built c program 32-bit , 64-bit. tried createprocess("c:\windows\system32\cmd.exe", "/c make -j8 some-component-name", ..) tried createprocess(null, "c:\windows\system32\cmd.exe /c make -j8 some-component-name", ..) tried createprocess(null, "cmd.exe /c make -j8 some-component-name", ..) things haven't tried thought of, though not sure if can fix problem: using shellexecute() in place of createprocess(). by way, make utility gnu

algorithm - Find 3 elements in each of 3 arrays that sum to a given value -

let , b, c 3 arrays of n elements each. find algorithm determining whether there exist a in a, b in b, c in c such a+b+c = k . i have tried following algorithm, takes o(n²) : sort 3 arrays. - o(n log n) temporary array h = k - (a+b) - o(n) for every h , find c' in b such c' = h - b[i] - o(n) search c' in c using binary search - o(log n) total = o(n log n) + o(n) + o(n² log n) can solve in o(n log n) ? suppose there existed solution s problem in o(n lg n) time. i show instance of 3sum, array of length n , linear-time reduces problem. given 3sum instance array s of length n , define arrays a = b = c = s , o(n) operation. use s(a, b, c, 0) determine whether there exist indices a,b,c arrays a,b,c , respectively, such a[a] + b[b] + c[c] = 0 in o(n lg n) time. since each array equal s , same values a,b,c satisfy 3sum's s[a] + s[b] + s[c] = 0 . unless you're publish big, doubt there can such fast algorithm problem, @ least ha

java - ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) - where is the error? -

i have little problem project. every time use btnlinktocreatesession.setonclicklistener(new view.onclicklistener() { public void onclick(view view) { intent = new intent(getapplicationcontext(), createsessionactivity.class); startactivity(i); finish(); } }); the error appears: "activitythread.performlaunchactivity(activitythread$activityclientrecord, intent)" when take out, works, again. there fault in code, or must error somewhere else? btnlinktocreatesession.setonclicklistener(new view.onclicklistener() { public void onclick(view view) { intent = new intent(getapplicationcontext(), createsessionactivity.class); startactivity(i); finish(); } }); // link register screen btnlinktoregister.setonclicklistener(new view.onclicklistener() { public void onclick(view view) { intent j = new

javascript - Get Position and Width of Parent Menu -

i want know how parent position , width jquery. example <ul id="menu"><li>parents</li> <ul><li>child</li></ul> </ul> my jquery: if($('#menu > li > ul').children('li').hasclass('current-menu-item')){ //do animate left: $(this).parent().siblings().position().left;, width: $(this).parent().siblings().width(); }); in case, @ <li>child</li> . how position , width of <li>parents</li> ? var parent = $('#menu .current-menu-item').parent().closest('li'); var position = parent.position(); var width = parent.width();

amazon web services - AND(&&) condition in EC2 command line tools --filter option -

i using ec2 command line tools this ec2-describe-tags --filter "resource-type=instance" --filter "value=value1" --filter "key=key1" --filter "value=value2" --filter "key=key2" i want know how put filters in and(&&) . want output should contain results satisfies filters. using newer aws ec2 api, following filters have && relation between them: aws ec2 describe-tags --filters "name=resource-type,values=instance" "name=value,values=value1" "name=key,values=key1" "name=value,values=value2" "name=key,values=key2"

php - How to find intersect rows when condition depend on some columns in one table -

table subscribe subscriber | subscribeto (columns) 1 | 5 1 | 6 1 | 7 1 | 8 1 | 9 1 | 10 2 | 5 2 | 6 2 | 7 there 2 users have id 1 , 2. subscribe various user , inserted these data table subscribe . column subscriber indicates subscriber , column subscribeto indicates they've subscribe to. above table can conclude that; user id=1 subscribed 6 users user id=2 subscribed 3 users i want find mutual of subscription (like facebook mutual friends) user 1 subscribe user 5,6,7,8,9,10 user 2 subscribe user 5,6,7 so, mutual subscription of user 1 , 2 are: 5,6,7 and i'm trying create sql statement.. give user table sql statement , think can use subscribe table can't figure out. table user userid (columns) 1 2 3 ... ... sql "select * user (select count( 1 ) subscribe subscriber = '1' , subscribeto = user.userid) , (select count( 1 ) subscribe subscriber = '2&#

c++ - Boost.Geometry polygon point assignment -

i trying use boost geometry , having trouble assigning points polygon. lets assume create static vector of points boost::geometry::model::d2::point_xy<double> >* a; and create polygon: boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > polygon; assuming have defined values of points of a. how can assign points p? the boost::geometry::assign_points() algorithm can used assign range of points polygon. if a range of points , p polygon, 1 use: boost::geometry::assign_points(p, a); here complete example demonstrating usage of assign_points : #include <iostream> #include <vector> #include <boost/assign/std/vector.hpp> #include <boost/geometry.hpp> #include <boost/geometry/algorithms/area.hpp> #include <boost/geometry/algorithms/assign.hpp> #include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/polygon.hpp> #include <boost/geo

java - Live Streaming of a music file in Android -

for learning purpose, tried creating client , server. 1 person sends udp packets of music file , other person receives it. created such app , packets being transmitted wanted. problem when after receiving packet, try play it, sound played nothing noise. meaningless sound comes speakers. to test process of sending , receiving packets , tried replacing audio file text file , check contents of packets @ receiver side. noticed packets received highly random . mean not in correct order. i know in udp packets can reach destination in order there no error control or anything. question how should correct sound out of speakers. if packets transmitted in order abc , received in order bca sound never correct. there way can convert byte array of packets meaningful sound. i know one solution use tcp tcp not live streaming. for purposes live streaming , video conferencing, udp used. correct way gather , play received packets. appreciated. code sender: inputstream songinputstream

hybridauth's social_hub/login.php doesn't work -

i install hybridauth on windows iis, , setup hybridauth\config.php below: array( "base_url" => "http:///hybridauth/", "providers" => array ( ..... "google" => array ( "enabled" => true, "keys" => array ( "id" => "<myappkey>", "secret" => "<myappsecret>" ), "scope" => "email" ), ) but when click "sign-in google" in http:///examples/social_hub/login.php, redirect me http:///hybridauth/?hauth.start=google&hauth.time=1401608000 show files under "localhost - /hybridauth/" know how fix it? thank you! 1) not sure if scope set (you should have set " https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email " 2) did set return address in google

php - Linux does not support uppercase file name, any idea? -

i uploaded website linux server, linux know lowercase files. solving converting of file name lowercase , convert of codes lowercase website convert lowercase text. for example 1 of code this: $sql="select * `article` `page` regexp '^$page' , `first_parent_page` = $parent_page , `level` = $level order `page` desc "; $result=mysql_query($sql,$con); if($result){ header('location:../login.php'); } this converted code: $sql="select * `article` `page` regexp '^$page' , `first_parent_page` = $parent_page , `level` = $level order `page` desc "; $result=mysql_query($sql,$con); if($result){ header('location:../login.php'); } i should lowercase codes because linux don't know uppercase named files login.php i used website convert codes convertor , convertor convert lowercase. , don't want convert stuff lowercase. this question please introduce me way solve problem or please tell me mysql work if

node.js - Image file upload with node and express -

hi trying image upload ajax.so files. //index.html <!doctype html> <html lang="en-us"> <head> <meta charset="utf-8"> <title>file upload showing upload progress</title> <style> * { font-family: verdana; font-size: 12px; } </style> </head> <body> <form action="/upload" method="post" enctype="multipart/form-data" id="myuploadform"> <input name="imagefile" id="imageinput" type="file" /> <input type="submit" id="submit-btn" value="upload" /> <img src="images/ajax-loader.gif" id="loading-img" style="display:none;" alt="please wait"/> </form> <div id="output"></div> <script type='text/javascript' src='http://code.jquery.com/jquery-1.7.1.min.

Preventing Linux kernel from taking allocated memory from a process -

i want allocate large portion of memory using malloc() indefinite amount of time. may touch memory long time let 1 minute. how prevent kernel taking memory away process? i can not re allocate memory because being used device outside of kernels control. in linux, can allocate memory in user space, such malloc or mmap , pass down kernel, , in kernel, obtain references memory get_user_pages . prevent pages going away, , allow them accessed address space struct page * references (and requiring kmap , kunmap if config_highmem in effect). these pages not contiguous physical memory, however, , may not in suitable range dma. memory accessed devices allocated in kernel (e.g. using kmalloc gfp_dma . allocations larger page, kmalloc finds consecutive physical pages, too. once obtained, kmalloc -ed memory can mapped user space remap_pfn_range .

java - Multiple query on DBpedia endpoint for movie information retrieval using Apache Jena -

i'm trying download films' information(year of production , title) using apache jena , querying dbpedia public endpoint. know public endpoint has security restrictions , reason doesn't grant use query return more 2000 rows in results set. reason, i've tried subdivide query in multiple query using limit , offset option appropriately , java program ( http://ideone.com/xf0gce ) i'll save them on specific file in formatted manner: public void moviequery(string dbpediafilms) throws ioexception { string includenamespaces = "prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" + "prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + "prefix dcterms: <http://purl.org/dc/terms/>\n" + "prefix dbpedia-owl: <http://dbpedia.org/ontology/>\n"; string currquery = includenamespaces + "select distinct ?movie (str(?movie_title) ?title) (str(?movie_year) ?year) {\n&quo

javascript - Accept integer or float type from user and add to array -

im trying add function accepts input user via value box. user types in int type or float value box , stored array. every time takes in new value, appends end of array. however, no matter do, keep getting error in console: uncaught typeerror: cannot read property 'value' of null what doing wrong? thanks. charges = []; function add() { var charge = document.getelementbyid(inputcharge).value; charges.push(charge); document.getelementbyid('divresult').innerhtml = charges.join(""); } <!doctype html> <html> <head><title></title> <script src="calculatetotal.js"></script> </head> <body> charge<input type="number" id="inputcharge" value=""> <input type="submit" value="add" onclick="add()"><br> deduct<input type="number" id="deduction" value=""> <input type="sub

arrays - Convert urllib2 output to a list python -

i want convert string urllib2 array or list of words. doing school project , stuck on part. suggestions? code below. import urllib.request url = input("please enter url: ") f=urllib.request.urlopen(url) print(f.read()) i want words in html string urllib generates parsed , have each word placed in own index in either array or list. thanks help.

button - Multi items app in Android -

i want create android app contains 5 or 6 options on menu page. , when click on menu option other activity starts , each activity related menu option contain 5 or 6 option start other activities. using buttons menu options. difficult create 25 36 activities. there way make easy? my problem is- activity1- option1 option2 option3 option4 option5 on option click new activity start i.e on click on option1 activity 2 starts , contains- option6 option7 option8 option9 option10 and on click on option6 description. so according way have create 30 activity classes time consuming. there easy way this? use slide menu page change. , on page use tabview that's choice

How to pass value to sql command in c# -

i have sql command: string keyprocesses = "select distinct stuff((select ', '+ cn.name wmccmcategories cn inner join categorysets uc on uc.categoryid = cn.categoryid inner join keyprocesses u on u.categorysetid = uc.setid inner join companies c on c.companyid = u.companyid c.companyname = @companyname order cn.name xml path('')), 1, 1, '') liststr wmccmcategories cnn group cnn.name"; and have: public sqlcommand sqlcmd = new sqlcommand(); sqlcmd.commandtext = commandtext; //where commandtext sql statement sqlcmd.parameters.clear(); then execute connection: string connectionstring = configurationsettings.appsettings["connectionstring"]; using (sqlconnection connection = new sqlconnection(connectionstring)) { sqlcommand command = new sqlcommand(commandtext, connection); try { connection.open(); sqldataadapter sdr = new sqldataadapter(sqlcmd.commandtext, connection); datatable dt=new datatabl

html - transition between background color and background image CSS3 -

i've got set of divs , want each of them have different background color , while on hover transition background image of chosen url. have far managed find code smooth color -> image transition requires actual img code in html , need divs putting text in them. is there chance have smooth 0.5s or less transition background color background url performed through css? if @ http://loopedmag.com can see want recreate in code transitioned animation color->image. you can't animate background property solid color image css3 transitions. to achieve desired behaviour, need fade in/out layer solid background color. may use pseudo element minimize markup layer. demo html : <div class="one"></div> <div class="two"></div> css : body,html{ height:100%; } div{ height:50%; width:50%; position:relative; background-size:cover; } .one{ background: url(http://lorempixel.com/output/fashion-q-c-64

html - Hide and move divs depending on device in Bootstrap -

Image
i using bootstrap create layout displays desktop, tablet , mobile. trying achieve illustrated here: to have created 3 divs: <div class="row"> <div class="col-md-3">text</div> <div class="col-md-3">text</div> <div class="col-md-3">text</div> </div> the middle div hidden on tablet view, last div fall below first on mobile view. using have, 3 divs display correctly on desktop, in tablet & mobile 3 collapse vertically. is there easy way bootstrap, or must write own css media queries? to hide middle div, use utilities class described in bootstrap: bootstrap 3 bootstrap doc use visible-lg class hide div on tablets , phones. i suggest use col-sm , col-xs collapse or not div depending width ( learn more grid system ): <div class="row"> <div class="col-sm-3 col-xs-9">text</div> <div class="col-sm-3 visible-lg&qu

parallel processing - Python C Extension OpenMP -

i getting segmentation violation in python interpreter when trying access variable returned own openmp c++ extension. all solutions have found either using ctypes or cython (which cannot use). http://snatverk.blogspot.de/2012/03/c-parallel-modules-for-python.html shows small example of openmp enabled python extension. although tried implement loops in example, still not work. my code extension code function looks this: static pyobject * matcher_match(pyobject *self, pyobject *args) { if(pytuple_size(args) != 2) { return null; } pyobject *names = pytuple_getitem(args, 0); py_ssize_t namessize = pylist_size(names); pyobject *namesb = pytuple_getitem(args, 1); py_ssize_t namesbsize = pylist_size(namesb); pyobject *matchidcs = pylist_new(namessize); py_begin_allow_threads; int i, j; #pragma omp parallel private(i, j) for(i = 0; < namessize; i++) { for(j = 0; j < namesbsize; j++) { // test_pair_ij pure c function without callbacks python //

wpf - Class name as string in defining a collection in c# -

i have class name string got using type type type = myvar.gettype(); string _classname = type.tostring(); // getting class name my question how use string _classname here in code below? var data = this.itemssource observablecollection<**_classname**>()[2]; here itemssource generic. thanks in advance. you can using reflection , activator.createinstance method: type type = myvar.gettype(); string classname = type.tostring(); type generictype = type.gettype(classname); type observablecollectiontype = typeof(observablecollection<>); type constructedtype = observablecollectiontype.makegenerictype(generictype); var constructedinstance = activator.createinstance(constructedtype);

app crash when try get user photo by Facebook iOS Graph API with app-scoped user id -

i use facebook ios. user's data without problem graph api. user's data app-scoped user id. try user's picture application crashed. tried use [fbrequestconnection startwithgraph:@"/me/picture" ...] , [fbrequestconnection startwithgraph:@"/(app id user's data)/picture" ...] still crashed. why? 2014-06-02 16:16:51.669 testapp[448:60b] -[nsnull datausingencoding:]: unrecognized selector sent instance 0x19f8068 2014-06-02 16:16:51.679 testapp[448:60b] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[nsnull datausingencoding:]: unrecognized selector sent instance 0x19f8068' *** first throw call stack: ( 0 corefoundation 0x018ac1e4 __exceptionpreprocess + 180 1 libobjc.a.dylib 0x0162b8e5 objc_exception_throw + 44 2 corefoundation 0x01949243 -[nsobject(nsobject) doesnotrecognizeselector:] + 275 3 corefound

ios - Not able to press an UIButton below UIView with corner radius -

Image
i have added view uiview , uibutton placed below view under left bottom corner. i've added corner radius uiview object way: self.myview.layer.cornerradius = self.myview.frame.size.width/2; self.myview.layer.maskstobounds = yes; now has shape of circle, , button visible. see picture below: the problem can't press button (it's not highlighting). how can make touchable? i know placing button front solve problem, know if there way press keeping below view. this question solved following link: allowing interaction uiview under uiview the recursive hittest 1 recommend using. accepted answer quite interesting (making views transparant touches or something).

pip - PIL installation error on Mac OS Maverics inside virtual env -

i trying install pil inside virtual below pip intall pil and got below error downloading/unpacking pil running setup.py egg_info package pil warning: '' not valid package name; please use only.-separated package names in setup.py installing collected packages: pil running setup.py install pil warning: '' not valid package name; please use only.-separated package names in setup.py --- using frameworks @ /system/library/frameworks building '_imagingft' extension cc -dndebug -g -fwrapv -os -wall -wstrict-prototypes -qunused-arguments -qunused-arguments -pipe -wno-error=unused-command-line-argument-hard-error-in-future -i/system/library/frameworks/tcl.framework/headers -i/system/library/frameworks/tk.framework/headers -i/usr/local/include/freetype2 -ilibimaging -i/opt/local/include -i/users/user/.virtualenvs/proj/include -i/usr/local/include -i/usr/include -i/system/library/frameworks/python.framework/versions/2.7/include/python2.7

android - Different menu for different Fragment Tabs -

description: 1) have activity contains 1 fragment. replace fragment menu. (first level) 2) 1 of fragments tabfragments. contains 1 fragments fragment can replace when user click on tab. (second level) i use android on 4.0. my question is: how can have "general" menu rootactivity + "normal" menu tabfragment + other menu fragment inside tabfragment, in actionbar ? in fact, when switch between fragment in firstlevel, menu updated correctly, when go second level, menu keep item other second level fragment. , when come other first level fragments still have menu second level fragment. edit : first level fragment (tabfragment) @override public void oncreateoptionsmenu(menu menu, menuinflater inflater) { inflater.inflate(r.menu.menu_intervention, menu); super.oncreateoptionsmenu(menu, inflater); // inflate menu below; } second level fragment: @override public void oncreateoptionsmenu(menu menu, menuinflater inflater) {

java - Detect doubleclick on cell of TableView JavaFX -

i trying detect doubleclick on random cell of tableview. detection of doubleclick not problem rather cell has been doubleclicked. table.addeventfilter(mouseevent.mouse_clicked, new eventhandler<mouseevent>() { @override public void handle(mouseevent event) { if (event.getclickcount() > 1) { system.out.println("double clicked!"); tablecell c = (tablecell) event.getsource(); system.out.println("cell text: " + c.gettext()); } } }); this how i'm building table: private void buildtable() throws exception { /*some initialisations etc*/ for(int i=0; i<result.getmetadata().getcolumncount();i++) { final int j = i; tablecolumn col = new tablecolumn(result.getmetadata().getcolumnname(i+1)); col.setcellvaluefactory(new callback<celldatafeatures<observablelist,string>,observablevalue<st

ruby on rails - How can set a default value in select tag? -

i have table , want set default value here table: |customers| |id| |name| 1 abc 2 def 3 ghi 4 jkl here controller: @customers.customer.all @customer_selected = customer.find(:all,:conditions=>['id=1']) here view, showing customers <%= select_tag "customer_id", options_for_select(@customers.collect {|t| [t.name,t.id]},params[:customer_id].to_i) %> i tried line select customer_id=1 default value (selected) <%= select_tag "customer_id", options_for_select(@customers.collect {|t| [t.name,t.id]},params[:customer_id].to_i),:selected =>@customer_selected.name %> i'm getting error undefined method `name' #<array:0x7f31d8098560> please can me ? one thing bear in mind if params[:customer_id] isn't there, equal nil, , nil.to_i gives 0. should fine shouldn't have customer id 0 it's aware of. i think should work: <% default_id

r - Predicting values and confidence intervals of predictions with the pcse package -

we ran ols regression using standard lm function. address issues panel data rerun analysis pcse package calculate panel corrected standard errors. got results , wanted generate graphic display predicted values , confidence intervals (as did normal lm regression standard ses) instead got error message: error in usemethod("predict") : no applicable method 'predict' applied object of class "pcse" any idea how pcse calculated se lm object class in order predict? you find our model , graph function below. thankful suggestions on how solve issue, is, find way come graphic displays want display greetz model: m.2 <- lm(piv~inter_x1+inter_x2+x3+x1+dumx2+x4+x5, data=dataset)) summary(m.2) m.2<- pcse(lm(piv~(x3*x1)+(x3*x2)+x3+x1+x2+x4+x5, data=dataset), groupn = dataset$c1, groupt = dataset$y) pred.val <- predict(m.2, newdata=dataset_2, se.fit=true, interval=c("confidence"), level=0.9) ## error in usemethod("pr

java - eclipse could not find main class -

Image
i trying run java program has 3 classes , .aj file. have main named main.class. when i'm trying run program says not find main class, though it's right there. eclipse trying run prob1.main doesnt exist. looking @ class commented package name. try recompiling class again , run it.

Singleton + nonstatic member - How to -

class scheduler:public kolejka { private: unsigned long real_time; scheduler(void) :real_time(0l){} scheduler(const scheduler &); scheduler& operator=(const scheduler&); ~scheduler() {} public: std::deque <kolejka*> kolejka; //... rest of methods, not important here static scheduler& getinstance() { unsigned long tmptime = 1; (int = 0; < 10; i++) { kolejka* tmp = new kolejka(tmptime + 1); kolejka.push_back(tmp); //error c2228: left of '.push_back' must //have class/struct/union //intellisense: nonstatic member reference must relative //to specific object tmptime++; delete tmp; } static scheduler instance; return instance; } }; the problem written in code, understand should other way, how? i'm asking little :) don't know how rid of problem, tried without pointers, problem same

c# - Merging two lines of code into one -

byte[] p = asciiencoding.ascii.getbytes(password); byte[] p = new byte[8] i need define size of array , keep first line of code @ same time. error when write them both, because p array defined twice. how can this? this code whole public string hasher(string password, string id) { try { byte[] p = asciiencoding.ascii.getbytes(password); byte[] a6 = asciiencoding.ascii.getbytes(id); byte totvector = 0; (int = 0; < 8; i++) { totvector = (byte)(totvector + p[i]); } byte[] a_concat = new byte[2]; a_concat[0] = (byte)((p[6] * totvector) % 256); a_concat[1] = (byte)((p[7] * totvector) % 256); byte[] = new byte[8]; (int = 0; < 6; i++) { a[i] = a6[i]; } a[6] = a_concat[0]; a[7] = a_concat[1]; byte[] h = new byte[8]; stri

css - data-layout="box_count" doesent display correct width -

Image
im struggling strange problem. when im using data-layout="box_count" on button, width of liked frame beeing cut when use data-layout="standard" absolutly correct. the code im using html5 , right out developer box. <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getelementsbytagname(s)[0]; if (d.getelementbyid(id)) return; js = d.createelement(s); js.id = id; js.src = "//connect.facebook.net/en_gb/sdk.js#xfbml=1&appid=504558953003252&version=v2.0"; fjs.parentnode.insertbefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> this images of how looks me, data-layout="box_count" data-layout="standard" any ideas? check css , make sure nothing prevents iframe being drawn plugin wishes. i had exact same problem few days ago , after filing bug report, facebook told me css style conflicting. some things shou