Posts

Showing posts from February, 2012

java ee - CDI event is always null -

cdi event null below exception. wondering whether can use cdi in general static methods. class should managed bean, in order make cdi event work? public class util { @inject @yellow static event<documentmessageevent> documentevent; public static list<atp> convertiball(string filename) throws resourceexception { ..... fireevent(page) } private synchronized static void fireevent(apvo page){ try { documentevent.fire(new documentmessageevent(page)); } catch (exception e) { log.error( "exception caught while firing documentmessageevent [" + page.getpagenumber() + "] - " + e.getmessage(), e); } } } error exception caught while firing documentmessageevent [2] - null: java.lang.nullpointerexception

android - Translating batch script to AHK for further development -

this part of batch script extract mtk android boot.img got stuck, shared dev. an ahk newbie myself, title says , got stuck loop , %boot_size% & cpio not extracting rmdisk folder... set /a n=0 :loop /f %%g in (bin\off2.txt) ( if !n!==1 ( set /a ofs1=%%g set /a n+=1 ) if !n!==3 ( set /a ofs2=%%g set /a n+=1 ) if !n!==5 ( set /a ofs3=%%g+4 set /a n+=1 ) if `%%g` equ `offset` ( set /a n+=1 ) ) %%i in (%1) ( set /a boot_size=%%~zi ) md %~n1 bin\sfk166.exe partcopy %1 -fromto 0x0 %ofs1% %~n1\kernel_header -yes bin\sfk166.exe partcopy %1 -fromto %ofs1% %ofs2% %~n1\kernel -yes bin\sfk166.exe partcopy %1 -fromto %ofs2% %ofs3% %~n1\ram_header -yes bin\sfk166.exe partcopy %1 -fromto %ofs3% %boot_size% %~n1\ram_disk.gz -yes bin\7z.exe -tgzip x -y %~n1\ram_disk.gz -o%~n1 >nul md %~n1\rmdisk cd %~n1 cd rmdisk %~dp0bin\cpio.exe -i <../ram_disk any appreciated... ;-) tia @

android activity - Objective C UIActivityView stops animating only after a delay -

i not sure why, reason uiactivityindicator spinner stays visible awhile after ask stop spinning. in app, check updates block method callback when check complete after point activity indicator hidden. nslog processed when block called, takes maybe 5-10 seconds indicator disappear. nothing going on in main far can tell, app sitting there. confused... [self showactivityindicator]; [[self schedulepack] checkforupdates:^(void) { nslog(@"done updating."); [self hideactivityindicator]; }]; the problem access ui element separate thread. try replacing [self hideactivityindicator]; with [self performselectoronmainthread:@selector(hideactivityindicator) withobject:nil waituntildone:no];

android - Cherry picks from gerrit overwritten by repo sync -

basically title problem. i'm building cyanogenmod while picking few different things gerrit. save them permanently local source. thought git add . or git add -a trick, picks seem overwritten anytime sync up. i've failed @ googling answer i'm coming same things telling me i'm doing correct. any here?

pulling links and scraping those pages in python -

i scrape links page. http://www.covers.com/pageloader/pageloader.aspx?page=/data/wnba/teams/pastresults/2012/team665231.html this gets links want. boxurl = urllib2.urlopen(url).read() soup = beautifulsoup(boxurl) boxscores = soup.findall('a', href=re.compile('boxscore')) i scrape every boxscore page. have made code scrape boxscore don't know how @ them. edit i guess way better since strips out html tags. still need know how open them. for link in soup.find_all('a', href=re.compile('boxscore')): print(link.get('href')) edit2: how scrape of data first link of page. url = 'http://www.covers.com/pageloader/pageloader.aspx?page=/data/wnba/results/2012/boxscore841602.html' boxurl = urllib2.urlopen(url).read() soup = beautifulsoup(boxurl) def _unpack(row, kind='td'): return [val.text val in row.findall(kind)] tables = soup('table') linescore = tables[1] linescore_rows = linescore.findal

javascript - Jquery function does not display animation -

i have created 2 functions allow me use them different css classes. var csselement; $(document).ready(function(){ expandbox (".orange"); minimizebox(".orange"); }); function expandbox ($csselement){ //when mouse rolls on $($csselement).mouseover(function(){ $(this).stop().animate({height:'485px'},{queue:false, duration:600, easing: 'easeoutbounce'}) }); } function minimizebox ($csselement){ //when mouse removed $(csselement).mouseout(function(){ $(this).stop().animate({height:'50px'},{queue:false, duration:600, easing: 'easeoutbounce'}) }); } however, function expandbox seems work. if hover mouse away .orange element box not contract. i want these animations appear functions plan use them few times within website. if put code below: $(document).ready(function(){ //when mouse rolls on $($csselement).mouseover(function(){ $(this)

php - Echo Facebook user name and photo? -

im trying make welcome page, facebook logged users, when visit webpage, can see name , photo, text "welcome our page, facebook_user_name" is possible or facebook don't have api's available this? thanks! :) you need create web application , register on fb. user needs grant access fb profile application. then, application may retrieve information users profile name or profile picture. you can php, java or javascript. here https://developers.facebook.com/docs/reference/apis/ but: long user has not granted acces actively his/her profile app, unable access data fb. so gimmick should be?

uac - ASP.NET Impersonation with Elevation -

i have asp.net application configured via web.config use impersonation this: <system.web> <identity impersonate="true" /> <authentication mode="windows" /> </system.web> the application needs perform administrative tasks. works fine if i'm logged on application user administrator , won't work (access administrative-only system resources fails) when logged in as, say, usera , does have administrative access on system. i suspect what's happening here uac stepping in. although asp.net app impersonating usera , when comes performing requiring elevation, fails, whereas running administrator fine, since user starts out elevated (never gets uac prompt if performing actions interactively in windows). incidentally, don't need network-level impersonation, don't believe should need delegation ? our company messed in house application , uac on 2 weeks. took 2 approaches issue. first, created security

webbrowser control - Windows Phone 8 SDK - Issue with screen locking, and application starting over -

i have application webbrowser control in it. when navigate in control step away bit, come (after unlocking screen due inactivity), first/original page shows again. how can maintain state of browser? define public property url in app.xaml.cs store url public uri url { get; set; } on webbrowser_loadcompleted event: save webbrowser.source property contains current loaded url above url property of application class. app app = application.current app; app.url = webbrowser.source; on application_deactivated event (send app background), save current app's state isolatedstorage isolatedstoragesettings settings = isolatedstoragesettings.applicationsettings; settings["url"] = url; settings.save(); on application_launching event (resume app), pull stored data back isolatedstoragesettings settings = isolatedstoragesettings.applicationsettings; url currenturl; if (settings.trygetvalue("url", out currenturl)) url = (uri)settings["url&quo

Android : Image button or button Highlighted with Effect when Pressed -

Image
here when pressed on these left , right arrow button @ time want see these type of effects on button. these same thing happens in iphone/ios default. can make type of effect? here mentioned pic want. here used xml files didnt got success. button_pressed.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"><shape> <gradient android:angle="180" android:centercolor="#657377" android:endcolor="#afffffff" android:startcolor="#ffffffff" android:type="linear"/> <corners android:radius="10dp" /> </shape></item> </selector> edit i used android:background="@drawable/button_pressed.xml" line did not got want exactly. tried : i used xml file per piyush's answer didnt succe

Javascript personalized function -

i need know how make jquery function , not css selectors, this: function getid( item ) { return document.getelementbyid( item ); } getid('elementid').firstfunction('property').secondfunction('property'); but don't know how send getid result firstfunction make getid() element , make secondfunction work, i've been trying prototype can't make work. you need ensure of methods want able chain accept same context output, in case dom element. so, firstfunction , secondfunction should both expect this dom element , should return dom element well. means, however, need modify built in dom element object , add own methods, generally bad idea . why jquery wraps in wrapper object contains methods available api. methods act on this (which must of same special object type) , return (usually modified) object of same type. check out lighter-weight example here: http://buildingwebapps.blogspot.com/2012/01/creating-lightweight-dom-j

jquery - How do I customise the ajax call when using form_tag's 'remote' in Rails? -

since ujs assigning event handler including jquery ujs source, how override of $.ajax settings specific call? so many examples use global methods. preferred method? (i asked earlier question thought customisation available through data-* attributes.) you can bind specific element's ajax success by: $element.bind("ajax:success", function(xhr, data, status){ dosomestuff(); });

java - Arraylist from class to array in jsp -

i kind of new jsp. have got php experience. i trying find way store arraylist data retrieved java class file array in jsp. jsp code: <c:foreach items="${mybean.status}" var="element"> <c:out value="${element}" /> </c:foreach> can store output retrieved class file array in jsp? i looking below. can done jstl? string []s = new string[count]; for(int i=0;i<=count;i++) { s[i] = element ; } thanks in advance. sure can.. can store @ once array.. did code using jstl + spring mvc , got + button (to add rows) , - button delete row (with javascript): <c:foreach items="${customer.contacts}" varstatus="i"> <tr> <td><form:hidden path="contacts[${i.index}].id" /> <form:input path="contacts[${i.index}].desc" type="text" /></td> <td><form:input path="contacts[${i.index}].number"

python - X509 certificates - maintaining certification path -

i'm working on x509 storage system python based program. certificates kept in postgressql database easy access. working ok, when each subject(user or ca authority) there 1 certificate. finding validation path easy, issuer field uniquely identify next certificate: usercert1(ca_cert_class1) -> ca_cert_class1(ca_cert_root) -> ca_cert_root(ca_cert_root) the problems starts when certificates renewed due expiration or other reason. 2 or more certificates have same subject. in case there more 1 possible certification paths. usercert1(ca_cert_class1) -> ca_cert_class1(ca_cert_root)(old)->.... -> ca_cert_class1(ca_cert_root)(new)->.... trying each combination not solution. removing expired certificates not solution, need them validate old digital signatures. question: how uniquely identify issuer cert within x509 certificate. guess, have x509v3 extensions. i'm not sure how use them. there x509v3 extension this. it's

how can I retrieve the latest 5 blog posts on the homepage of my docpad website? -

i have been testing docpad cms , want know how can display in homepage latest 5 posts blog. i have looked examples no luck far. do need plugin functionality? @ moment im using following modules: "docpad-plugin-marked": "~2.1.1", "docpad-plugin-stylus": "~2.3.0", "docpad-plugin-coffeekup": "~2.1.5", "docpad-plugin-cleanurls": "~2.4.3", "docpad-plugin-coffeescript": "~2.2.1", "docpad": "~6.32.0", "docpad-plugin-minicms": "~2.1.1" in docpad.coffee file under collections have posts: -> @getcollection('documents').findalllive({relativeoutdirpath:path.join('blog','post')},[date:-1]) i suppose key here ordering of collection date attribute ("date:-1") then in "eco" file can access collection using: @getcollection('posts'). will, of course, give posts - if want last n po

asp.net mvc - consuming json wcf service from view in mvc -

i trying store information of "user" table in wcf. , return in json format.when invoking service,i can see entities. question how call service in view.i have tried calling ajax shoots error message :( plzz help service.svc.cs namespace jsonwcf { [aspnetcompatibilityrequirements(requirementsmode = aspnetcompatibilityrequirementsmode.allowed)]// note: can use "rename" command on "refactor" menu change class name "service1" in code, svc , config file together. public class service1 : iservice1 { [webinvoke( method = "post", responseformat = webmessageformat.json, bodystyle = webmessagebodystyle.wrappedrequest )] public list<userdetails> selectuserdetails() { pasdatacontext db = new pasdatacontext(); list<userdetails> results = new list<userdetails>(); foreach (user u in db.users) {

java - Comparing two instances of XML for changes -

i have requirement want keep/track changes base xml document . have figure out efficient way keep track of changes done base xml structure , keep changes in different fomat(xml). input source can of both type sax , dom .how can achieve ? xmlunit has functionality: xmltestcase.comparexml() has both dom , sax versions. use detaileddiff list of differences between 2 xmls. convert diff object own representation if needed. xmlunit nice because can treat similar xml documents (such whitespace, sibling order, namespace prefixes) same if want.

java - Tomcat conection pooling for oracle DB using Jndi -

for project want use tomcat connection pooling oracle db using jndi , getting exception while executing below code: this exception getting: javax.naming.namenotfoundexception: name java: not bound in context @ org.apache.naming.namingcontext.lookup(namingcontext.java:803) @ org.apache.naming.namingcontext.lookup(namingcontext.java:159) @ javax.naming.initialcontext.lookup(initialcontext.java:392) @ com.iton.dbcp.dbutil.getconnection(dbutil.java:28) @ com.iton.dbcp.testservlet.doget(testservlet.java:35) @ javax.servlet.http.httpservlet.service(httpservlet.java:689) @ javax.servlet.http.httpservlet.service(httpservlet.java:802) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(appl icationfilterchain.java:252) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationf ilterchain.java:173) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrapperv alve.java:213) @ org.apache.catalina.cor

css - How do I make a div 100% of the viewport without using fixed positioning? -

how able make side bar 100% of entire page rather 100% of screen if div larger screen? i'd avoid using fixed positioning on side bar need contain large amounts of information require scrolling. body { height:100%; background:red; } #container { width:50%; margin:0 auto; height:1200px; background:white; } #left { position:absolute; float:left; height:100%; width:100px; background:black; } <body> <div id="left"></div> <div id="container"></div> </body> http://jsfiddle.net/jbmbr/2/ does achieve desire? http://jsfiddle.net/david_knowles/qftd5/ body{ height:100%; background:red; position:relative;} #container{ width:50%; margin:0 auto; height:1200px; background:white;} #left{ position:absolute; top:0; bottom:0; right:0; width:100px; background:black; overflow:scroll;}

ubuntu - nginx binary files not available linux -

hi have requirement should able install nginx in machine doesnt have internet connection below approaches tried created debian package source , tried installing downloaded source(tar file) , tried make , make install downloading source requires internet , make , make install not recommended the last option build nginx using binary file. not able find binaries nginx.am stuck here helpful

Accessing glassfish server from Android, emulator -

i have glassfish running on laptop. how can access real android device or emulator if want access using httpurlconnection have simply: httpurlconnection con = (httpurlconnection) ( new url(url)).openconnection(); con.setrequestmethod("post"); con.setdoinput(true); con.setdooutput(true); con.connect(); remember if use emulator localhost (127.0.0.1) corresponds 10.0.2.2. once have connection open can read , write using inputstream or outpustream. if use real device sure glashfish server visible smartphone.

jQuery or JavaScript to make DIV columns same height across across several containers -

Image
i have number of container divs each holding other column divs, have tried javascript script make half column divs resize @ same height. has worked means other half divs on page resize height. see screenshot below. half divs have same id in different containers. there jquery or javascript code can resize height across divs within each individual container? in screen shot top row 1 container, bottom row has div within different container. want bottom row div resize match height of tallest div within separate container. want workout several containers resize inner divs across page. part of code: <style> #page{width:85%; text-align:center;margin:auto;} #row{width:100%;background:yellow;margin-bottom:1%;} #container{height: auto;display: table;float:left;} #header{width:100%;background-color: rgb(0, 143, 213); height:50px;} #full{width:99%;margin:0.5%;background-color:skyblue;} .half{width:48%; margin:0.5%;padding:0.5%;float:left; background-color:#1589ff;display: table-c

hash - How to generate a hashed share link using flask -

i developing app, , want realize "share" function, can share content facebook or twitter. every content has own id, , want generate hashed link when "share" button clicked. say, if there essay a, , want share facebook, click "share facebook" button. should generate url, looks "http//my_app_backstage_server/essay/hash(id)", hash(id) not real id of content, hashed one. how can implement in flask framework? thanks! facebook button or twitter create link page on facebook (if don't want generate special links actions). need provide content pages access. you can generate random string or real hash , store on database (don't forget value must unique): import random import string hashlib import sha512 simple_chars = string.ascii_letters + string.digits def get_random_string(length=24): return ''.join(random.choice(simple_chars) in xrange(length)) def get_random_hash(length=24): hash = sha512() hash.upd

cordova - Emulator with debugging for Sencha Touch 2.2.0 + Phonegap -

i'm looking emulator sencha 2.2.0 + phonegap possibility debuging js. using ripple eumulator chrome, doesn't work curent sencha version. alternative emulator debugging code? (only windows). if run phonegap application on android emulator use weinre debugger similiar firebug or chrome devtools. on ios simulator can use safari webinspector. can connect browser running on device , webview inside app. this tutorial explains how use it.

c++ - Where to put #prama warning preprocessor directive to suppress warnings? -

i have many header files , source codes project in c++. wanted suppress warnings, therefore, came know #pragma warning preprocessor. able suppress 1 kind of warning, namely 4251, putting #pragma warning(push) #pragma warning(disable:4251) ...some declarations/prototypes #pragma warning(pop) in header file (utils.h) of corresponding source file(utils.cpp), warning have been shown. now, there kind of warning (4146), occurring in source file, clah.cpp. putting same code, mentioned, header file of file (clahe.h). however, compiler not able suppress warning ? can please tell me if doing somewhere mistake ? or, putting pragma statements wrongly ? thanks. p.s., beginner in c++. if have header has #pragma warning(push) on top , #pragma warning(pop) at bottom, after header parsed, warning settings reset. you'll need put pragma in cpp file well. #include "someheader.h" //this implementation file //some code translates, basical

extjs - how to wrap text of selectfield option in sencha touch 2 -

i'am trying display sencha touch 2 selectfield long option text text gets truncated ellipsis, very long option t... . how display couple lines in 1 option? code: { xtype: 'selectfield', options:[ { text: 'very long option wish splint 2 separate lines', value: 0 }, { text: 'another long option wish splint 2 separate lines', value: 1 } ] } i've tried using \n , <br/> not working. there 3 2 ways this. use labelwrap config option set true. avoid truncating text appears on selectfield initially. later when tap on selectfield; you've 2 choices. using picker or list . picker used if set true in usepicker config. if on tablet, desktop or mobile default list shown containing options. using labelwrap config not usefull if options displayed in list after tap on selectfield. use following css override avoid truncating. .x-list-item-label{ height: 100% !important; }

model view controller - Implementing a Registiration Form with JSF? -

i trying learn web development jsf myself. there planty of sources learn , having hard time binding them together. imagine have database table called user have columns: id, name, surname. using jpa in project have class @entity annotation, mapped class. have index.xhtml, in have registiration form username , password fields. when user clicks register button, should check if user same username exists, if not, should register user , redirct user welcome.xhtml. if registiration unsuccessful, user should stay in index.xhtml. my questions are: i have index.xhtml, , userentity.java. else? need registirationformbean @managedbean? , registirationformbean have registeruser method with. what? have registirationformcontrollerbean? should managedbean well? or need userregistirationbean? userregistirationservice? so how create mvc properly? you need 1 bean - there caveat, shouldn't use managedbean annotation anymore , move forward cdi technology, use @named . have getter

c# - Convert.ToString returns `System.Byte[]` and not the actual data as GROUP_CONCAT returns BLOB -

Image
i have 1 method calling mysql procedure. below part of procedure: select ar.alert_id alertid, ar.rule_id ruleid, ar.name rulename, ar.rule_type ruletype, ar.description description, (select group_concat(occured_event_id separator ', ') alert_rule_event alert_rule_id = ar.id) occuredeventids, alert_rule ar c# code: alertruleentity.alertid = convert.toint32(dtalertruleentitylist.rows[index]["alertid"]); alertruleentity.ruleid = convert.toint32(dtalertruleentitylist.rows[index]["ruleid"]); alertruleentity.rulename = convert.tostring(dtalertruleentitylist.rows[index]["rulename"]); alertruleentity.ruletype = convert.tostring(dtalertruleentitylist.rows[index]["ruletype"]); alertruleentity.description = convert.tostring(dtalertruleentitylist.rows[index]["description"]); alertruleentity.occuredeventids = convert.tostring(dtalertruleentitylist.rows[index]["

iphone - Timestamp as watermark on iOS video -

i want add timestamp watermark on recorded , capturing videos in ios app. here have got posted question , answer on stackoverflow.com how can add watermark in captured video on ios and other examples on web. but still watermark. trying achieve is if user started recording video on december 20, 2011 @ 17:32:24 , video 3 minutes long, timestamp @ beginning of video read 12/20/2011 // 17:32:24. time change video progresses , timestamp on last frame of video read 12/20/2011 // 17:35:24. i confused how can done? have tried lot not getting through. any guidance, highly appreciated. thanks

SQL Server 2008 Access Levels -

i've 3 stored procedures -- sp1, sp2 & sp3. sp2 , sp3 called within sp1 . if create dbrole (and user id) , provide exec access sp1 alone, , execute sp1 , sp2 & sp3 gets executed without permission issues? or need provide explicit execute access sp2 & sp3 ? you need access them all, may use execute 'some other user' gain privileges other procedures: msdn documentation

android - Why Binder returns null when i bind Service in activity? -

there mainservice , has data member binder , , function member onbind() return binder. in mainactivity, has member binder too, , has member conn class serviceconnection, , override onserviceconnected() function asign value binder.i bind service : bindservice(intent, conn, service.bind_auto_create), post function in oncreate().however, result binder null.

connect - node.js request session property -

i try learn, how build app node.js, express , backbone. user authentication use cookie , session middleware, app.use(express.cookieparser()); app.use(express.session({secret: "socialnet secret key", store: new memorystore()})); now, if request comes in, can use session property req.session i encounter code snippet book app.post('/login', function(req, res) { console.log('login request'); var email = req.param('email', null); var password = req.param('password', null); if ( null == email || email.length < 1 || null == password || password.length < 1 ) { res.send(400); return; } account.login(email, password, function(success) { if ( !success ) { res.send(401); return; } console.log('login successful'); req.session.loggedin = true; res.send(200); }); }); look @ req.session.loggedin, loggedin property comes from? can add own request session prop

maven repository and dependencies download -

i've used standard maven command mvn clean install , according logs (in same console window) dependencies loaded , artifacts installed dedicated directory maven repository p:\.m2\repository . maven build process succeeded. i'm using maven 2.2.1 here problem. repository directory empty. i'm missing? thanks. some reasons: someone deleted folder (or it's content) maven installed files in different place i suggest run mvn again option -x . running mvn clean -x should enough see paths uses locate dependencies ( install download many more files need see one). note: p:\ sounds network drive. if home folder (i.e. not shared other people), isn't idea since cause lot of network traffic , make builds slow , brittle (in case of network problems).

How to update the old database file with the new database file in android? -

i having application uses sqlite .db in that. having existing database file in application . have have make connection , should download new .db file , have replace existing .db new .db file had downloaded. i keeping .db file in assests folder of application . people saying readable folder , cant delete file folder . so please let me know how solve problem . you can change databasehelper class constructor updating database name,version number important. public databasehelper(context context, string dbname, null, int dbversion) { super(context, dbname, null, dbversion); // todo auto-generated constructor stub } instead of using this public databasehelper(context context) { super(context, dbname, null, dbversion); // todo auto-generated constructor stub }

How can I track tweets from a particular city and store in a MongoDB via python? -

i write piece of code grabs tweets particular location (e.g. city) , puts them in mongodb via python. complete newcomer programming, have managed track particular hashtags twitter , store them in mongodb using following piece of code: 01 import pycurl, json 02 import pymongo 03 04 stream_url = "https://stream.twitter.com/1/statuses/filter.json" 05 words = "track=#occupywallstreet" 06 user = "myuser" 07 pass = "mypass" 08 09 def on_tweet(data): 10 try: 11 tweet = json.loads(data) 12 db.posts.insert(tweet) 13 print tweet 14 except: 15 return 16 17 pymongo import connection 18 connection = connection() 19 db = connection.occupywallstreet 20 conn = pycurl.curl() 21 conn.setopt(pycurl.post, 1) 22 conn.setopt(pycurl.postfields, words) 23 conn.setopt(pycurl.httpheader, ["connection: keep-alive", "keep-alive: 3000"]) 24 conn.setopt(pycurl.userpwd, "%s:%s" % (user, pass)) 25 conn.setop

How to display VAST ads in my android app? -

i display video ads in app based on vast. can please guide me on how ? you can use vast ad supporting advertising sdk showing vast video ads. or you can parse vast response in application can play video link in android native video player. in case have fire vast ad tracking events.

android - Insertion to SQLiteDatabase -

i wrote code: // currentfriendstable // --------------------- //| _id | email | uname | // --------------------- // ffriend class class ffriend { string email, uname; // getter , setter } // add single friend database public long addfriend(ffriend friend) { contentvalues values = new contentvalues(); values.put(currentfriendstable.column_email, friend.getemail()); values.put(currentfriendstable.column_uname, friend.getname()); return database.insert(currentfriendstable.table_name, null, values); } // add list of friends database public void addlistoffriends(list<ffriend> listoffriend){ int lenghoflist = listoffriend.size(); (ffriend friend : listoffriend) addfriend(friend); } i have 2 question here: when add values table using database.insert() function, adding _id automatically ? (i defined column _id primary key autoincrement) is scenario of calling addfriend(ffriend friend) function in addlistoffriends(list<ffriend&g

c# - Size of struct with generic type fields -

i want estimate size of array of structs containing generic type parameters, in case dictionary entry struct. need size of struct. struct entry { int hash; int next; tkey key; tvalue value; } how can size in bytes of struct? edit it seems using marshal.sizeof problematic. passing type of struct raise exception saying argument can't generic type definition. if instead call overload takes instance, e.g. marshal.sizeof(default(entry)) work if both generic type arguments value types. if generic arguments e.g. <int, object> exception thrown dictionary`2+entry[system.int32,system.object]' cannot marshaled unmanaged structure; no meaningful size or offset can computed. it sounds il sizeof instruction need. sizeof instruction used c# sizeof operator behind-the-scenes, il version has fewer restrictions reason. the ecma cli specification (partition iii, section 4.25) has description of sizeof instruction: returns size, in

javascript - HTML DOCTYPE Syntax error on js files -

i have 5 errors on login page syntaxerror: syntax error <!doctype html> on 5 js files, when checked files, found in non public directory. how can ignore these files on login page or add authorization these 5 files ? thanks there several things do: if need files on login-page: move files public folder add location section web.config make folder public if don't need them on login-page: make sure don't reference files if user not authenticated. example in view: @{ if (user.identity.isauthenticated){ <text><script src="..." /></text> } }

android - Unable to dismiss intent activity in libgdx -

i have developed game on libgdx in trying share text content using intent . intent activity shown when click on share button in game. problem activity keeps popping when click button. unable dismiss activity , go game screen.the android code below, public class mainactivity extends androidapplication implements androidintent{ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); androidapplicationconfiguration cfg = new androidapplicationconfiguration(); cfg.usegl20 = true; cfg.useaccelerometer = true; cfg.usecompass = false; initialize(new mygame(this), cfg); } @override public void share() { log.d("magicwords", "sharing game"); intent intent = new intent(intent.action_send); intent.settype("text/plain"); intent.putextra(intent.extra_text, "this status line"); startactivity(intent.crea

symfony - Symfony2 - Add a required checkbox to an Image Form Field -

i need form display checkbox field, when user selected image upload in image form field , make required. the user has confirm, claims rights on picture. i've tried make custom validator, think won't work scenario. thank you if understood well, 2 solutions: you via html . user have check after uploading picture. if don't checked box, won't submit form. with boolean in entity, set required=true , display other field. but, result in database true.. ( useless )

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

i have detailsview control on page used edit various fields of record, works in respect. i looking way add 1 column (and if works, why not more) right, absolutely read-only, show same fields of record comparison purposes. i aware there no obvious way such thing out of box detailsview . have looked other controls (transposed gridview , recommended formview , listview ), nothing satisfies. have special data binding setup using detailsview , can't out of without losing features. anyone on how "hack in" additional columns (for display only) on detailsview ? the solution have now, use second detailsview , visible set false in aspx. in code, make sure databind hidden detailsview hosts data third column first, initial detailsview named itemdetails . and in item created event, pass third column html rendering of hidden controls (in last code block) : protected void itemdetails_itemcreated(object sender, eventargs e) { if (dataite

javascript - When asm.js is faster than normal JS code, why should I write new code in JS? -

emscripten generate faster code c/c++ js code wrote hands, means should write new code in c/c++ , compile them run on web? i read emscripten faq, says "by means write new javascript code.", why that? asm.js not faster way execute javascript-esque code. faster way run code reduced level of abstraction of machine code. seem overestimate gains: if let js developers write c++ if it's js, end fugly code that's not fast c++ , flawed in other ways too. many potential bottlenecks, such dom manipulation , network latency, aren't affected @ how fast code running. for many programs, speed faster language implementation dwarfed speed of high-level optimizations. in other words, doing work faster nice, not doing @ faster. going route has significant downsides well: you have throw away working code, , re-write (including bugs) in language of team won't know well, if @ all. as of now, technology still in infancy. wouldn't bet company, or impor

eclipse - Unity3D messed up my Android resources? -

i have been developing game android while eclipse , have had little problems asynctasks or threading in general. while ago installed unity3d , after trying few things returned android coding , published new build of game. now have gotten crash reports weird stack trace. 1 below, that's 1 of many different ones have gotten: java.lang.runtimeexception: error occured while executing doinbackground() @ android.os.asynctask$3.done(asynctask.java:231) @ java.util.concurrent.futuretask$sync.innersetexception(futuretask.java:305) @ java.util.concurrent.futuretask.setexception(futuretask.java:156) @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:339) @ java.util.concurrent.futuretask.run(futuretask.java:169) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1119) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:612) @ java.lang.thread.run(thread.java:1050) caused by: java.lang.outofm

iphone - Situation in which a hitTest-confirmed view with a gesture recognizer won't receive the event? -

`i've got view uiimageview subview. main view has single tap gesturerecognizer on works 99% of time. every once in while, gesture recognizer seems fail, , event gets pushed stack next responder. i've added breakpoint in hittest method of top view, , hit test method correctly returns inner-most uiimageview in cases, including when event goes wrong place. in situation view result of hittest not event passed gesture recognizer? i've printed out debug code hittest breakpoint when gesture selector doesn't called: (lldb) po u $2 = 0x20854520 <uiimageview: 0x20854520; frame = (0 0; 61 62); opaque = no; layer = <calayer: 0x208e7670>> (lldb) po [u superview] $0 = 0x1fd225e0 <hotspotview: 0x1fd225e0; frame = (303 663; 61 62); gesturerecognizers = <nsarray: 0x2082b850>; layer = <calayer: 0x1fd15af0>> (lldb) po ((hotspotview *)u.superview).gesturerecognizers $1 = 0x208bc940 <__nsarrayi 0x208bc940>( <uitapgesturerecognizer: 0x20

windows phone 7 - How do I bind TwoWay between a CheckBox in a UserControl and the ViewModel in the wider scope? -

i have usercontrol has checkbox on it. when consume usercontrol on main xaml page, i'd twoway bind property on control property on viewmodel e.g. <myusercontrol btnisblacklisted="{binding isblacklisted, mode=twoway}" /> when isblacklisted changes, i'd checkbox change , vice-versa. here have, public static readonly dependencyproperty btnisblacklistedproperty = dependencyproperty.register("btnisblacklisted", typeof(bool), typeof(myusercontrol), new propertymetadata(false, new propertychangedcallback(btnisblacklistedpropertychanged)) ); private static void btnisblacklistedpropertychanged(dependencyobject d, dependencypropertychangedeventargs e) { // ... here ... } public bool btnisblacklisted { { return (bool)getvalue(btnisblacklistedproperty); } set { setvalue(btnisblacklistedproperty, value); } } my usercontrol has check

sql - Get the visitors that have only revisited one day or more -

i have sql query visitors have been online more once since first visit: select count(date_lastactive) visitors date_lastactive != '0000-00-00 00:00:00' because of simpleness, every revisited visitors listed. don't want that! want visitors have been revisited website 1 day , more (2 days, 3 days, 5 month, 8 months, 2 years, , on not under 1 day such 4 hours or that). how can accomplish this? thanks in advance :) t-sql (ms sql server syntax): select count(some_visitor_id) visitors datediff(d, date_lastactive, date_firstvisit) > 1 not 100% sql dialect freshprinceofso using, guess it'll this: select count(some_visitor_id) visitors date_lastactive >= date_add(date_firstvisit, interval 1 day)`

Use Jquery to remove first URL in a double URL link -

i trying remove first url in double url link such as: http://somewebsite.com/something/#/###/#/http://someotherwebsite.com/ after page loads. afterwards, like: http://someotherwebsite.com/ where # = numbers sometimes first website .org or.net. tried searching , tried ideas never remove first full link. it's not pretty, @ least on correct track: links = 'http://somewebsite.com/something/#/###/#/http://someotherwebsite.com/' links = links.split('http') console.log(links[2]) that give second link (removing 'http', there can add on , need. it's not pretty, doesn't sound looking elegant solution if want know more split() function, splits (hence name) string based on input (the 'http' in our case). there can traverse through or whatever want list.

python - How can I make a white box in PyQt? -

Image
i have pyqt application has widget called deck class deck(qtgui.qwidget): def __init__(self, filename, parent): super(deck, self).__init__(parent) self.setminimumsize(100, 150) self.setstylesheet('background-color: white;') label = qtgui.qlabel("deck", self) label.show() i expected deck widget white, under label, although accepts clicks on 100x150 area , adjusts hbox:s size. edit: surrounding layout. import sys pyqt4 import qtgui app = qtgui.qapplication(sys.argv) #import qt4reactor #qt4reactor.install() deck import deck class duel(qtgui.qwidget): def __init__(self): super(duel, self).__init__() toparea = qtgui.qhboxlayout() toparea.addstretch(1) d = deck(sys.argv[1], self) d.show() toparea.addwidget(d) bottomarea = qtgui.qhboxlayout() d = deck(sys.argv[2], self) d.show() bottomarea.addwidget(d) bottomarea.addstr

java me - GridFieldManager Blackberry align fields -

i have gridfieldmanager whith 3 columns , want align content this: |title left | title center | title right| the problem i'm using richtextfield instead of labelfield because want text of each title grap this: |title left | title center | title right | |is wrapped | wrapped | wrapped | if use richtextfield instead of labelfield, then, the alignment ignored. code: public class customgridfieldextends gridfieldmanager { private int numcolumns = 3; private int margin = 5; public customgridfield(string lefttext, string centertext, string righttext) { super(1, 3, gridfieldmanager.use_all_width); setpadding(0, margin, 0, margin); int columnwidth = (display.getwidth() / numcolumns); (int = 0; < numcolumns; i++) { setcolumnproperty(i, gridfieldmanager.fixed_size, columnwidth); } // leftmost text richtextfield leftlabel = new richtextfield(lefttext){ protected v

python - why can't x[:,0] = x[0] for a single row vector? -

i'm relatively new python i'm trying understand seems basic. create vector: x = np.linspace(0,2,3) out[38]: array([ 0., 1., 2.]) now why isn't x[:,0] value argument? indexerror: invalid index it must x[0]. have function calling calculates: np.sqrt(x[:,0]**2 + x[:,1]**2 + x[:,2]**2) why can't have true regardless of input? many other languages, independent of there being other rows in array. perhaps misunderstand fundamental - sorry if so. i'd avoid putting: if len(x) == 1: norm = np.sqrt(x[0]**2 + x[1]**2 + x[2]**2) else: norm = np.sqrt(x[:,0]**2 + x[:,1]**2 + x[:,2]**2) everywhere. surely there way around this... thanks. edit: example of working in language matlab: >> b = [1,2,3] b = 1 2 3 >> b(:,1) ans = 1 >> b(1) ans = 1 perhaps looking this: np.sqrt(x[...,0]**2 + x[...,1]**2 + x[...,2]**2) there can number of dimensions in place of ellipsis ... see what python ellipsis

c++ - allocated but not initialized -

i have met allocated not initialized issue. here part of code: void test2(vector<string> names, int num) // test { const char **tmp = new const char *[num]; // issue happends here. for(int = 0; < num; ++) tmp[i] = names[i].c_str(); // not inialization??? //call function using tmp delete []tmp; } well in line 3 of code, got issue: assigning: "tmp" = "new char const *[num]", allocated not initialized. i believe got confused 2-d arrays allocations , initialization. think tmp const char * array, , want convert vertor const char **; then in code, right use new , delete here? i know if 2d array int* , if want assign value it, need new int [num], loop new int[]; how case here? can me piece of code? don't use const in situation because you're allocating data post-initialization.

asp.net - Simplemembership - adding email field and use as login-name -

i trying 2 things here: 1. adding email field (default)userprofile table. works charm. users can register both username , email. 2. change login use email instead of username, works charm. here problem. above works when seperate them, use both of them the registration process fails following error message: cannot insert value null column 'username', table 'opdb.dbo.userprofile'; column not allow nulls. insert fails. websecurity.createuserandaccount(model.username, model.password, new { email = model.email }); websecurity.login(model.email, model.password); i more or less following guide found here , in comments section see others having same problem, however, solution not set username field allow nulls stated in replies. the strange thing works long don't use both together. ideas? drives me crazy! thanks in advance edit : order of columns in database? field used identification needs first column in table? if want email ident need first

grails - XmlSlurper parsing a query result -

i have query bring cell in table has xml in it. have can spit out in cell without delimiters. need take each individual element , link them object. there easy way this? def sql def datasource static transactional = true def pulllogs(string username, string id) { if(username != null && id != null) { sql = new sql(datasource) println "data source is: " + datasource.tostring() def schema = datasource.properties.defaultschema sql.query('select userid, audit_details dev.audit_log t xmlexists(\'\$s/*/user[id=\"' + id + '\" or username=\"'+username+'\"]\' passing t.audit_details \"s\") order audit_event', []) { resultset rs -> while (rs.next()) { def auditdetails = new xmlslurper().parsetext(rs.getstring('audit_event_details')) println auditdetails.tostring } } sql.close() } } now give me cell audit details

MySQL Select customers without an active order with JOIN -

so, trying select customers inactive mysql join. have following statement selects customers active service order. select distinct u.* users u inner join orders o on o.assigned=u.id , o.status!=0 this works fine. trying select customers had order order became deactivated (o.status equate value 0). have following statement (which close) returning customers still have active order, have order deactivated. select distinct u.* users u inner join orders o on o.assigned=u.id , o.status!=1 so in layman term, customer can have multiple service orders. every service being independent 1 another, want select customers deactivated. example: susan has 2 service orders, 1 activated , other deactivated. right now, susan being populated in list of users deactivated , incorrect. customers orders deactivated. thank you! select u.* users u left join orders o on o.assigned=u.id , o.status!=0 o.assigned null; or that

asp.net mvc - Telerik MVC Grid, rebind after ajax delete from custom command? -

i've got telerik mvc grid , trying have grid rebind after deleting item. here grid: @(html.telerik().grid(model.item).name("items").sortable().scrollable(x => x.height(400)).filterable().pageable(x => x.pagesize(20)) .pageable() .columns(columns => { columns.bound(x => x.equipment.location.building.name).title("building"); columns.bound(x => x.equipment.location.room).width(150); columns.bound(x => x.number).title("number").width(150); columns.command(commands => { if (model.canviewhistory) { commands .custom("viewhistory") .text("history") .buttontype(gridbuttontype.text) .sendstate(false) .dataroutevalues(x => x.add(y => y.id).routekey("id")) .action("index", &