Posts

Showing posts from August, 2013

liferay - How can I fetch the existing table data in aportlet -

i trying create user site admin have created portlet has basic user details form , in action class called userlocalserviceutil.adduser() . values inserting db in user_ . want display list of created users site admin how can that? have following queries. 1) how can fetch values user_ in portlet. need create service builder or there api methods fetch values user_ table? 2) want display users list created site admin in portlet. don't want display whole company list of users. how can achieve this? suggest me references or guidelines this. your appreciated. for q1 : http://cdn.docs.liferay.com/portal/6.1/javadocs/com/liferay/portal/service/userlocalserviceutil.html#getusers(int , int) this might you. don't need service builder that. create simple liferay mvc portlet , call relevant methods. for q2 : don't think possible api methods. can set expando variable user @ time of creation site-admin. , @ time of fetching users, can cross-check value of field

How to Auto fill field from another Table in Access 2007 Depend on previous filled -

i have 3 tables [ types ] > have 1 field called type . [ vehicles ] > have 2 filed vehicleno , type (lookup types table . [ diesel ] > have many field mean vehcileno , type choose vehicles table. when enter new row in diesel choose vehicleno write type again . is there way make auto fill for example in [ vehicles ] table have vehicleno = 58254 type = flat traler when enter row in diesel i choose example vehicleno 58254 , need type field fill automatically word flat traler enter other field is possible in access 2007? you want triggers in database. here information that: http://en.wikipedia.org/wiki/database_trigger access not have triggers. there workaround using forms. bind tables form , put vba-code in afterupdate-event of textboxes vehicleno. does or need more information implementation?

android - How to make a call with Qt directly from the application? -

i want implement dialer-feature in app. actually, it's done, works way don't want to. when button pressed, native dialer opens , waiting pressing button . possible call directly without double pressing? here's code : button { id: callbutton anchors.centerin: parent text: 'make call' onclicked: qt.openurlexternally('tel:+77051085322') } whereas in ios call can issued directly , same not apply android. overcome problem can define c++ class wrapper handles call, depending on current os. instance of class registered context property , directly used in qml. inside class can exploit android native apis provide automatic dialing feature via intent action action_call (but remember there restrictions in using it ). typically in android write: intent callintent = new callintent(intent.action_call); callintent.setpackage("com.android.phone"); // force native dialer (android < 5) callint

asp.net mvc - Azure request routing for a blog -

i'm using azure host mvc5 website at mysite.com i want host wordpress site at mysite.com/blog but, security reasons, don't want host mvc5 app , wordpress on same instance. i don't want go down route of seperate subdomain blog. how should go this? can azure application request routing sort of thing?

asp.net mvc - How can i display the file name in the Edit View? File name is stored in the images Folder and also in database -

view is @html.textboxfor(model => model.choosefile, "", new { @class = "span12", placeholder = "choose file",type="file"}) when edit need file name picked , stored in database. image stored in folder image. i need give download option same. please me. you have few options if file size small, read bytes db , send file result mbc controller if file large, try streaming. you can try this public filecontentresult getfile(int id) { sqldatareader rdr; byte[] filecontent = null; string mimetype = "";string filename = ""; const string connect = @"server=.\sqlexpress;database=filetest;trusted_connection=true;"; using (var conn = new sqlconnection(connect)) { var qry = "select filecontent, mimetype, filename filestore id = @id"; var cmd = new sqlcommand(qry, conn); cmd.parameters.addwithvalue("@id", id); conn.ope

asp.net mvc - Why should we use HandleErrorAttribute? -

i new mvc. reading error logging in mvc. i came know handleerrorattribute . have question regarding that. let's placed handleerrorattribute in action . <!-- language: c# --> [handleerror(view = "error")] public actionresult index6() { throw new exception("something terrible happened."); return view(); } and turned on custom errors in web.config <customerrors mode="on"> </customerrors> now if undandled exception occured in "index action", show error.cshtml in "views/shared" folder. but can have same behavior setting configuration under customerrors section in web.config. <customerrors mode="on" defaultredirect="~/error"> <error statuscode="404" redirect="~/error/notfound" /> </customerrors> just mention, have "errorcontroller" "index" action returns "views/shared/error.cshtml" view. so, ques

javascript - Error Unexpected Token ILLEGAL with read from img attribute -

i try read src of image here :- <div class="featured_preview"> <img src="ggat/wp-content/uploads/2015/03/11-192x236.jpg" width="300"> </div> by code :- jquery(document).ready(function() { jquery(".open-popup-link").click(function () { alert(jquery(".featured_preview img").attr("src"‏);); }); }); why show me error :- uncaught syntaxerror: unexpected token illegal change this: alert(jquery(".featured_preview img").attr("src"‏);); // note semi colon by: alert(jquery(".featured_preview img").attr("src"‏));

database - Multi-Line Excel to New Row Per Line -

i have large excel file, 5000 rows sample of upload here . the file contains data employees following: first column: employee name second: employee id columns 3-7: experiences (multiline values) 3: career name 4: rank 5: 6: 7: reason leaving columns 8-13: managerial jobs columns 14-17: education columns 18-26: courses now each employee have many multi line values experiences, managerial jobs, education , courses, in other words, have many courses 1 @ each line on same row now needed following: excel macro (vba): to move every employee (row) header new worksheet in same workbook, , name sheet employee id located in column 2 (the code of ready) for each multi line value (education example), should add each line in separate row if possible sort every multiline values date, older newer. , thats it, in attached excel file, i've made first employee, possible repeat operation 5000 employees, if not, database suggest use, can microsoft access it? whilst exce

sh - Parsing string for retrieving date in UNIX and freeBSD -

i have string in following format: yyyy-mm-dd how can convert date on unix and freebsd? know is date -d $var +'%y-%m-%d' on gnu and date -jf $var +'%y-%m-%d' on freebsd but if script (in sh, not in bash) have work on both os? how can combine it? because date command different kind of solution might if detect correct platform: #!/bin/sh var='2014-03-15' platform='uknown' str="$(uname)" if [ "$str" == 'linux' ]; platform='linux' elif [ "$str" == 'freebsd' ]; platform='freebsd' fi then according platform can do: if [ "$platform" == 'linux' ]; date -d "$var" +'%y-%m-%d' elif [ "$platform" == 'freebsd' ]; date -jf "%y-%m-%d" "$var" +'%y-%m-%d' fi also think missing format command: date -jf $var +'%y-%m-%d' i think should be: date -jf "format"

c# - Creation of Wifi Connection With Native Wifi API -

how can establish wifi connection native wifi api? how can share internet via established wifi in c#? try use managed wifi api , can connect existing wifi couldn't create new one.

javascript - Angular Tour directive issues -

i have used below tour directive. <tour step="currentstep" <span tourtip="few more steps go." tourtip-next-label="close" tourtip-placement="bottom" tourtip-offset="80" tourtip-step="0"> </span> </tour> this tour directive q 1: how can make whole item click able ? in other words if user clicks ,it should open popup or that. q 2: clicking anywhere on page should close tour item if open ? any highly appreciated. you utilize ng-if directive in collaboration custom directive (i've called toggler) set value on ng-if depends accordingly needs, example: <tour toggler step="currentstep" <span ng-if="open" tourtip="few more steps go." tourtip-next-label="close" tourtip-placemen

How to compare 2 button backgrounds in Android? -

so have 2 buttons (or imagebuttons or can use background) same background. want method check whether have same background or not. i tried 2 buttons same background , button1.getbackground(); button2.getbackground(); but both returned different values . any other methods? the getbackground() method returns drawable object. now compare 2 drawable objects best use getconstantstate() method obtain them. should work. button1.getbackground().getconstantstate().equals(button2.getbackground().getconstantstate())

api - Live tracking sytem -

i looking build own custom poker tools. starting small getting maths right. have built simple odds calculater reaaly need automated rather user input. if somone can me hear can maybe explore hud tracking or self analysis of own game. have read ocr, screen scraping , api dont no how use these , weather or not can grab numbers , use tham equations. greatfull if somone please. the term "poker tools" pretty wide, depends lot on want do. depend on poker venue working on, difficulty getting information 1 can vary quite lot. now, if want holdem manager, gives statistics calculated using lot of older hands, easiest way read poker venue log, can find actions. these files it's easy calculate typical statistics vpip or pfr of players have played agains , yourself. if want real data statistics (about current hand playing) things complicated. said 1 option use ocr, need lot of effort implemented, need take automatic screenshots , find relevant data in them, number of pl

zip - vb.net Download file and unzip it -

i want download file .zip in vb, , decompress when download have reached 100%, here code download file: wc.downloadfileasync(new uri(http://google.zip), "c:\documents , settings\all users\documents\google.zip") sw.start() what need add decompress google.zip when download have reached 100%? dim saveas string="c:\documents , settings\all users\documents\google.zip" dim theresponse httpwebresponse dim therequest httpwebrequest try 'checks if file exist therequest = webrequest.create(fileurl) 'fileurl zip url theresponse = therequest.getresponse catch ex exception 'could not found on server (network delay maybe) exit sub 'exit sub or function, because if not found can't downloaded end try dim length long = theresponse.contentlength dim writestream new io.filestream(saveas, io.filemode.cre

How to make updater for GameMaker Game -

i using gamemaker . game working on need updated later on. how create updater people don't have download updated version. person playing can push button , game update. i have done it. i created file on server, can every server. in file said: [version] version = 1010 so newest version 1.0.1.0. there function gm_version check current version of game, ot return 1.0.0.1, don't know why done this. so, in order fix this, create event: //re-order version , delete points version3 = string_replace(gm_version,'.','') point1 = string_pos('.',version3) version2 = string_delete(version3,point1,1) point2 = string_pos('.',version2) version1 = string_delete(version2,point2,1) string1 = string_copy(version1,point1,point2 - point1) version0 = string_delete(version1,point1,point2 - point1) version_local = version0 + string1 //delete old file , serverfile version_online = 0 got = 0 file_delete("your file") file = http_get_file("

email - Adding attachment in android using Java Mail -

i trying add attachments email send using javamail. can send email without attachment error when try attach file. 03-28 18:07:36.735: e/sendmail(6703): null 03-28 18:07:36.735: e/sendmail(6703): java.lang.nullpointerexception 03-28 18:07:36.735: e/sendmail(6703): @ com.example.email.gmailsender.addattachment(gmailsender.java:95) 03-28 18:07:36.735: e/sendmail(6703): @ com.example.email.mainactivity$1$1.run(mainactivity.java:28) here method use attach file. public void addattachment(string filename) throws exception { bodypart messagebodypart = new mimebodypart(); datasource source = new filedatasource(filename); messagebodypart.setdatahandler(new datahandler(source)); messagebodypart.setfilename(filename); _multipart.addbodypart(messagebodypart); message.setcontent(_multipart); } and call in main activity. sender.addattachment("/storage/extsdcard/dcim/camera/photo.jpg"); do think there wrong path of fil

c++ - reference to a non-existent variable will be a error, but why doesn't this cause any error? -

Image
i got question function below may result in run time error. why? code : int& sub(int& , int& b){ int c = - b ; return c ; } how can write code in main there run-time error?? thanks!! as it's undefined behaviour, there no guaranteed portable error. but here , example, betting on gfact nested calls produce referred result overwritten. int = 5, b=4, c=2; int r = msub(a, msub(b,c)); cout << "should 3: "<<r<<endl; // output depends on compiler. received 0, incorect ! here online demo . needless such errors extremely nasty ! happens here ? the compiler first calls msub(b,c) resutl temporary reference former local variable on stack. @ moment, there's high probability, computed value of 2 still there, if temporary variable doesn't exist anymore. then compiler calls msub(a, ...) using reference. call change stack, overwriting value referred to. so there's no segfault, no horror (in simple compiler s

java - Send sms - body not transmitted in Lollipop -

the following lines should open sms dialog in order send sms. on api 19, body transmitted dialog, on lollipop, remains blank. intent sendintent = new intent(intent.action_view); sendintent.settype("vnd.android-dir/mms-sms"); sendintent.putextra("sms_body", bodysms); context.startactivity(sendintent); any idea ? with of commonsware, did trick : intent sendintent = new intent(intent.action_view); sendintent.settype("vnd.android-dir/mms-sms"); sendintent.putextra(intent.extra_text, bodysms); context.startactivity(sendintent);

javascript - Stop and Reset Harvest's Tick Counter jQuery Plugin -

anyone knows how stop , reset harvest's tick counter jquery plugin? want stop counter on specific number , reset primary start number. you can checkout code here . html markup: <span class="tick tick-flip tick-promo">5,000</span> jquery logic: <script type="text/javascript"> $(document).ready(function () { startcounter(); }); function startcounter() { $('.tick').ticker({ delay: 1000, incremental: 1, separators: true }); } var mycounter = setinterval(function resetcounter() { var lscurrenttick = $('.tick').find('.tick-new').text(); if (lscurrenttick > 5010) { $.fn.ticker.stop(); } }, 1000); </script> i had read code figure out. here demo $(startcounter); function startcounter() { var tickobj = $('.tick').ticker({ delay: 1000, incremental: 1, separators: true })[0]; setinterval(functi

Blade in laravel 4.2 not working in @elseif statement -

i trying render javascript codes using blade template in laravel 4.2 , unable render inside @elseif working in @if statement . can verify flaw in laravel 4.2 or error. @if ( $page == 'loginpage' ) @yield('body') {{ html::script('js/jquery.min.js') }} //works here @elseif ( $page == 'resetpage' ) @include('panel') @yield ('body') @section('js') {{ html::script('js/jquery.min.js') }} //cannot render here neither yielded section. @show @endif only html::script in @if statement works. granted. in advance. edit: solved problem have overrided section other sections. sorry bother all.

php - CodeIgniter: Add css link -

i trying use php framework codeigniter php project. never used before. according documentation activated helper url , included css link shown below: $autoload['helper'] = array('url'); <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>public/css/bootstrap.min.css"/> <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>public/css/style.css"/> unfortunately page not able load css. if put compiled css link page able load it. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> base_url() not add trailing slash. need forward slash in between php code , public in link href. say base url /htdocs/website/ , way have set print out /htdocs/websitepublic/css/style.css . here fixed code: <link rel="stylesheet" type="text/css" href="

matlab - How to compute a function on a set of natural numbers using recursion -

i working on property of given set of natural numbers , seems difficult compute. build function 'fun' takes 2 inputs, 1 cardinal value , set. if set empty fun should return 0 because fun depends on product of set , fun on subsets of complement set. for clarification here example: s set given s={1,2,3,4}. function fun(2,s) defined fun(2,s)=prod({1,2})*[fun(1,{3}) + fun(1,{4}) + fun(2,{3,4})] + prod({1,3})*[fun(1,{2}) + fun(1,{4}) + fun(2,{2,4})] + prod({1,4})*[fun(1,{3}) + fun(1,{2}) + fun(2,{2,3})] + prod({2,3})*[fun(1,{4}) + fun(1,{1}) + fun(2,{1,4})] + prod({2,4})*[fun(1,{1}) + fun(1,{3}) + fun(2,{3,1})] + prod({3,4})*[fun(1,{1}) + fun(1,{2}) + fun(2,{1,2})] prod defined product of elements in set, example prod({1,2})=2; prod({3,2})=6 i trying compute function fun using recursive method in matlab it's not working. base case cardinal value should more 0 means there should @ least 1 element in set other wise p

swing - Java GUI Panels -

i trying make game 1 of classes, running trouble in implementing of things want do. essentially, want multiple different parts inside same graphical user interface window. to understanding use jpanels create these different parts , put them in larger jpanel, right in this? i have code here, need on going of this. public class farklewindow extends jframe{ private int windowwidth = 800; private int windowheight = 600; private jpanel player1dice, player2dice, dicepanel, infobox; private farkledisplay gameboard;public farklewindow() { this.settitle("farkle!"); this.setsize(windowwidth,windowheight); this.setdefaultcloseoperation(jframe.exit_on_close); inititalizewindow(); this.setvisible(true); } private void inititalizewindow() { gameboard = new farkledisplay(); this.add(gameboard, borderlayout.center); //addmenuoptions(); player1dice = new jpanel(); ga

css - CSS3 marquee effect performance issues -

i scroll text translate3d , effect suffers performance issues. additional effects running @ same, sometimes text not scrolling smoothly, fast computer. ideas improvements? jsfiddle html: <p><span>lorem ipsum...</span></p> css: p { box-sizing: border-box; margin: 0 auto; overflow: hidden; white-space: nowrap; } span { -webkit-animation: marquee 70s linear infinite; display: inline-block; padding-left: 100%; } @-webkit-keyframes marquee { 0% { -webkit-transform: translate3d(0, 0, 0); } 100% { -webkit-transform: translate3d(-100%, 0, 0); } }

scala - Delayed Execution of a series of operations -

i'm trying write class when call function defined in class, store in array of functions instead of executing right away, user calls exec() execute it: class testa(val a: int, newaction: option[arraybuffer[(int) => int]]) { val action: arraybuffer[(int) => int] = if (newaction.isempty) arraybuffer.empty[(int) => int] else newaction.get def add(b: int): testa = {action += (a => + b); new testa(a, some(action))} def exec(): int = { var result = 0 action.foreach(r => result += r.apply(a)) result } def this(a:int) = this(a, none) } then test code: "delayed action" should "delay action till ready" in { val test = new testa(3) val result = test.add(5).add(5) println(result.exec()) } this gives me result of 16 because 3 passed in twice , got added twice. guess easy way me solve problem not pass in value second round, change val a: int val a: option[int] . helps doesn't solve real problem: letting s

How to implement LSH by MapReduce? -

suppose wish implement local sensitive hashing(lsh) mapreduce. specifically, assume chunks of signature matrix consist of columns, , elements key-value pairs key column number , value signature (i.e., vector of values). (a) show how produce buckets bands output of single mapreduce process. hint: remember map function can produce several key-value pairs single element. (b) show how mapreduce process can convert output of (a) list of pairs need compared. specifically, each column i, there should list of columns j > needs compared. (a) map: elements , signature input, produce key-value pairs (bucket_id, element) reduce: produce buckets bands output, i.e. (bucket_id, list(elements)) map(key, value: element): split item bands band in bands: sig in band: key = hash(sig) // key = bucket id collect(key, value) reduce(key, values): collect(key, values) (b) map: output of (a) input, produce list of combination in same

c - How can I reduce the runtime? -

here link problem i'm trying solve: http://acm.timus.ru/problem.aspx?space=1&num=1086 here approach: #include <stdio.h> #include <math.h> int main() { int n, i, m, p; scanf("%d", &n); for(i = 0; < n; i++) { scanf("%d", &m); p = find_prime(m); printf("%d\n", p); } return 0; } int find_prime(int a) { int i, p = 1, t, prime[15000], j; prime[0] = 2; for(i = 0; < a; ) { if(p == 2) { p++; }else { p = p + 1; } t = 0; for(j = 0; prime[j] <= sqrt(p); j++) { if(p%prime[j] == 0 && p != 2) { t = 1; break; } } if(t != 1) { i++; prime[i] = p; } } return p; } i know algorithm fine , produces correct answer. "time limit exceed

sql - Clash of multivalued attribute -

i having database having name , hobbies(as multivalued attribute) , want find out count of occurence of more 1 same value example if sample database a reading dancing b reading b dancing then result should be list of hobbies | number of occurrence -----------------|--------------------- reading, dancing | 2 i think have query this: select hobbies, count(*) hno t group hobbies that have result set this: hobbies | hno --------+------ reading | 2 dancing | 2 now data-set can follow answers of question [ concatenate many rows single text string ] have them in 1 row.

ubuntu - DigitalOcean, Docker, Dokku: Installing Firefox inside a container -

i have application needs use headed browser periodically. i want host using dokku. how can install container? when run: dokku run my_app apt-get install firefox i get: e: failed fetch http://archive.ubuntu.com/ubuntu/pool/main/s/systemd/libsystemd-daemon0_204-5ubuntu20.9_amd64.deb 404 not found [ip: 91.189.91.15 80] . . . e: failed fetch http://archive.ubuntu.com/ubuntu/pool/main/u/ubufox/xul-ext-ubufox_2.9-0ubuntu0.14.04.1_all.deb 404 not found [ip: 91.189.91.15 80] after running: dokku run my_app firefox returns: fata[0000] error response daemon: cannot start container ... exec: "firefox": executable file not found in $path i aware phatomjs better solution third party gem using dependant on headed firefox browser. from error message getting when installing firefox, seems apt cache inside docker container out-of-date. running apt-get update first should resolve problem. though run firefox headless, you'll need step. you'll need

android - Read html inside XML feed using XmlPullParser -

how read html contents inside xml,using xlpullparser in android project. ex:what's inside in facebook feed . note:it may contains images, albums, videos... update:i need parse content of ![cdata[ on vogella.com , there nice example on how use xmlpullparser. import java.io.ioexception; import java.io.stringreader; import org.xmlpull.v1.xmlpullparser; import org.xmlpull.v1.xmlpullparserexception.html; import org.xmlpull.v1.xmlpullparserfactory; public class simplexmlpullapp { public static void main (string args[]) throws xmlpullparserexception, ioexception { xmlpullparserfactory factory = xmlpullparserfactory.newinstance(); factory.setnamespaceaware(true); xmlpullparser xpp = factory.newpullparser(); xpp.setinput(new stringreader ("<foo>hello world!</foo>")); int eventtype = xpp.geteventtype(); while (eventtype != xmlpullparser.end_document) { if(eventtype == xmlpullparser.start

java - How to return a JSON object from a HashMap with Moxy and Jersey -

i using jersey 2.17 moxy , have functions : @produces(application_json) @restricted public list<user> getfriends( @pathparam("user") string user ) { return userdao.getfriends(user); } user.preferences hashmap . it works fine objects except hashmap gets translated into: "preferences":{"entry":[{"key":{"type":"string","value":"language"},"value":{"type":"string","value":"en"}},{"key":{"type":"string","value":"country"},"value":{"type":"string","value":"us"}}]} but return javascript object like: preferences:{"language":"en","country":"us"} how can that? yeah moxy , maps don't work well. it's sad, json nothing more mapped key/value pairs. if want use moxy, need us

mingw - Making Cython work with Python 3.4 on Anacondas, Windows 7 64-bit -

i have installed python 3.4 on windows 7 64-bit machine, using anaconda/condas. when run "hello world" cython example error: [py34] c:\users\jon\documents\github\cythonfunctions\cython_funcs>python setup.py build_ext --inplace running build_ext building 'cython_funcs.hello' extension c:\anaconda\envs\py34\mingw\bin\gcc.exe -mdll -o -wall -ic:\anaconda\envs\py34\include -ic:\anaconda\envs\py34\include -c hello.c -o build\temp.win-amd64-3.4\release\hello.o writing build\temp.win-amd64-3.4\release\hello.def c:\anaconda\envs\py34\mingw\bin\gcc.exe -shared -s build\temp.win-amd64-3.4\release\hello.o build\temp.win-amd64-3.4\release\hello.def -lc:\anaconda\envs\py34\libs -lc:\anaconda\envs\py34\pcbuild\amd6 4 -lpython34 -lmsvcr100 -o c:\users\jon\documents\github\cythonfunctions\cython_funcs\cython_funcs\hello.pyd build\temp.win-amd64-3.4\release\hello.o:hello.c:(.text+0x314): undefined reference `__imp__pythreadstate_current' build\temp.win-amd64-3.4\releas

c - How to get Windows version by name (for future Windows versions)? -

i can use getversionex() function windows version, function return number , not string. there no problem can convert number string, example: if (osvi.dwmajorversion == 6 && osvi.dwminorversion == 1) { printf("%s\n", "windows 7"); } but if new windows version came out after releasing program. have recompile program add new windows version! you should query caption of win32_operatingsystem .

javascript - Check typeof text data -

i have string in link http://pastie.org/private/n7bu5qlknphtyyv5sqla . i trying decode using different methods new uint8array(encodedstring); and tried octal decoders online no success. can me understand encoding type , how decode it. edit : progress: file loaded client side. before using readasbinarystring , changed reader.readasarraybuffer(blob); getting arraybuffer , converted new uint8array(arraybuffer) . seems have data zipped data.

parsing - Java program to read information from a website -

i writing program in java track "fantasy college basketball" league friends. struggling finding best implementation automatically update statistics each player drafted. as background, every day individuals in fantasy league earn points based on statistics college basketball players drafted earned week. right now, mannually: 1: go player's espn profile espn tracks individual player stats url based on random , unique player id number. frank kaminsky's id 56759, espn profile is: http://espn.go.com/mens-college-basketball/player/_/id/56769/ . can assume user input player's espn id when player drafted , have information when updating stats. 2: parse html page relevant stats looking @ url above - important information in "2014 - 2015 game log" section. want obtain recent game's pts, reb, ast, blk, stl, pf, , to use elsewhere in program. what best approach this? my first reaction use .openstream() on url, require lot of careful string pars

Certain parts of Python script not running -

under choose option 2 part. if input bread rest of part won't run. script ends there. wrong can tell me? don't error message script stops. other works bread = 44 lettuce = 21 meat = 21 cheese = 23 sandwich = bread, lettuce.meat, cheese choseoption = input('what mark order, add stock, or check stock') if choseoption == 1: neworder = input('what did order?') if neworder == 'sandwich': bread = bread - 4 lettuce = lettuce - 5 meat = meat - 7 cheese = cheese - 10 print(bread) print(lettuce) print(meat) print(cheese if choseoption == 2: newstock = input('what add stock?') if choseoption == 'bread': addbread = input('how bread add? ') bread = bread + addbread if newstock == 'lettuce': addletuce = input('how lettuce add?') lettuce = lettuce + addletuce if newstock == 'meat': add

java - How to resize a Libgdx desktop window in-code during runtime -

i have problem finding out how resize window in-code during runtime. i have tried using gdx.graphics.setdisplaymode(); removes ability resize window, wich must in game. tried access display class opengl without luck, since not referenced in core part of gradle. any idea how done? i stuck exact same problem. , figured out instead of directly call display.setdisplaymode(new displaymode(width, height)) should use gdx.graphics.setwindowedmode(width, height) change window size.

objective c - [Facebook-iOS-SDK 4.0]How to get user email address from FBSDKProfile -

i'm upgrading app facebook-ios-sdk-4.0 , seems can't user email fbsdkprofile , since provide, username, userid, etc. to fetch email need utilize graph api, providing parameters field populated fields want. take @ facebook's graph api explore tool, can figure out queries. https://developers.facebook.com/tools/explorer the code worked me fetch email following, assumes logged in: nsmutabledictionary* parameters = [nsmutabledictionary dictionary]; [parameters setvalue:@"id,name,email" forkey:@"fields"]; [[[fbsdkgraphrequest alloc] initwithgraphpath:@"me" parameters:parameters] startwithcompletionhandler:^(fbsdkgraphrequestconnection *connection, id result, nserror *error) { ahandler(result, error); }];

user interface - Particle system ONGui() - Unity3d -

Image
i developing game in unity3d , have scripts uses ongui() method , attached gamemenu object. need play particle system on scene while gui scripts active. when cant see particle system because ongui method disabling maincamera , on top of on scene. so there way play particle system in front of ongui() method ? this how scene looks like: on red marked area, want particle system being played underline selection. whole menu designed ongui() method , particle system playing behind cant see. avoid using ongui it's pretty deprecated. unity supports feature new gui system. however, using ongui not possible (without using 3rd party tools).

html - Text does not align left inside a div -

i'm trying align span element inside div it's left border. code: .bikoret { width:40%; border:1px solid black; } .bikoret > .content { width:80%; padding:0; word-wrap: break-word; } .bikoret > .username { text-align:center; padding-left:1%; padding-right:1%; position:relative; left:0; border-top:1px inset; } <div dir="rtl" style="text-align:center; background-color:white; border-top:1px; border-style:inset; margin-top:4px; padding-left:10px; padding-right:10px;" runat="server" id="takzir"> <center> <div class='bikoret'> <div class='content'> centered </div> <span class='username'>this aligned left</span> </div> </center> </div> how can fix it? tried now.. here how approa

javascript - (this).attr() stops working after jquery.noConflict() -

i had code worked on 1 project when decided port project, has issues $ . decided use jquery.noconflict() method resolve it. resolved alright .attr() method returns undefined. initial code $(".sharebtn").click(function(event) { event.preventdefault(); content = $(this).attr("data-share-content"); content_id = $(this).attr("data-share-contentid"); medium=$(this).attr("data-share-medium"); cur_count = parseint($("#share_count_holder_"+content_id).val()); if(cur_count<=999){$("#post-share-count").html((cur_count+1));} if(cur_count>999 && cur_count<=1000000){ disp=parsefloat(math.round((cur_count/1000)+'e1')+'e-1'); $("#post-share-count").html(disp+"k"); } if(cur_count>1000000){ disp=parsefloat(math.round((cur_count/1000000)+'e1')+'e-1'); $("#post-share-count").html(disp+"m"); } $("#share_coun

How do I extract emails from dictionary in python as key value pair? -

from following dictionary structure, how extract , print email addresses? e.g. want see 'smauel.david@gmail' 4, 'sdusa@yahoo.com' 1, etc. dict_items([('10:04:14', 1), ('3', 6), ('thu', 6), ('19:51:21', 1), ('2008',27), ('from', 27), ('11:35:08', 1), ('5', 1), ('sntp@hotmail.com', 3), ('jan', 27), ('15:46:24', 1), ('14:50:18', 1), ('11:37:30', 1), ('18:10:48', 1), ('17:07:00', 1), ('09:05:31', 1), ('10:38:42', 1), ('sdusa@yahoo.com', 1), ('samuel.david@gmail.com', 4) ]) use dict comprehensions d = dict([('10:04:14', 1), ('3', 6), ('thu', 6), ('19:51:21', 1),('2008',27), ('from', 27), ('11:35:08', 1), ('5', 1),('sntp@hotmail.com', 3), ('jan', 27), ('15:46:24', 1), ('14:50:18',1), ('11:37:30', 1), (

matlab - Circle detection via Hough Transform -

Image
i writing matlab code takes in photo , detects circular object. after using filters, got below image. to detect circular object(it not perfect circle), tried apply hough transform passing different values of radius , threshold, couldn't detect properly. why happens? shape of object or background of image? also possible detect same object @ following image using hough transform? edge of circular object seems human eye, not sure background can eliminated image via hough transform. you can use imfindcircles in image processing toolbox. using morphology fill in circle , cranking sensitivity may help: im = imread('pattern.jpg'); im2 = rgb2gray(im(100:end-100, 100:end-100, :)); im3 = im2bw(im2, 0.1); im4 = imclose(im3, strel('disk', 4, 4)); im5 = imfill(im4, 'holes'); imshow(im5); [centers, radii] = imfindcircles(im5, [180, 200], 'sensitivity', .99); viscircles(centers, radii);

weird characters while reading text and binary from a socket's stream in java -

i have tried search answer no luck (both @ google , stackoverflow) i writing java program in server , client can communicate sending/receiving data , files... i sending files chunks of 1mb each. let client know number of chunks, sending string line containing blocknb=x x number of chunks, followed file. however when reading client, receiving instead of line weird characters: ur\u0000\u0002[b¬Ã³\u0017ø\btà\u0002\u0000\u0000xp\u0000\u0000\bp \b , \uxxxx representant of values (i expecting here blocknb=1 ) (written in clearer way: ur [b¬Ã³ ø tà xp p (where spaces escaped characters) here code. server side try ( serversocket welcome = new serversocket(6500); socket socket = welcome.accept(); objectoutputstream outputstream = new objectoutputstream(socket.getoutputstream()); printwriter printwriter = new printwriter(socket.getoutputstream()) ) { system.out.println("accepted"); file f = new fi

javascript - Why is my jQuery click function not firing? -

i building search page posts itself. got sample page working here . built fiddle here . don't understand why works. when user hits page, should show search form. when search submitted, should hide form, show results, , button new search. i'm using jquery. here's code: //code block 1 // show search form if there no querystring //hide search form, show results if querystring $(document).ready(function() { if(document.location.search.length) { $("#newsearch").show(1000); $("#results").show(1000); $("#search").hide(300); } else { $("#search").show(); } }); //code block 2 //if new search clicked, show form, hide results $("#newsearch").click(function() { $("#newsearch").hide(1000); $("#results").hide(1000); $("#search").show(300); }); when code block 1 , 2 loaded in head, block 2 never fires. when pull 2 out , put @ end of page, works. i

java - How to optimize the computing speed of this for loop? -

i kind of stuck difficult problem (for me, @ least). noticed when profiling code (single core) computing time eaten single nested loop below (double integral on image). think best way accelerate computing? i tried map nested streams, not understand how map multiple if blocks... trying on gpu using opencl better suited problem? ip imagej imageprocessor , , method .getpixelvalue(x,y) quite ressource consuming. since belongs established lib, avoid modifying if can. variables declarations: private imageprocessor ip = null; //this type comes imagej private double area; private double a11, a22; private double u1, u2; private double v1, v2; private double y1, y2; private static final double half_sqrt2 = sqrt(2.0) / 2.0; private static final double sqrt_tiny = sqrt((double)float.intbitstofloat((int)0x33ffffff)); function: private double contrast ( ) { if (area < 1.0) { return(1.0 / sqrt_tiny); } double c = 0.0; final int xmin = max((int)floor

machine learning - Singular Covariance and NA's for z value using Random Projection in R -

i'm getting na's z value in following code. it's due singular covariance. i've run similar test on iris dataset, , don't same error. doing wrong or nature of data? code in r: install.packages('mclust') library('mclust') mydata <- read.table("http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv", sep=";", header=true); est <- mevvv(mydata[,-12], unmap(mydata[,12])) randproj(mydata[,-12], seeds=200, parameters = variance, z = est$z, truth = iris[,5], = "errors", identify = true, scale = true) thanks, dgene take @ table(mydata[, 12]) # 3 4 5 6 7 8 # 10 53 681 638 199 18 this means using 10 observations in 1 cluster, while have 11 features (variables) in model, warning message na values. if want specify model vvv use code : fm <- mclust(mydata[, -12], modelnames="vvv")

javascript - google map api multi markers -

i have make map company , have put company logo on 1 marker, , container icon on 10 others markers don' t know how it: current code : ( have first marker logo personal image can't see marker ) have make new variable "marker2" ? , make new variables each position of icons ? var nice = new google.maps.latlng(43.7101728,7.2619532); var centre = new google.maps.latlng(43.7101728,7.2619532); var marker; var map; function initialize() { var mapoptions = { zoom: 14, center: nice, }; map = new google.maps.map(document.getelementbyid('map-canvas'), mapoptions); marker = new google.maps.marker({ map:map, draggable:false, animation: google.maps.animation.drop, position: centre, icon:'image/abi06b.png' }); google.maps.event.addlistener(marker, 'click', togglebounce); } function togglebounce() { if (marker.getanimation() != null)

Adding same element to every level of array php -

i need add another element each level of array (sorry, think bad terminology). i have array - array ( [0] => array ( [actor_rt_id] => 162683283, [item_number] => 3 ) [1] => array ( [actor_rt_id] => 162657351, [item_number] => 5 ) ) this code produces array. commented out line tried add array. code before comment creates array. $data_itemone['actor_rt_id'] = $this->input->post('actor_id'); $data_itemtwo['item_number'] = $this->input->post('item_number'); $data_item = array_merge($data_itemone, $data_itemtwo); $res = []; foreach($data_item $key => $value){ foreach ($value $data => $thevalue) { $res[$data][$key] = $thevalue; //$res['film_id'] = $film_id; } } i have variable need add post single string. $film_id = $this->input->post('film_id'); i need in array - array ( [0] => array (

What password(s) go in the bacula client's /etc/bacula/bacula-fd.conf? -

i have bacula 7.0.5 server running on centos 7 , i'm trying configure clients , add them server's config using webmin. first question is, can expect debian clients using bacula-client 5.2.6+dfsg-9 work reliably bacula 7.0.5 server? second question: passwords use in client's /etc/bacula/bacula-fd.conf?

macros - Elixir: generating module with proper import -

i'm trying write macro generates module: defmodule genmodules defmacro module(name, do: body) quote defmodule unquote(string.to_atom(name)) unquote(body) end end end end what i'm missing how inject 'import' statement refer module macro called from? i.e., following code: defmodule test import genmodules module "newmodule" def test_call hello_world end end def hello_world io.puts "hello" end end won't compile because hello_world function not visible generated newmodule. so need generate import test before body of module, somehow getting name of module macro called from. how do this? thank you, boris to module macro called can use special form __caller__ . contains bunch of information, can extract calling module so: __caller

ntp - Is there a simpler way to take a substring of an char array and convert it to a long in C? -

i looking shorter/more elegant way ntp timestamp received ntp packet. packet stored in unsigned char array, buf, socket function recvfrom: unsigned char buf[48]; recvfrom(sockfd, buf, 48, 0, (struct sockaddr *) &their_addr, &addr_len)); i copying value of 40th-43rd elements represent 32-bit timestamp of seconds unsigned long, transsec, bitshifting so: recvpacket->transmitsec = buf[40]; recvpacket->transsec <<= 8; recvpacket->transsec |= buf[41]; recvpacket->transsec <<= 8; recvpacket->transsec |= buf[42]; recvpacket->transsec <<= 8; recvpacket->transsec |= buf[43]; this works fine, in interest of learning, there shorter/more elegant way of doing this? have tried memcpy: memcpy(&recvpacket->transsec, &buf[40], sizeof(unsigned long)); and other variations of above, getting incorrect numbers. not particularly confident i'm using correctly. what might endianness issue. check wiki entry here: http://en.w

Odoo Rounding error - thousand separator -

Image
i've rounding on account entries 0 display in spanish language set to: [3,0], decimal separator ",", thousand separator "." rounding factor on money (clp): 1.000000, computational accuracy: 4 during editing after editing 417.311 reduces 417 i try find bug in view_list.js , view_list_editable.js, cant found make sure field float type , not integer.

php - remove 3 directories in url via htaccess file -

i want convert url http://localhost/project1/mvc/public/content/1 url http://localhost/content/1 . i have .htaccess file placed in public folder removes index.php in url. options -multiviews rewriteengine on rewritebase /project1/mvc/public rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^(.+)$ index.php?url=$1 [qsa,l] here's directory structure: project 1 ---mvc -----app -----public i need in creating .htaccess file this. syntax modifying url , folder/s should put .htaccess file/s? thanks you can use code in document_root/.htaccess file (above directory level of mvc ): rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewriterule ^((?!/project1/mvc/public/).*) project1/mvc/public/$1 [l,nc]

javascript - converting a certain time format into a Date Object -

i timestamp api "2015-04-03t19:04:00" , every week updated. want use countdown.js , have played around with date in format new date(year, month, days, hour, minutes) ... it works: $('.counttime').countdown({until : new date(year, month, days, hour, minutes)}) basically want know best way convertthe string api date object think countdown.js accepts above. split string arrays dashes , colons , delete "t"? or there javascript function convert formats? concerned saying 19:04 when experimenting used 12 hours not 24 hours. wonder if put in 19:04 , correct countdown new date('2015-04-03t19:04:00')

objective c - Xcode 6.2 iOS target 6.1: self.view endEditing:YES throws exception unrecognized selector sent to instance -

i have textfield pulls decimal pad keyboard. added tap gesture recognizer in .xib , want close keyboard when taps on screen. @property (weak, nonatomic) iboutlet uitextfield *billtextfield; - (ibaction)ontap:(id)sender; @end @implementation tipviewcontroller - (ibaction)ontap:(id)sender { self.title = @"tap detected"; [self.view endediting:yes]; } @end this throws following exception: [tipviewcontroller billtextfield:]: unrecognized selector sent instance 0x7fd6dac50630 2015-03-28 22:19:59.747 tipcalculator[32959:3666939] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[tipviewcontroller billtextfield:]: unrecognized selector sent instance 0x7fd6dac50630' what missing here?

php - Can't connect to MySQL on live with Laravel 5 -

i have problem on connecting laravel 5 mysql on live server, seems ok on localhost when uploaded live server, wont connect saying: pdoexception in connector.php line 47: sqlstate[hy000] [2003] can't connect mysql server on '10.0.0.131' (111) here config local server: config/database.php 'mysql' => [ 'driver' => 'mysql', 'host' => env('db_host', '127.0.0.1'), 'database' => env('db_database', 'my_database_name'), 'username' => env('db_username', 'my_username'), 'password' => env('db_password', 'my_password'), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, ], .env app_env=local app_debu

CPU gap when doing k-means with Spark -

Image
i working spark 1.2.0. my feature vector 350 dimensions the data set 24k vectors the problem described below happens kmeans|| algorithm; have switched kmeans-random now, know why kmeans|| doesn't work. when call kmeans.train k=100 , observe cpu usage gap after spark has done several collectasmap calls. marked in red in image, there 8 cores, 1 core working while other 7 @ rest during gap . if raise k 200, gap increase. i want know why gap? how avoid it? because work requires me set k=5000 larger data set. current settings, job never ends... i have tried approach both windows , linux (both 64bit) environment, , observe same behavior. i want, give code , sample data. have checked webui, gc times? 1 cpu up, others down stop-the-world garbage collection. you might wanna try enabling parallel gc , check section on gc tuning in spark documentation . other that, collectasmap return data master/driver, bigger data gets, longer single driver process

gcc - sndfile.h not found on OS X -

i'm trying install libsndfile on osx, , used homebrew (brew install libsndfile). when try compile example code #include <sndfile.h> using gcc says sndfile.h cannot found, when check in /usr/local/include it's right there. there i'm missing? depending on compiler you're using may need add: -i/usr/local/include to command line, e.g. gcc -wall -i/usr/local/include foo.c -o foo