Posts

Showing posts from September, 2012

How would you go about writing a custom script that grabs the Adobe or Google Analytics image request? -

if wanted build scraper pings each url on site , stores adobe (or google) image request, how go this? i.e. want grabs parameters in url posted adobe in csv or similar. i'm familiar how build simple web scrapers, how grab url see in example fiddler contains variables being sent analytics solution? if could run script lists urls corresponding tracking events being fired , make qaing more manageable. you should able query dom image object created tag request. more familiar ibm digital analytics (coremetrics) platform , can find tag requests using accessing following array document.cmtagctl.cti in web console on coremetrics tagged page. used method when building selenium webdriver test case , wanted test analytics tags. i don't have equivalent adobe or ga @ moment since depends in library implementation trying same ga. cheers, jamie

does JPA use JavaBeans BeanInfo information? -

according jpa 2.1 spec: it required entity class follow method signature conventions javabeans read/write properties (as defined javabeans introspector class) persistent properties when property access used. in case, every persistent property property of type t of entity, there getter method, getproperty , , setter method setproperty . does imply methods must always named getproperty , setproperty (per design pattern "convention" in §8.3.1 of javabeans spec 1.0.1, "[i]f don't find explicit beaninfo on class"); or beaninfo class provided direct jpa implementation different method (per full description of introspector class in spec)? although i'm curious how hibernate or other jpa implementations implement this, i'm instead asking implementation jpa spec requires. the methods must named per java beans contract ... getxxx (or isxxx), setxxx. there no beaninfo hook used jpa implementation know of

How to set a Paypal Sandbox test account address -

trying first tests of new paypal standard buttons test account. after noticing taxes not being charged correctly added ontario taxes sandbox business account profile , bingo, ontario sales tax got charged. see in test account profile used transaction set province of residence... how change being quebec instance, quebec sales tax gets charged? thanks ok figured out myself. basically need log sandbox 1 of test accounts , change address like. same goes details on credit cards. 1- first logon developer site: https://developer.paypal.com/developer 2- go dashboard 3- click on accounts under sandbox on left (make sure have set password on 1 want use below....) 4- click on enter sandbox link in middle of right pane. 5- click on second logout (not 1 on top, log out of paypal altogether!) logout business sandbox account 6- log sandbox using test client account 7- play address like. changing account address province of quebec , entering transaction using accou...

android app root or system privileges -

i trying build android app can access /data dir (for example) without parsing output of command ran on shell after doing su. i mean, after researching lot, , looking in code of root explorers, when need root perms parsing output of command after doing su. what want doing like: file file = new file("/data"); file[] files = file.listfiles();// list array of file (int = 0; < files.length; i++) { file fileitem = files[i]; system.out.println("file name: "+fileitem.getname().tostring()) { } for achieving think application process must running root begining of execution. i tried run app shell after doing su way: $su #am start -n com.example.test/.ui.activity but same after looking @ output of ps command see application running user "u0_a110" , not root. also tried parameter --user 0 , --user 1000, same results... think dalvik virtual machine drops privileges parent process. i tried convert app system app moving /system/priv-app sa...

How do I programmatically locate my Google Drive folder in OSX? -

similar question here , osx. how can programmatically detect google drive path on osx. couldn't find sync_config.db in windows version. ok, db file in osx located under: ~/library/application support/google/drive/user_default/sync_config.db

ios - Scroll to scrollview page while scrollview is being resized -

i've got scrollview paging disabled. has number of subviews. each of has width constraint , constrained each other , scrollview, when subviews grow, scrollview content area grows. when subview tapped, run following code: var page = subview.tag scrollviewsubviewwidthconstraint in scrollviewsubviewwidthconstraints { //this results in subview being larger scrollviewsubviewwidthconstraint.constant = self.view.frame.width } uiview.animatewithduration(0.35) { self.view.layoutifneeded() } scrollview.pagingenabled = false scrollview.setcontentoffset(cgpoint(x: self.view.frame.width * cgfloat(page), y: 0), animated: true) this code intended to: resize subviews width of 'page' enable paging on scrollview scroll correct page smoothly unfortunately not doesn't scroll correct page, seemingly because it's trying calculate amount scroll while constraints being updated, in unappealing fashion animation wise. if change code (cutting out animation) ...

regex - Groups using regular expression in Bash on windows -

here trying do: message=“time-1 time-2 test" echo $message | sed -e 's/(^([a-z]{2,8}-[0-9]{1,4}).*[[:space:]]+[[:alnum:]]+$).*$/\2/‘ gives: time-1 should give: time-1 time-2 i need working on windows, linux , macos (as part of git hook), cannot use “=~" can please correct wrong at. i believe ask: $ echo "$message" | sed -e 's/(^([a-z]{2,8}-[0-9]{1,4}[[:space:]]+)*).*/\1/' time-1 time-2

java - File not found when using multiple scanners -

i'm writing simple program in eclipse input , compare 2 text files. however, can't seem import 2 text files @ same time. if delete 1 of new scanner objects, clears other file; otherwise, gives me error file not found on both. both files in same place in source folder. code follows: textfile1 = new file("text1.txt"); scanner text1 = new scanner(textfile1); textfile2 = new file("text2.txt"); scanner text2 = new scanner(textfile2); thanks in advance! try code try-catch block , let me know if worked or not. // compiler complains if there scanner opened without try-catch block around try { final file file1 = new file("text1.txt"); //it thing make file final, gives easy reference reader final file file2 = new file("text2.txt"); scanner t1 = new scanner(file1); scanner t2 = new scanner(file2); //after done close scanner t1.close(); ...

Json object is printed in strange format in Python -

so request steam page responds json: {"success":true,"lowest_price":"$2.23","volume":"2,842","median_price":"$2.24"} my objective transform dictionary in python, when return json object in function this: {u'volume': u'2,842', u'median_price': u'2,02€ ', u'lowest_price': u'1,99€ ', u'success': true} (notice u'). what can eliminate u's? you're seeing python letting know strings you're printing unicode strings. unless output you're seeing matters (e.g., it's input else), can disregard leading 'u' character until run issues unicode output. there litany of stack overflow questions address this. python string prints [u'string'] what's u prefix in python string printing string prints 'u' before string in python? and lot more....

paw app - Paw support for REST Level 3 (HATEOAS) Navigation? Following links -

Image
i'm using paw client rest level 3 (hateos) api. part of rest level 3 links related resources discoverable part of response returned. paw provide rest level 3 specific support such making easy follow links returned? what able follow links clicking (command+clicking if needed) on value url in response , issue against url. http headers carried on url things such authorization not break. (it may or may not want smart , if it's same domain/context-root original request rest level 3 link , not generic link). see example of great clickable below: ideally great able navigate previous responses once result has been followed. lot of rest level 3 links provide or 'rev' links allow this, not links bi-directional being able go in browser great. currently workaround is: triple-clicking on value command+c navigate address bar command+a command+v command+enter so it's doable today, 6 actions rather single click action on url contained in response tedious ...

geometry - How to determine device's location in the sky / project sky coords into 2d map -

i trying enable user point device sky , view stars "should" located. i displaying stars on 2d map using leafletjs , google sky tiles. the data have available following: 1: star ra, dec , mag 2: gyroscope, compass , accelerator to actual star markers showing on map use formula convert ra/dec lat/lng: starlng = (-(starra) + 180) starlat = stardec i have been banging head trying figure out how project current area user viewing 2d leaflet lat/lng , keep track/auto-pan map depending on direction user moves device. i new celestial coordinate system , things related. any appreciated! thanks!

PHP 5.6, PDO MySql Connection on Unix (LAMPP) - Fatal Error: SQLSTATE[HY000] [1045] -

this question has answer here: mysql error 1045 (28000): access denied user 'bill'@'localhost' (using password: yes) 27 answers i try realize cms in mvc oop php. i use unix system (ubuntu 14) , lampp (xampp) server. in config.php fetch information database connection xml file. i try methods before mysql connection pdo in php, , works. there 2 things different in case is, first is, fetch mysql connection information xml file. second work on unix system. stackoverflow marked questions duplicate, cant't forward answer. maybee can take look, , explain newbie ;) mysql error 1045 (28000): access denied user 'bill'@'localhost' (using password: yes) config.php: final class config { /**************************************************************************/ /*private function*/ /* * xml content */ private static functi...

mysql - Can't update sql through php -

$settings = parse_ini_file("settings.ini"); $conn = new mysqli($settings[servername],$settings[username],$settings[password], $settings[dbname]); $height = $_post['heightft'] * 12 + $_post['heightin']; if($conn->connect_error) { die("connection failed: " . $conn->connect_error); } if(isset($_cookie['user'])) { list($currentfname, $currentlname) = explode(",", $_cookie['user']); } $newfname = $_post['fname']; $newlname = $_post['lname']; $newage = $_post['age']; $newweight = $_post['weight']; $newheight = $_post['height']; $newsex = $_post['sex']; $sql = "update $settings[usertable] set fname = $newfname, lname = $newlname, age = $newage, weight = $newweight, height = $newheight, sex = $newsex fname = $currentfname , lname = $currentlname"; $retval = mysql_query($sql, $conn); if(!$retval) { die("could not update data: " . print_r($_post) ...

sql - do not update if exists postgres -

i have table has unique constraint on (uid,client_fact). when try update client_fact raise error on constraint obvious because if update client_fact value 2 user_id 1 , if there combination of these 2 column raise exception. there way can skip , continue updating others. the query using is update user_ft set client_fact_id = 779, client_fact_id in (select client_fact_id user_ft client_fact_id = 778 , updated_date::date =< '2015-05-28') , not exists (select uid ,client_fact_id user_ft client_fact_id = 779) i used not exists clause handle case have combination of user , factid sitting in table. ran didn't updated anything. got ... don't need use not exists. .. result skipping rows canged query have if user in table combination don't consider user in query. see below corrected query update user_ft set client_fact_id = 779 ...

android - resize/scale text dynamically in andengine -

i created simple game move objects 1 place , each moves increment count of moves in score table. after objects moved correct want set opacity screen , resizing score initial size(e.g. 15px) whole screen(e.g. 50px). load font this: fontfactory.setassetbasepath("font/"); final itexture mainfonttexture = new bitmaptextureatlas(activity.gettexturemanager(), 256, 256, textureoptions.bilinear_premultiplyalpha); font = fontfactory.createstrokefromasset(activity.getfontmanager(), mainfonttexture, activity.getassets(), "font.ttf", 15, true, color.white, 2, color.black); font.load(); in createscene() method create hud text , initial text: int mmoves = 0; hud gamehud = new hud(); text mtext = new text(25, 25, font, "moves: " + "123456789", getvertexbufferobjectmanager()); and each moves set text actual moves count: mtext.settext("moves: " + mmoves++); and when level complete don't know how can resize text. mean...

asp.net - How to handle an exception in VB code if the stored procedure doesn't return one of the fields? -

i have vb function calls stored procedure 2 kinds of reports (actives users/inactive users). stored procedure returns data (columns) based on report choose. if choose active users report, sproc doesn't return inactive_date users, return same field, inactive_date field inactive users report. i'm getting error when choose active users report, because sproc doesn't return inactive_date field, vb.net code same both active/inactive users reports. here of ways tried resolve, no luck. if isdbnull(dr("inactive_date")) result.inactive_date = nothing else result.inactive_date = safestr(dr("inactive_date")) end if and if isdbnull(dr("inactive_date")) result.inactive_date = datetime.now else result.inactive_date = safestr(dr("inactive_date")) end if you're getting exception because you're trying access dictionary entry doesn't exist. have few options. have stored procedure active users return ...

Python Tkinter Attribute Error -

i have made tkinter program keep getting error: file "f:\programming 2\gui\gui #11.py", line 78, in shape_workit cylinder(pos=(0,0,0),axis=(1,0,0),color=self.color3.get(), attributeerror: 'kinter' object has no attribute 'color3' here code error occurs from: def shapescolor(self): if self.color1.get()=="does orange": color3=color.orange if self.color1.get()=="does blue": color3=color.blue def shape_workit(self): try: if self.shape.get()=="does cylinder": #creates cylinder cylinder(pos=(0,0,0),axis=(1,0,0),color=self.color3.get() ##error here, radius=float(self.radius.get())) here code error gets from my guess need doing self.color3 = ... rather color3 = ... , since you're later refering self.color3 , haven't set attribute anywhere else in code posted.

Cassandra schema, query -

i'm designing new application, use cassandra (i'm new in cassandra). database contain 2-4 column families. problem that, have provide opportunity filter based on every column attributes. give me helpful suggestion have keep in mind during planning? data redundancy? cassandra isn't optimized use-case. preferred way query data using primary key. filtering arbitrary columns possible using allow filtering query modifier creating secondary index each column, not combined in single query creating lookup tables different primary key variants based on column want filter all of options have limitations.

javascript - Using "this" inside named function on a jQuery plugin -

i'm trying write simple jquery plugin , need code run on both load , window resize wrote function inside plugin. jquery(document).ready(function($) { (function( $ ) { $.fn.responsivenav = function() { function enable_responsive_nav() { if( this.hasclass('class') ) { //do stuff } } $(window).resize(function(e) { enable_responsive_nav(); }); enable_responsive_nav(); return this; }; }( jquery )); $('nav').responsivenav(); the problem 'this' doesn't seem recognized inside function. tried passing function argument: enable_responsive_nav( ) ...but error on console saying hasclass() 'is not function'. i guess without function out , bind window resize event outside plugin, i'm trying keep single call , i'm sure i'm missing simple. one common solution create local variable called that or self in scope t...

javascript - Trouble with ajax delay in search form -

i trying set timeout ajaxget function shown here . without code have found have: $('#search').on('keyup', function() { var query; query = $(this).val(); ajaxget('{% url "distributors:search_dist" %}', { 'query': query }, function(content) { $('#distributors').html(content); // alert(content); set_favorite(); }) }); and works nice. after implemented solution delay have: var delay = (function() { var timer = 0; return function(callback, ms) { cleartimeout(timer); timer = settimeout(callback, ms); }; })(); $('#search').keyup(function() { delay(function() { var query; query = $(this).val(); ajaxget('{% url "distributors:search_dist" %}', { 'query': query }, function(content) { // $('#distributors').html(content); alert(content); ...

php - Get Monolog JSON Stack Trace as Array -

i'm using laravel 4.2 , want logs out json. laravel uses monolog, i've configured json formatter so: $loghandler = new monolog\handler\streamhandler(config::get('app.logfile'), monolog\logger::debug); $loghandler->setformatter(new monolog\formatter\jsonformatter); log::getmonolog()->pushhandler($loghandler); the problem stack traces included part of message string, so: { "message": "exception 'exception' message 'socket operation failed: host name lookup failure' in /var/www/vendor/clue/socket-raw/socket/raw/socket.php:388\nstack trace:\n#0 /var/www/vendor/clue/socket-raw/so..." } can point me in right direction make stack trace own separate array in json? long overdue update: the primary problem laravel, , lots of code following example, tries log exception itself, e.g., log::error($e) . this wrong way log exception monolog. first parameter supposed simple message string. in processing it, monolog\lo...

android - django-scarface strange message trimmed on iOS push notification -

i have strange issue ios push notification , django app. in djnago application integrated django-scarface send push notification ios , android device using amazon aws sns service . in test can send push notifications generic device using string message. can receive correctly notifications on devices. now, if change text of notification this: notification_message = notifications.settings.request_received_notification_message % sender.from_user.first_name request_received_notification_message = "%s sent request!" notification_message correctly generated... example read u"safari sent request!" (in debug mode) but, when receive notification on ios device have this: "safari sent you...." for strange region message trimmed... but, if set hardcoded name works well: example, if have: notification_message = notifications.settings.request_received_notification_message % "safari" have suggestion strange problem?

erlang - How to delete the whole directory which is not empty? -

i want clean temporary collecting resource. file module has del_dir/1 require directory empty. there not function files in directory (with absolute path") the source code follows, how correct it? delete_path(x)-> {ok,list} = file:list_dir_all(x), %% <--- return value has no absolute path here lager:debug("_229:~n\t~p",[list]), lists:map(fun(x)-> lager:debug("_231:~n\t~p",[x]), ok = file:delete(x) end,list), ok = file:del_dir(x), ok. you can delete directory via console command using os:cmd, though it's rough approach. unix-like os be: os:cmd("rm -rf " ++ dirpath). if want delete non-empty directory using appropriate erlang functions have recursively. following example here shows how it: -module(directory). -export([del_dir/1]). del_dir(dir) -> lists:foreach(fun(d) -> ok = file:del_dir(d) ...

windows - How much improvement can I expect with SharpDX over heavily optimized GDI code in C#/WinForms? -

i've been working on c#/gdi graphical app couple years. i've spent lot of time optimizing drawing code. drawing screen invalidating picturebox control 10 times second, , leveraging subsequent onpaint event occurs when windows triggers it. onpaint event gives me access graphics object via painteventargs param. per frame: draw hundreds of lines, hundreds of rectangles, , call graphics.drawstring() method hundreds of times well. i started putting sharpdx project in hopes draw more 2d elements, , draw faster screen. set 2 test projects draw same 2d elements on screen using gdi , using sharpdx. used c# stopwatch object detect how long taking draw 2d elements. far, have not noticed speed improvement when drawing sharpdx. both gdi , sharpdx average 20millis per draw. how of speed improvement should expect using sharpdx? , portion of rasterization supposed make faster gdi? i worked on windows forms app "rendering system" pluggable, , wrote 2 rendering syste...

asp.net - breezejs EntityQuery fail -

i'm playing around breezejs knockout todo-list tutorial/template ( http://www.asp.net/single-page-application/overview/templates/breezeknockout-template ). decided make new employees class , see if bind list of employees. the view references variable in vm 'results' supposed observable array of employees. <section data-bind="foreach: results"> <article> <header> <form> <input type="text" data-bind="value: firstname" /> </form> </header> </article> </section> in viewmodel added result var , line in order automatically load employees results variable. /* defines todo application viewmodel */ window.todoapp.todolistviewmodel = (function (ko, datacontext) { var results = ko.observablearray(); var todolis...

Spring MVC Mixing xml and java @ContextConfiguration in integration test -

i trying configure spring mvc integration test using combination of xml config , @configuration annotated classes. @runwith(springjunit4classrunner.class) @webappconfiguration @testpropertysource({"/spring-security.properties", "/rabbitmq-default.properties", "/mongodb-default.properties", "/webapp-override.properties"}) @contexthierarchy({ @contextconfiguration("classpath:**/security-config.xml"), @contextconfiguration(classes = rootconfig.class), @contextconfiguration(classes = springmvcconfig.class) }) public class baseconfiguredmvcintegrationtest { } the java configurations initialized correctly. problem although "**/security-config.xml" file found , parsed during initialization... spring security beans defined in there never registered in webapplicationcontext . caused by: org.springframework.beans.factory.nosuchbeandefinitionexception:...

Android camera setPreviewSize and setPictureFormat exception on Samsung Galaxy Tab Active -

i have problem on 1 device @ field : samsung galaxy tab active parameters.setpreviewsize(1280, 720); parameters.setpicturesize(1280, 720); parameters.setpictureformat(imageformat.jpeg); leads to: full stack trace: java.lang.runtimeexception android.app.activitythread.performlaunchactivity(activitythread.java:2184) android.app.activitythread.handlelaunchactivity(activitythread.java:2233) android.app.activitythread.access$800(activitythread.java:135) android.app.activitythread$h.handlemessage(activitythread.java:1196) android.os.handler.dispatchmessage(handler.java:102) android.os.looper.loop(looper.java:136) android.app.activitythread.main(activitythread.java:5001) java.lang.reflect.method.invokenative(native method) java.lang.reflect.method.invoke(method.java:515) com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:785) com.android.internal.os.zygoteinit.main(zygoteinit.java:601) dalvik.system.nativestart.main(native method) caused by: android.hard...

awk - How to save each line in a text file as new file -

i have tab delimited text file 5 columns, , i'd each row own txt file contains information columns 2-5 , named after column 1. for example, txt file has hundreds of rows similar this: sample1name_oligos primer forwardseq reverseseq sample1name sample2name_oligos primer forwardseq reverseseq sample2name i'd have txt file named sample1name_oligos this: primer forwardseq reverseseq sample1name and txt file named sample1name_oligos looks this: primer forwardseq reverseseq sample1name i've tried 2 ways: 1. found thought solution: awk '{print substr($0,match($0,$2)) >> ( $1 ".txt" )}' filename (from http://www.linuxquestions.org/questions/linux-newbie-8/how-to-save-each-line-from-textfile-as-new-file-889795/ ) this worked test file made (5 rows), when run on 100+ rows file first 17 files out , error: awk: file18.txt makes many open files input record number 18, file myfile.txt source line number 1 i deleted r...

jsf - Avoid auto-instantiation of managed bean when injected as @ManagedProperty -

i have requestscoped bean can receive data 3 different viewscoped beans (from 3 different pages). beans jsf managed beans. when use managedproperty in request scoped 3 different view scoped beans, instantiates view scoped beans not want. want know bean being called , call specific method (different) each bean. how can check bean instantiated , in scope can call correct bean's method? looks it's pretty simple. reading 1 of balus's posts. used managedproperty(value="#{viewscope.managedbeanname}") . did not instantiate. inscope, gave me created bean :). happy

ios - Link UITableView delegate function back to other function -

i've created custom alert method, uitableview inside it. typedef void (^succes)(id data); typedef void (^failure)(nserror *error); + (void)testfortable:(nsstring *)title withsuccess:(succes)success failure:(failure)failure { sclalertview *alert = [[sclalertview alloc] initwithnewwindow]; alert.customviewcolor = [uicolor papercolorlightblue500]; [alert setshowanimationtype:slideinfromright]; uitableview *tableview = [alert addtableview]; tableview.delegate = self; tableview.datasource = self; [alert showedit:self title:@"test table" subtitle:@"this test alert table" closebuttontitle:nil duration:0.0f]; } #pragma mark - tableview methods + (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath{ return 40; } + (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { return 20; } + (uitableviewcell *)tableview:(uitableview *)t...

ruby - cannot load such file -

Image
i building own first gem. after created functionality ordered files best practice of gem building. i moved files right folders. executable in bin/boss-mailer , rest put in lib folder like: the executable simple. set executable ruby , try require boss_mailer.rb in lib file. this cannot load file. can require using require "./boss_mailer" beginning pointing current path. but in other gems on github see people use require "filename" reference loading file. here: gli gem my question do have pre-build gem or else require files without point current path? have require file lib/boss_mailer' without using ./ ? are using bundler ? recommend that. running binary as: bundle exec ./bin/boss_mailer.rb please make sure configure $load_path correctly in boss-mailer.gemspec correctly, if you've followed best practices you've done that.

html - font-awesome , when use attribute the icon disapear -

i have following code: <i class="fa fa-chevron-left"></i> but when add id , onclick attribute so: <i class="fa fa-chevron-left" id="back" onclick="backnews();"></i> the icon disappears. can see problem? the icon re-appears if remove attributes i have tried remove <i> , replace <span> tag, no luck. any suggestions welcome please check if site's css accident applies css rules #back . happen if use id="back" or onclick="backnews();" ? happen if change id this id="backnow" ?

registry - Script or bat file to remove a site from IE 11 Compatibility -

good afternoon, looking little doozy. we have gpo in place remove local site compatibility mode in ie11 but, our users continue add manually under own profiles. can't lock down so, thinking if run bat file locally remove , possibly check box options particular site, ideal. registry change/edit? script?

angularjs - Cannot read property 'open' of undefined -

i trying use angular-bootstrap keep getting error cannot read property 'open' of undefined here how i'm using it. in index.html i've included it <script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.12.1.min.js"></script> in app.js angular .module('myapp', ['ngroute', 'ngresource', 'ui.bootstrap', 'angulardjangoregistrationauthapp', 'http-auth-interceptor', 'angularpayments', 'angularapp']) in controller 'use strict'; angular.module('myapp') .controller('subscriptionctrl', ['$scope','$rootscope', 'djangoauth','loginrequired','validate','$location', function($scope, $rootscope, djangoauth, loginrequired, validate, $location, $modal) { $scope.open = function(index) { var modalinstance = $modal.open({ animation: $scope.a...

c# - How to get the correct Image height and width -

i trying calculate size of rectangle using height , width of image in project. image (icon) 20px w , 16px h. when load in imagelist , @ image size, shows 16px x 16px. i assume there compression being applied image, not experienced in area. need correct, dimensions. there way? note: not loading file disk... in project. this, simply, doing: var tabpage = _tabcontrol.tabpages[e.index]; var image = _tabcontrolimagelist.images[tabpage.imageindex]; var imagehw = math.max(image.height, image.width); you can , must declare imagesize want have, before load images imagelist : _tabcontrolimagelist.imagesize = new system.drawing.size(20, 16); afterwards images inside imagelist have following size: 20x16px .

Dynamic Array Size in C++ -

i looking way dynamically set size of integer array depending on passed parameter. example in pseudocode: int myfunction(int number) { int myarr[amount of digits in number]; } so when input 13456 int array[] size should 5. whats quickest way in c++, when don't know constant size? you cannot create array run-time size, must known @ compile time. recommend std::vector instead. one solution count characters after converting string #include <string> int myfunction(int number) { std::vector<int> myarr(std::to_string(number).size()); } mathematically, can take log (base 10) find number of digits in number. #include <cmath> int myfunction(int number) { int numdigits = static_cast<int>(std::log10(number)) + 1; std::vector<int> myarr(numdigits); }

python - Asking the user for input until they give a valid response -

i writing program must accept input user. #note: python 2.7 users should use `raw_input`, equivalent of 3.x's `input` age = int(input("please enter age: ")) if age >= 18: print("you able vote in united states!") else: print("you not able vote in united states.") this works expected if user enters sensible data. c:\python\projects> canyouvote.py please enter age: 23 able vote in united states! but if make mistake, crashes: c:\python\projects> canyouvote.py please enter age: dickety 6 traceback (most recent call last): file "canyouvote.py", line 1, in <module> age = int(input("please enter age: ")) valueerror: invalid literal int() base 10: 'dickety six' instead of crashing, try getting input again. this: c:\python\projects> canyouvote.py please enter age: dickety 6 sorry, didn't understand that. please enter age: 26 able vote in united states! how can accomplish this? i...

Adding extra bits in c bitfield -

i have update following structure add street information in structure. typedef struct address_tag { union { struct { unsigned state : 20; unsigned city : 10; unsigned unused :2; }; uint32_t address; }; } defect_address_t; i used unused bits , used 2 bits street: typedef struct address_tag { union { struct { unsigned state : 20; unsigned city : 10; unsigned street :2; }; uint32_t address; }; }address_t; the problem have reserve 10 bits street instead of 2. there way can add it? have make sure address 32 bits. the obvious solution take bits others, such state . if only, need no more 6 bits state. need bits state in city field, anyway. however, if concern memory (occupying no more 32 bits), can add possibilities enum , , have functions extract state/city/street. typedef enum state_city_street_t { cali...

robotics - Arduino Making Spiral -

i have robot sweeper creating detects walls , turns when getting distance not hit. movements pretty random , device start out making small circle , growing larger one. seems getting stuck in 1 size circle maybe little growth. created multiple size circle functions not seem taking hold. ahead of time. no matter how small appreciated. #include<newping.h> #define motor_a 0 #define motor_b 1 #define trigger_pin 5 #define echo_pin 4 #define max_distance 200 #define cw 0 #define ccw 1 const byte pwma = 3; const byte pwmb = 11; const byte dira = 12; const byte dirb = 13; newping sonar (trigger_pin, echo_pin, max_distance); void setup() { // put setup code here, run once: setupardumoto(); } void loop() { delay(50); unsigned int us= sonar.ping(); if(us/us_roundtrip_cm>50||us/us_roundtrip_cm==0) { forward(); curve(); //stopardumoto(motor_a); // stopardumoto(motor_b); } else if(us/us_roundtrip_cm>=90) { smallercurve(); } ...

c# - Any idea why this jquery datepicker control only loads part of the CSS? -

Image
developing c#/asp.net app , i've used datepicker control before. imported necessary bits 1 app new one. in old app, looks this: and in new app, looks this: as can see, background color right. background gradient image word "next" matches background image prev , next arrows, layout fubar. oh, , year dropdown overlays prev button , month dropdown. the jquery-ui datepicker / calendar tool formed 2 components. jquery build object , underlying css file. yours not same because classes , ids assigned not in same format defined calendar. if wish occur such, need run both next each other , inspect them. see particular set of classes, investigation see differences between 2 implementations. as sidenote: want make sure both jqueryui , css consistent way files match 1 another. overall, when apply css correctly, variant of calendar similar of original.

matlab - How to sort an array based on the values of the elements? -

a = [125,313,275,120] b = [277,715,823,450] i have 2 arrays , want sort , want apply same ordering b, meaning want have : know can use sort (a), don't know how b1. a1 = [120,125,275,313] b1 = [450,277,823,715] thank you. try: [a1, i] = sort(a); b1 = b(i);

UI-GRID - Convert A Cell To Date Format -

is there way in ui-grid convert column long value date string? is there way todo without having loop through each value? instead of looping, can add cell template column has date field. celltemplate:'<div class="ui-grid-cell-contents">{{grid.appscope.showdate(123123123)}}</div>' and create showdate method in scope $scope.showdate = function(value) { return new date(value); } you can format date in showdate.

jquery - Javascript Test for Multiple Selection Menu -

this edit check on multiple select field search form. when selection made in multiple select field , form submitted, empty() function logs "user made selection", part works. however, if no selection made, empty() function not log "no selection made". if no selection made in field, won't variables cityselectedvalue , cityselectedhtml null and/or undefined? believe script found checks that? not sure if setup jsfiddle correctly. if not, let me know , i'll fix it: https://jsfiddle.net/ibuprofen/077qxk01/ try code: https://jsfiddle.net/077qxk01/31/ this function rsponsible getting proper information selected options. extract values or text: function getselectvalues(select) { var result = []; var options = select && select.options; var opt; (var i=0, ilen=options.length; i<ilen; i++) { opt = options[i]; if (opt.selected) { result.push(opt.value || opt.text); } } return result; } as jsfiddle ...

javascript - Fill input field, with twig value using jquery -

i've been searching while no luck. i know question looks mundane, , has plenty (as in hundreds) of answers out in google , here, yet, still problem seems far solved. i have following problem, need fill input field, value silex variables in twig file. the form follows: <span>author: </span> <input type="text" name="author" id="author" {% if user.getauthorname %}value="{{user.getauthorname}}"{% endif %} /> <span><a href="#" id="filler">use own username</a></span> and js code is: <script> $(function(){ $('#filler').live('click', function() { $("#author").val($("#author").text("{{user.getfirstname}} {{user.getlastname}}")); }); }); </script> the problem i'm having is, code works, yet still, when click, fills field with [object object] instead of actual value of 2 variables i've tr...

php - Morris Donut chart with data from mysql -

Image
with below code trying create morris donut chart. not getting output expected. first time trying create morris chart fetching data mysql. if big mistake, please forgive me. here code "morris.php" <?php require_once('connection.php'); ?> <html> <head> <link rel="stylesheet" href="morris.css"> <script src="jquery.min.js"></script> <script src="raphael-min.js"></script> <script src="morris.min.js"></script> <meta charset=utf-8 /> </head> <body> <?php $sql= "select wlt_txn_cat cat , sum(wlt_txn_amount) amt wallet_txns wlt_txn_type = 'expense' group wlt_txn_amount desc"; $result = mysqli_query($globals["___mysqli_ston"], $sql) or die(((is_object($globals["___mysqli_ston"])) ? mysqli_error($globals["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : fals...

actionscript 3 - Find the most recent date from an Array -

how find recent date array 1 below? tue jun 2 17:59:54 gmt+0200 2013 tue jun 5 18:00:10 gmt+0200 2013 tue jun 1 12:27:14 gmt+0200 2013 tue jun 3 17:26:58 gmt+0200 2013 tue jun 9 17:27:49 gmt+0200 2013 tue jun 1 13:27:39 gmt+0200 2015 tue jun 3 12:27:59 gmt+0200 2013 tue jun 6 15:27:22 gmt+0200 2014 tue jun 2 17:27:30 gmt+0200 2014 assuming array full of as3 native date objects, this: array.sorton("time",array.descending); trace("most recent:",array[0]); you cannot use array.sort (unless use array.numeric flag) because sort string representation of date. days of week grouped instead of actual date. if dates strings, need convert them date objects prior sorting: //assuming posted array in var called 'stringarray' var datearray:array = []; //a new array hold converted strings for(var i:int=0;i<stringarray.length;i++){ datearray.push(new date(stringarray[i])); } datearray.sorton("time",array.descending); trace(...

npm - yo generator stuck - TypeError: Cannot read property 'addListener' of null -

i'm trying create own simple "hello world" yeoman generator. simple one. i installed yeoman generator . npm install -g generator-generator then tried run it. yo generator _-----_ | | .--------------------------. |--(o)--| | create own yeoman | `---------´ | generator | ( _´u`_ ) | superpowers! | /___a___\ '--------------------------' | ~ | __'.___.'__ ´ ` |° ´ y ` ? mind telling me username on github? my-name ? what's base name of generator? test i stuck here 10 minutes .... then, decide kill - control + c , got this. /usr/local/lib/node_modules/yo/node_modules/inquirer/node_modules/rx/dist/rx.js:579 throw e; ^ typeerror: cannot read property 'addlistener' of null @ function.observable.fromevent (/usr/local/lib/node_modules/yo/node_modules/inquirer/node_modules/rx/dist/rx.async.js:426:16) @ module.export...

C# DatagridView shows 0 columns -

this question has answer here: datagridview has no columns 1 answer i'm creating datagridview , using datatable populate it. my c# datagridview dgv = new datagridview(); datatable dt = new datatable(); dt.columns.add("col_1"); dt.columns.add("col_2"); for(int i=0; i< mydictionary; i++) { dt.rows.add(mydictionary.key, mydictionary.value); } dgv.datasource = dt; for(int j=0; j < dgv.columns.count; j++) {...} // count 0... i'm looking access columns can dgv.columns[j].autosizemode = datagridviewautosizecolumnmode.fill; q: how can have datagridview reflect columns properly? you have set property autogeneratecolumns true : dgv.autogeneratecolumns = true; dgv.datasource = dt;

Backend for WoIP on WebRTC, asterisk? -

i want add feature on site: receiving phone calls in browser. best way realize (backend)? read asterisk bad choise webrtc protocol. me advice, me do? or link article that. it's difficult answer without more details constraints have, , answers mention using hosted js sdks quick solution doesn't require build , maintain own infrastructure. for concerns observation on asterisk, it's not true can't support webrtc. take @ respoke , digium's "webrtc extension" asterisk. asterisk module free, service comes @ price. still in area of building own infrastructure, should take @ freeswitch , 'verto' module . in case you're not constrained use non-free service, need build signalling platform too. a popular webrtc/voip gateway janus , may find interesting.

Close jQuery UI dialog from page loaded within iframe -

i know there lot of threads regarding topic out there, none of them have helped me in trying do. i attempting old system away window.showmodaldialog() , using jquery ui dialogs, , trying minimal changes, turning issue because of of outdated javascript , stuff in here. initial page: $(document).ready(function(){ $("#searchdialog").dialog({ position: "center", autoopen: false, draggable: false, resizable: false, height: 650, width: 650, modal: true, dialogclass: 'searchdialog', closeonescape: true }); $('.searchdialog .ui-dialog-titlebar').each(function () { $(this).css("display", "none"); }); }); <div id="searchdialog" style="display:none; height: 650px; width:650px;"> ...