Posts

Showing posts from February, 2013

How to get the javascript to the clients, and how to implement caching when building a TMS? -

i looking @ making own tag management system, or tms: system manages javascript snippets on many sites, analytics , ad-snippets, in such way can, example, change google analytics piwik analytics changing 1 tag. automatically propagate alle other connected sites. i've looked @ available options, , either expensive, or far more feature rich need. in case, google not friend, there numerous marketing type articles tms'es , entirely eclipse articles technical challenges , how to's (if there any). the main problems see how javascript code sites connected tms, , doing without having call tms every time. does have idea this? their 2 parts app. first management console, user defines tags: ga, piwik etc. the second client, user installs small javascript snippet, of ga, installs script tags based on settings in console. the client how java-script code sites, need contact server form of api key, return script tags, , or java-script code required website, client i

javascript - AngularJS Ajaxify entire website -

i' working history api , jquery in order ajaxify website. all links fires ajax calls retrieve page , replace actual content fetched content, user can navigate without page reload. how can achieve using angularjs ? i took @ $location doc, , created directive on links. directive stop default event , use $location.path() set new url. angular.module('directives.ajaxnavigation', []) .directive('a', ['$location', function($location) { return { link: function(scope, ielement, iattrs) { ielement.bind('click', function(e) { console.log(ielement.attr('href')); scope.$apply($location.path(ielement.attr('href'))); e.preventdefault(); }); } } }]); how can capture "urlchange" event in order make ajax call each time fired ?

ios - CATransform3D UIImageView in UIScrollView -

i attempting apply m34 transformation using catransform3drotate . current structure have uiscrollview hosts uiimageview . image view must able zoomed , rotated usual. there 3d mode, similar apple maps 3d mode, have been attempting simulate using m34 transform. two problems, first, zoom resets transform. second, transform zooms image. what correct way of handling this?

python - Pyinstaller add icon, launch without console for Mac -

this short question. have created package mac using pyinstaller , trying add icon it. trying program run without launching terminal user has no interaction terminal. keeing following cmd when running pyinstaller: python pyinstaller.py --icon=group.ico --onefile --noconsole gesl_timetabler.py i regular package (unix executable) , app. unix executable works , no processes run when double click app. also, neither app, nor unix executable, has icon image displayed. sure trivial problem command pyinstaller, having difficulty figuring out mistake. me fix instructions above? thank you! try using --windowed instead. far can tell they're same thing, might trick. as icons, i've gotten work on console windows. doesn't carry on main gui window.

javascript - Ajax form submission on a form created using jquery -

i using table different rows , edit button on each row. this edit button creates form using ajax / json fill form details depending on row clicked. the problem comes when creating ajax form. im using same method always, reason ajax submission not working on form , going process php page. im wondering if because form not on page when javascript code ajax call loaded? so example: 1) page loaded , included on page is: <script type="text/javascript" src="admin/js/showuserdetailsform.js"></script> <script type="text/javascript" src="admin/js/saveuserdetails.js"></script> 2) click edit, , showuserdetailsform.js creates form. form this: $('<div id="admin-edituser-popup">'+ '<div id="login-popup-title">edit user:<button id="closeedituserform">close</button></div>'+ '<div id="login-popup-centre">'+ '

preg match all - error in php code using preg_match_all -

hello done code need :) keep give me nothing , no result ok here code <?php $f=' <tr class="hover"> <td class="ra " >3.</td> <td class="pla " ><a href="spieler.php?uid=3010">الـعـاصـفـة</a> </td> <td class="al " ><a href="allianz.php?aid=127">|brave|</a></td> <td class="pop " >2519</td> <td class="vil " >6</td> </tr> <tr class="hover"> <td class="ra " >3.</td> <td class="pla " ><a href="spieler.php?uid=4292">look</a> </td> <td class="al " ><a href="allianz.php?aid=127">|brave|</a></td> <td class="pop " >2001</td>

angularjs - keeping the view up to date -

i banging head on brick wall, have been hours , hours.... i have controller gets list of objects stored in pouchdb via factory uses angularjs promise return answer it's asynchronous request outside flow of angularjs app. works fine , returns objects. i have controller uses external rest api carry out search more objects, on results screen have "add" button adds object pouchdb. my problem no matter try, tutorials follow, answers read cannot first list of objects update when new objects added. does have idea should doing here? if it's sensible? there better way of doing this? nested controllers maybe? any advice gratefully received. it's impossible tell without knowing more code, common mistake happens not being mindful of different scopes angular creates. can use chrome extension angularjs batarang debug scopes. simple debugging set window property scope in controller (i.e. window.sc1 = $scope; ) , check out values in console. specif

How can I prevent maximizing a JavaFX window to fullscreen? -

i have done this... mystage.initstyle(stagestyle.utility); which works fine removing maximize button can still double click on window title bar (in windows) maximize window. i tried not fire. mystage.fullscreenproperty().addlistener(new changelistener<boolean>() { @override public void changed(observablevalue<? extends boolean> prop, boolean wasiconified, boolean isiconified) { system.out.println("ignore fullscreen"); } }); is there other way consume event has no effect? if don't want user resize window @ all, can set stage's resizable property false.

ruby - How to install rfuse on ubuntu? -

solved - see below. i trying install rfuse gem on ubuntu 12.04 vagrant image. in it's extconf , checks fuse , fails. i have apt-get installed fuse , fuse-utils , , /lib/libfuse.so.2 exists. tried session below, which: replicates failure uses nm verify main function exist in library (i don't know if valid.) try ensure library found using ld_library_path (not sure if valid either) i'm stuck because i'm not sure how failing. not finding library? if is, not finding right function? looking libraries? other techniques have debug this? vagrant@n1:~$ ruby2.1 -rmkmf -e 'have_library("fuse")' checking main() in -lfuse... no vagrant@n1:~$ nm -d -c -g /lib/libfuse.so.2 | grep main 0000000000016080 t cuse_lowlevel_main 0000000000016570 t fuse_main 0000000000016840 t fuse_main 0000000000016860 t fuse_main_compat1 0000000000016840 t fuse_main_compat2 0000000000016880 t fuse_main_real 0000000000016890 t fuse_main_real 0000000000016830 t fuse_ma

java - Netbeans GUI builder - custom class properties category -

Image
i want know how categorize properties of custom jcomponent in netbeans gui properties editor. so anyways. there property "key" in there , under category "other properties". how make new property category under category example "special properties"? the code in question this: public void setkey(string ke) { //functionality } public string getkey() { return k.gettext(); } i know possible. saw such feature somewhere long time ago cannot find back.

opengl - Should primitives be centered in a 3d engine? -

so, i'm adding physics game engine right , physics engine expects vertices of primitive distributed around 0,0,0. primitive cubes vertice positions range 0 1 in every dimension. should center cubes around 0,0,0 or shift vertices when giving them physics engine , when reading position of rigidbody ? depends on physics engine, it's easiest work if physics system can assume object's center of mass @ 0,0,0. cube primitives, if think rotating , scaling them, should come conclusion 0,0,0 center convenient operations well.

html - Font Size to Re-size Based on Window Size -

is there simple way make font re-size based on window size? for example, font bigger on desktop on mobile device. way, users on smaller screen not have font take room. i tried using "px" "em" , "%" none of them seem work. the best way have found use little trick coupled media queries. set body element's font-size in px (some people explode use of px font sizes instead of em , personal preference). example: body{ font-size: 20px; } i set other elements percentage of body element. if want h1 s 30px set them like: h1 { font-size: 150%; /* (30/20) * 100 = 150 */ } however, may pertinent have element fixed font size @ screen sizes, example you're using glyph font , want have icons stay particular size alignment purposes. in case use set px height again. example: .icon { font-size: 15px; } what means rather having change whole lot of different element's font-sizes @ different screen widths, have change body eleme

ruby on rails - Item in Active Record that gets created by default on rake db:create -

or along lines. have belongs_to relationship, want have belongs_to relationship default 'unknown entity' type of item. make reporting on items don't belong easy, , won't have force creation of entity belongs on creation of item, things that. best way this? want item automatically created when database created or when migrations run. can put migration somehow? i found answer in sidebar related question. i use db:seed option, execute in seeds.rb file. more info can found here similar question. http://codedecoder.wordpress.com/2013/04/25/rake-db-seed-in-rails/

Convert code from actionscript to python -

i trying convert project actionscript python. here actionscript code: private static function parsestuff(_arg1):string{ var _local4:string; var _local5:int; var _local2 = ""; var _local3:int; while (_local3 < _arg1.length) { _local4 = _arg1.substr(_local3, 1); _local5 = _local4.charcodeat(0); if ((((_local5 >= 48)) && ((_local5 <= 57)))){ _local4 = string((int(_local4) ^ 1)); }; _local2 = (_local2 + _local4); _local3++; }; return (_local2); } and here attemp in python local4='' local5=0 local2='' local3 = 0 while (local3<len(arg1)): local4 = arg1[1:] local5 = int(local4[0].encode("hex")) if ((((local5 >= 48)) , ((local5 <= 57)))): local4 = str((int(local4) ^ 1)) local2 = (local2 + local4) local3 =

ruby on rails - rubymine debug rspec Uncaught exception: cannot load such file -- teamcity/spec/runner/formatter/teamcity/formatter -

i setup rails project , cant rspec run in rubymine. here testing gems: group :development, :test gem 'rspec-rails' gem 'shoulda-matchers' gem 'factory_girl_rails', require: false end group :test gem 'faker' end and here error message /users/dude/.rvm/rubies/ruby-2.1.2/bin/ruby -e at_exit{sleep(1)};$stdout.sync=true;$stderr.sync=true;load($0=argv.shift) /users/dude/.rvm/gems/ruby-2.1.2@myproject/gems/ruby-debug-ide-0.4.23.beta1/bin/rdebug-ide --disable-int-handler --port 53125 --dispatcher-port 53126 -- /users/dude/.rvm/gems/ruby-2.1.2@myproject/bin/rspec /users/dude/code/myproject/spec/models/instagram_user_spec.rb --require teamcity/spec/runner/formatter/teamcity/formatter --format spec::runner::formatter::teamcityformatter --example instagramuser --require /applications/rubymine.app/rb/testing/patch/bdd/teamcity/spec/runner/formatter/teamcity/rspec3_formatter.rb testing started @ 9:03 pm ... fast debugger (ruby-debug-ide 0.4.23.beta1

node.js - Node Redis Async -

i have simple function tokenexists checks see whether token part of redis set . know resp coming undefined because final line of code running before function done making request , getting response redis . have read many articles on handling async nature of redis node of had either multi-line commands or express , route specific issues. wondering how make code synchronous. function tokenexists(token, callback) { db.sismember("tokens", token, function(err,res) { if (err) throw err; callback(null, parseint(res, 10) === 1); }); } function generatetoken(){ try { var token = urlsafebase64(crypto.randombytes(23)); } catch (ex) { console.log(ex) } tokenexists(token, function(err,res){ if (err) throw err; res ? token : generatetoken(); }) } ^^ method returning 'undefined' you can't. the database call async have use callback tokenexists function. function tokenexists(token, callback) { db.sismember(&quo

Android Wear: Not sync my app to Watch. Why? -

i has published android wear app. installed app on google play , tried sync androwid wear via google android wear app didn't work. i guess apk installed doesn't include "wear.apk". how can include it? when generated apk on android studio, 2 apks generated. uploaded 1 apk "application.apk". expected "application.apk" included "wear.apk". build.gradle has dependency of wear. wearapp project(':wear') does knows possible reasons , solutions. any appreciated. thanks, [update1] ・application module androidmanifest.xml <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.hogehoge.bip" > <uses-feature android:name="android.hardware.camera" android:required="false" /> <uses-feature android:name="android.hardware.camera.autofocus" /> <uses-permission android:name="android.permission.camera&q

c - something wrong with my dynamic array -

while add more 13 element, result seems not correct! code below! when add 12 elements, result the no.0 0 no.1 1 no.2 2 no.3 3 no.4 4 no.5 5 no.6 6 no.7 7 no.8 8 no.9 9 no.10 10 no.11 11 when add 1 more, result changed lot, have no idea what's going on here: the no.0 0 no.1 1 no.2 2 no.3 3 no.4 4 no.5 5 no.6 6 no.7 7 no.8 0 no.9 1 no.10 2 no.11 3 no.12 12 #include<stdio.h> #include<stdlib.h> typedef struct dynarray myarray; struct dynarray { int size; int length; int *array; }; myarray *create(void) { /* todo: define arrays */ myarray *da; da = malloc(sizeof(myarray)); da->size = 0; da->length = 3; da->array = (int *)malloc(da->length * sizeof(int)); return da; } void add(myarray *array, int val) { int i; int length = array->length; int size = array->size; int *temp; //printf("da->size1 = %d\nda

asp.net - Could not load file or assembly 'Microsoft.Xrm.Client, Version ERROR -

i'm creating asp web app connect crm. got error every time run application: error not load file or assembly 'microsoft.xrm.client using microsoft.xrm.client.dll version: 5.0.9690.2165 reference give error : could not load file or assembly 'microsoft.xrm.client, version=5.0.9689.2166, culture=neutral, publickeytoken=31bf3856ad364e35' or 1 of dependencies. located assembly's manifest definition not match assembly reference. (exception hresult: 0x80131040) but when replace dll microsoft.xrm.client.dll version: 5.0.9689.2166 reference give error: could not load file or assembly 'microsoft.xrm.client, version=5.0.9690.2165, culture=neutral, publickeytoken=31bf3856ad364e35' or 1 of dependencies. located assembly's manifest definition not match assembly reference. (exception hresult: 0x80131040) and cant add both version reference. i'm confused version on of microsoft.xrm.client.dll version use debug error. please let know

ruby - Create Array url_options for rails -

my rails application default url post _http://0.0.0.0:3000/posts/7, how can display url _http://0.0.0.0:3000/posts/cer4235235ft5435rerjk343f numbers , text. create column in database, update alpha numeric string, , use column querying. eg: add column permalink posts table class post < activerecord::base before_create :create_permalink def create_permalink self.permalink = securerandom.hex end .. change links use string <%= link_to post.title, post_path(:id => post.permalink) %> modify controller def show @post = post.where(:permalink => params[:id]).first end

How to load with jQuery only once, then use selectors without additional HTTP requests -

could me code, please? jquery(document).ready(function(){ jquery('#div1').load('/text.php #p1'); jquery('#div2').load('/text.php #p2'); jquery('#div3').load('/text.php #p3'); jquery('#div4').load('/text.php #p4') }); when using code, browser makes http request time when needs open same file text.php . difference in selectors. can tell me if it's possible load file text.php once, , use selectors fill content of different div s? you can use request try like jquery(function ($) { $.get('/text.php', function (html) { var $html = $('<div />', { html: html }); $('#div1').empty().append($html.find('#p1')) $('#div2').empty().append($html.find('#p2')) $('#div3').empty().append($html.find('#p3')) $('#div4').empty().append($html.find('#p4')) }, 'html'

opengl es - Screen co-ordinates to Normalised device co-ordinates -

i have screen co-ordinates x=216,y=726,w=504,h=284 , need convert these normalized device co-ordinates [-1,1] before drawing using gldraw in opengles. please appreciated. relatively new opengles. thanks in advance. generally, when mapping coordinates 1 coordinate system another, here's procedure: targetposition.x = targetleftmost + (sourceposition.x / sourcewidth) * targetwidth targetposition.y = targettopmost + (sourceposition.y / sourceheight) * targetheight so you, should be: targetposition.x = -1 + (sourceposition.x / 504) * targetwidth //(targetwidth = 2?) this should started.

javascript - Google maps api v2 on Cordova: not sentitive to events? -

in cordova, open map shows markers when initialized. in code, create map , wait event map_ready add markers. way ? var map; document.addeventlistener("deviceready", function() { var button = document.getelementbyid("button"); button.addeventlistener("click", onbtnclicked, false); var div = document.getelementbyid("map_canvas"); map = plugin.google.maps.map.getmap(div); }, false); map.addeventlistener(plugin.google.maps.event.map_ready, function(map) { map.getmylocation(function(location) { var msg = ["current location:\n", "latitude:" + location.latlng.lat, "longitude:" + location.latlng.lng].join("\n"); map.addmarker({ 'position': location.latlng, 'title': msg }, function(marker) { marker.showinfowindow(); }); }); }); with code, marker not added. works if use bu

How can I recreate this masking effect in CSS/JavaScript? -

Image
i'm trying recreate effect shown in gif here. it's fine have 2 separate images - don't need recreate greyscale/blur effect (although can webkit filters) - it's masking i'm having trouble with. basically i've got carousel slider, , slides left , right, background underneath current slide blurred, make text on top more visible. can't manage keep background in same place slider moves along mask. how can recreate this? edit: i've managed figure out: http://jsfiddle.net/9xk410wk/18/ used css transforms in opposite directions: .tile { -webkit-transform: translate3d(-400px, 0px, 0px); } .blur > div { -webkit-transform: translate3d(400px, 0px, 0px); } .tile:hover { -webkit-transform: translate3d(400px, 0px, 0px); } .tile:hover .blur > div { -webkit-transform: translate3d(-400px, 0px, 0px); } you use webkit grayscale filter this: fiddle (hover on image see effect) markup <div class="pic"> <

c# - Random row from Linq to Sql with no duplicate -

what best (and fastest) way retreive random rows using linq sql unique data / no duplicate record? oh preffer in 1 statement, possible? found relevant question don't think approach resulting unique records. i have tried far : //first approach airasiadatacontext linqdatactx = new airasiadatacontext(); var tes = (from u in linqdatactx.users.asenumerable() orderby guid.newguid() select u).take(5); //second approach var usr = u in linqdatactx.users select u; int count = usr.count(); // 1st round-trip int index = new random().next(count); list<user> tes2 = new list<user>(); (int = 0; < 5; i++) { tes2.add(usr.skip(index).firstordefault()); // 2nd round-trip } as can see above, have tried 2 solution, works, above codes did not resulting unique records, there chances duplicate. db.tablename.orderby(x=>guid.newguid()).firstordefault(); if want take unique data / no duplicate record, you'd bett

javascript - How to give the row and col positions of a node in Cytoscap JS -

i have nodes want place in specific location within grid. in cytoscape js defined data follows: nodes: [ { data: { id: '1', name: 'cytoscape1', row: '1', col:'1' } }, { data: { id: '2', name: 'cytoscape2', row: '2', col:'3' } }, { data: { id: '3', name: 'cytoscape3', row: '1', col:'3' } }, { data: { id: '4', name: 'cytoscape4', row: '1', col:'4' } } ] i want use col , row data setting node position. i've added in following grid layout options graph: layout: { name: 'grid', padding: 10, rows: 4, columns: 4, position: function( node ){ return {node.row, node.col}; } } my problem concerns function returning row , col position of node. reason piece of code doesn't work , couldn't find examples used option. when testing in live example gives syntax error. i've tried many d

angularjs - Converting angular-dragdrop to work with firebase $asArray -

pretty new angularjs , firebase here, trying convert angular-dragdrop.js per following link below work angularfire 0.8.0 $asarray feature: https://github.com/codef0rmer/angular-dragdrop/blob/master/src/angular-dragdrop.js i wondering if following changes sufficient: 1) include firebase within function declaration (function (window, angular, firebase, undefined) { 2) include $firebase within jqyoui callback function var jqyoui = angular.module('ngdragdrop', []).service('ngdragdropservice', ['$firebase', '$timeout', '$parse', function($timeout, $parse) { 3) change "push" , "splice" update on dropmodelvalue , dropmodelvalue $add , $remove instead. dropmodelvalue.$add(dragitem); 4) add $save after dropmodelvalue , dropmodelvalue assignments dragmodelvalue[dragsettings.index] = dropitem; dragmodelvalue[dragsettings.index].$save(dragsettings.index); your appreciated. in advance. you can utilize $ex

c# - Determine which thread exception occurred in DispatcherUnhandledException -

i have wpf app in using tasks invoke new threads. have app_dispatcherunhandledexception event in code catch areas occur on thread, works fine. purposes of logging i'd determine whether exception occured on main thread or on task. possible? the event args object has dispatcher property, has thread property: dispatcher.unhandledexception event - http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.unhandledexception(v=vs.110).aspx dispatcherunhandledexceptionfiltereventargs class - http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcherunhandledexceptionfiltereventargs(v=vs.110).aspx dispatchereventargs.dispatcher property - http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatchereventargs.dispatcher(v=vs.110).aspx you can name threads, or store managed id of main 1 identify thread that. hope helps!

c# - WP8 App opens by tapping on Toast -

i'm developing application windows phone 8. need check if app opened tapping on toast notification. how can that? suppose cannot information toast. if check out msdn article here http://msdn.microsoft.com/en-us/library/windows/apps/jj662938(v=vs.105).aspx , you'll see possible add information toast can use in app! deep linking screen using toast notifications can use param element or navigateuri property, depending on how you're creating toast notification, deep link specific screen in app. here allowed formats. string used following examples must 256 characters or less. /page1.xaml – defines screen navigate in app when app starts. string must begin "/". /page1.xaml?value1=1234 &value2=9876 – defines screen navigate when app starts, along name/value pairs of info. string must begin "/". ?value1=1234 &value2=9876 – contains name/value pairs of info passed default start screen of app. string must begin "?".

java - How to solve my try-catch exception handling? -

i'm having problems try-catch exception here. prompt user name of text file say, robot.txt if file not exist, have make sure application reprompts user file name. hope guys can understand i'm still newbie here please feel free provide suggestions or advices on coding etc. cheers! main method class: import java.io.*; import java.util.scanner; import java.util.vector; class testvector3 { public static void main(string [] args) { system.out.println("please enter name of text file read: "); scanner userinput = new scanner(system.in); vector <killerrobot> robotdetails = new vector <killerrobot>(); killerrobot robot; scanner fileinput = null; try { file textfile = new file(userinput.nextline()); fileinput = new scanner(textfile); } catch (filenotfoundexception e) { system.out.println("error - file not found!"); system.out.println("re-enter file name :");

javascript - Moment.js diff of two moments defined by week and weekday gives wrong result -

i want calculate difference between moment (itemmoment) , (nowmoment) defined weekday, hour , minute. if itemmoment before nowmoment (diff < 0) want add 1 week , calculate difference again, addition of week (week: week + 1 in code )somehow doesn't change difference , still negative difference. it's first time use moment.js library may don't how use correctly. great if experienced used help. var = moment(); var year = now.year(); var week = now.week(); var weekday = now.weekday(); var hour = now.hour(); var minute = now.minute(); var itemmoment = moment({ day: item.weekday, hour: item.hour, minute: item.minute }); var nowmoment = moment({ day: weekday, hour: hour, minute: minute }); if (itemmoment.dif

direct3d - Why the texture blurred ? I need it keeps the same resolution of the source image -

the source image 1920x1200 px. here render function: void render() { // clear backbuffer , zbuffer g_pd3ddevice->clear( 0, null, d3dclear_target | d3dclear_zbuffer, d3dcolor_xrgb( 0, 0, 255 ), 1.0f, 0 ); // begin scene if( succeeded( g_pd3ddevice->beginscene() ) ) { g_pd3ddevice->setsamplerstate(0, d3dsamp_addressu, d3dtaddress_border); g_pd3ddevice->setsamplerstate(0, d3dsamp_addressv, d3dtaddress_border); g_pd3ddevice->setsamplerstate(0, d3dsamp_bordercolor, 0x000000ff); g_pd3ddevice->settexture( 0, g_ptexture ); // render vertex buffer contents g_pd3ddevice->setstreamsource( 0, g_pvb, 0, sizeof( customvertex ) ); g_pd3ddevice->setfvf( d3dfvf_customvertex ); g_pd3ddevice->drawprimitive( d3dpt_trianglelist, 0, 2);//2 * 50 - 2 ); // end scene g_pd3ddevice->endscene(); } // present backbuffer contents display // s

java - Change TextureView Size at Runtime -

i working on streaming mp4 textureview app working on. have textureview displaying video need resize match screen size on rotation. after trial , error seems problem textureview cannot made larger containing view. have tried resize container view unable center textureview correctly on screen. public void onorientationchanged(int orientation) { if(islandscape(orientation)){ mytexture.setrotation(-90); relativelayout.layoutparams params = new relativelayout.layoutparams(relativelayout.layoutparams.wrap_content, relativelayout.layoutparams.wrap_content); params.width = height; params.height = (height * 9)/16; params.addrule(relativelayout.center_in_parent, relativelayout.true); mytexture.setlayoutparams(params); mytexture.getlayoutparams().height = (height * 9)/16; mytexture.getlayoutparams().width = height;

Store global strings in iOS in Swift for app-wide use -

i designing app has login screen. when user enters username , password, call web service done returns token on successful login. need send token every http call inside different screens across app. i want achieve similar functionality this: where store global constants in ios application? as there won't .h , .m files in swift, how store these global strings (note these not constants, these global variables) need able access in view controller this wanted: sharing strings , variables throughout ios app i able share strings such apikeys, tokens using nsuserdefaults saving: nsuserdefaults.standarduserdefaults().setobject("apistringhere", forkey: "apikey") nsuserdefaults.standarduserdefaults().synchronize() getting: nsuserdefaults.standarduserdefaults().objectforkey("apikey")

ios - in UITableView first entry and last entry switching record data when loading from server -

i developing app display data server in parallax type uitableview , , here code. loading great, cell data(image, etc) keep switching 1 cell another. - (void)viewdidload { [self hasinternet]; self.tableview.datasource = self; self.tableview.delegate = self; [self loaddata]; self.edgesforextendedlayout=uirectedgenone; self.extendedlayoutincludesopaquebars=no; self.automaticallyadjustsscrollviewinsets=no; [super viewdidload]; } - (void)viewwillappear:(bool)animated { [self scrollviewdidscroll:nil]; [super viewwillappear:animated]; [self loaddata]; self.tableview.datasource = self; self.tableview.delegate = self; } - (void) loaddata{ name = @"name"; email = @"email"; thumbnail = @"thumbnail"; myobject = [[nsmutablearray alloc] init]; nsdata *jsonsource = [nsdata datawithcontentsofurl:[nsurl urlwithstring:@"http://url.php"]]; id jsonobjects = [nsjsonserialization jsono

Floating point exception in C -

#include <stdio.h> #include <math.h> #include <string.h> long fctl(int n){ int a=1,i; for(i=n;i>1;--i) a*=i; return a; } long ch(int n, int r){ return fctl(n) / (fctl(n-r)*fctl(r)); } int main(){ char *hands[] = {"onepair", "twopair", "triple", "straight", "flush", "fullhouse", "fourofakind", "straightflush", "royalflush"}; double handprobs[9]; handprobs[0] = ch(13,1)*ch(4,2) * ch(12,3)*pow(ch(4,1), 3) / ch(52,5); handprobs[1] = ch(13,2)*pow(ch(4,2), 2) * ch(11,1)*ch(4,1) / ch(52,5); handprobs[2] = ch(13,1)*ch(4,3) * ch(12,2)*pow(ch(4,1), 2) / ch(52,5); handprobs[3] = 10.0 * pow(ch(4, 1),5) / ch(52, 5) - 10.0/ch(52,5) - 4.0/ch(52,5); handprobs[4] = ch(13,5)*ch(4,1) / ch(52, 5) - 10.0/ch(52,5); handprobs[5] = ch(13,1)*ch(4,3) * ch(12,1)*ch(4,2) / ch(52,5); handprobs[6] = ch(13,1)*1 * ch(12,1)*ch(4,1) / ch(52,5); handprobs[7] = 40.0 / ch

wordpress - Password protect user viewing in WP or Joomla -

i hoping if know extension or plugin either wordpress or joomla (preferably), can restrict unauthorized visitors viewing full profile information? what trying achieve this: http://keepmesafeid.com/lost.php?id=1ba0846587744383fa518b7e642ff632 visitors can't view full profile information before entering password associated profile. each profile have unique password associated visitor needs enter, before visitor can see full profile info. i hope of guys can me out here.

Meaning of Discriminated Union in F# -

i understand meaning of "discriminated" , "union" in standalone contexts, @ loss when comes f#'s "discriminated union". fyi, english not first language , not @ math either. hope out there can shed light on feature of f#. please. what need know is: the use case discriminated union. used for? it's equivalent other oop feature/terms. if there's any. is set operation use venn diagrams represent data? or can me pointing links. a discriminated union union of 2 sets can tell set item belonged to; if same thing, can discriminate between them, i.e. tell them apart. for instance, if have discriminated union of 2 sets of integers, both containing number 2 , can discriminate between 2 s because know original set came from. as example, consider points in 2-dimensional plane. these can expressed pair of reals in 2 ways, either using rectangular (or cartesian) coordinates (x coordinate, y coordinate) or using polar coordinate

android - Draw canvas rectange with animation -

Image
i draw rectangle canvas. draw rectangle wobble animation. example: have drawn gray rectangle, when click on rectangle draw red rectangle animation. code draw rectangle ready. don't know how can animate rectangle.

ember.js - Best Practice for Creating New Record with belongsTo Relationship -

i wondering best practice creating new record in ember createrecord() , persisting api? specifically, should ember's post request single json embeds model's relationships, or customary post each relationship individually? in code, i'm not able single json, i'm wondering if i'm missing "ember way" or (more likely) have mistake in code? details: here details of setup. have 2 models: /models/orguser.js: ds.model.extend({ ... orgperson: ds.belongsto('org-person', { inverse: 'org-user', async: true, embedded: 'always' }), }); /models/orgperson.js: ds.model.extend({ ... orguser: ds.belongsto('org-user'), }) i'm attempting create new user on "create new user" page. route page below. best place call createrecord() new models? /routes/org-users/add.js: ember.route.extend({ model: function() { var orgperson = this.store.createrecord('org-person');

ios - Crash on textfield become first responder with pickerview -

so i've been trying pickerview working can't work. when run app crashes without stacktrace , shows thread 1: exc_bad_access on [textfield becomefirstresponder]. pickerarray correct, that's not problem. #import "testviewcontroller.h" #import "findclasses.h" @interface testviewcontroller () @property uipickerview *picker; @property nsarray *pickerarray; @property (nonatomic, strong) findclasses *finder; @end @implementation testviewcontroller @synthesize finder = _finder; - (findclasses *)finder { if (!_finder) _finder = [[findclasses alloc] init]; return _finder; } - (void)viewdidload { [super viewdidload]; self.pickerarray = [self.finder findclassesintimetable]; self.classfield.delegate = self; self.picker = [[uipickerview alloc] init]; self.picker.delegate = self; self.picker.datasource = self; self.classfield.inputview = self.picker; // additional setup after loading view. } - (bool)textfieldshouldb

security - Password protected iOS app on screen lock -

i trying password protect ios app having passcode screen (similar lock screen) pop every time app has been in background. i've put required code in appdelegate 's applicationwillenterforeground: , part ok. however, problem how present passcode screen. tried present uiviewcontroller modally root vc, creates problems if other modal vc present. second option create new uiwindow , make passcode vc rootviewcontroller . works, not sure if best practice or if there better solutions. looking in end solution similar 1 used in dropbox app. so, question clean , straight: there security implications or bad practices creating uiwindow on top of main window in order show passcode screen? , there other suggestions on how password protect app dropbox it? also, here code using: - (void)applicationwillenterforeground:(uiapplication *)application { if (self.loggedinviewcontroller && !lockvc) { //verify application logged in, , no passcode being shown lockvc = [[c

javascript - requirejs, is it possible to create a shim that loads deps after path -

here trying achieve. i have primary library needs loaded several other libraries need loaded after primary library. all secondary libraries require primary library loaded. is there reverse of shim deps? primarylib.js secondarylib1.js secondarylib2.js secondarylib3.js secondarylib4.js secondarylib5.js .... i call like: require(['primarylib'], function(){ }) primarylib.js should loaded first , of secondary libraries should loaded. if use normal shim method need set each secondary library require primary lib. when want call libs need call of secondary libraries in require() call instead of single lib avoid @ costs. edit: additional comments , context i trying implement blueimp's file uploader. it crying load-image dependancies. the final config load-image files looks this. "load-image": { "path": "lib\/blueimp-load-image\/load-image" }, "load-image-exif-map": {

java - LinearLayout on android -

i trying create sign form android application this xml code <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_horizontal" android:orientation="horizontal" > <textview android:id="@+id/mynumber" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="number +961" android:textsize="20sp" android:color="@android:color/white" /> <edittext android:id="@+id/edittextnumber" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="number" android:textcolor="#ffffff" /> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_cont

python - Cartesian product giving a dictionary -

i have following lists: brand=["audi","mercedes"] speed=[130,150] model=["sport","family"] i want obtain equivalent of: ll=[] ll.append({'brand':'mercedes', 'speed':130, 'model':'family'}) ll.append({'brand':'mercedes', 'speed':130, 'model':'sport'}) ll.append({'brand':'audi', 'speed':130, 'model':'family'}) ll.append({'brand':'audi', 'speed':130, 'model':'sport'}) ll.append({'brand':'mercedes', 'speed':150, 'model':'family'}) ll.append({'brand':'mercedes', 'speed':150, 'model':'sport'}) ll.append({'brand':'audi', 'speed':150, 'model':'family'}) ll.append({'brand':'audi', 'speed':150, 'model':'sport'}) i do: from itert

c++ - PC Lint Error while using templates -

when run pc lint application below mentioned code errors: the errors line (1) are error 129: declaration expected, identifier '__created' ignored error 10: expecting identifier or other declarator error 129: declaration expected, identifier 'typename' ignored template<typename t,uint32 capacity> //(1) class { public: a(); t *alloc(); t *free( t *ptr); //private members private: t *m_headptr; t m_pool[capacity]; } how can rid of errors? save file c++ file correct ending or tell lint treat such, currently, seems treated c file.

c# - Add buttons to a gridview row manually -

i want have dynamic gridview includes 3 buttons in each rows.i want have 5 rows in grid view.i use code populate data row.but don't know how add button each row.can 1 me? datagridviewrow row = new datagridviewrow(); row.createcells(scanimagesgrid); row.cells[0].value = "1"; row.cells[1].value = "عکس شخصی"; row.cells[2].value= //my button no1 row.cells[3].value= //my button no2 row.cells[4].value= //my button no4 scanimagesgrid.rows.add(row); i want know how respond on click event of each button in each row. lot

java - Why do I get NullPointerException ? (Basic GPS logic) -

import java.math.bigdecimal; import java.util.*; public class directiongraphe { public arraylist<graphvector> shortest; public arraylist<graphvector> current_path; private arraylist <graphvector> fastest; private integer weight_sum; private integer current_gain; public directiongraphe(){ } private arraylist <graphvector> graph = new arraylist<graphvector>(); public arraylist <graphvector> getroutes(graphvector toncho){ arraylist<graphvector> list = new arraylist <graphvector> (); for(graphvector eachvector : graph){ if(toncho.isroute(eachvector)){ list.add(eachvector); } } return list; } public void addvector(graphvector vector) throws exception{ if(isconnected(vector) || graph.isempty()){ graph.add(vector); } else throw(new exception (" vector not connected ! "));