Posts

Showing posts from April, 2014

database - ISOdate/POSIXct vs Milliseconds -

this more of thinking question. have been working around different time/date formats, , noticed seems preferred store date/time objects variables unique classes (like isodate or posixct) in databases (like mongo, mysql, postegen). i why 1 want convert such format when analyzing data, wondering what's advantage when store in format in data-base? do these formats tend take less space conventional numbers? can't seem find answer online. for arguments sake let's talk simple date type (just date, no time or time zone) - such date type in mysql. say stored string of 2014-12-31 . what's 1 day later? human, it's easy come answer 2015-01-01 , computer needs have algorithms programmed in. while these types might expose apis have algorithms dealing calendar math, under hood store information whole number of days since starting date (which called "epoch"). 2014-12-31 stored 16701 . computer can efficiently add 1 16702 next day. this make...

spring security - Authenticate using SAML-based Basic Authentication? -

i have use case web application needs let users authenticate in 2 different ways using same user data store (aka idp) via saml. user's browser redirected idp , redirected saml assertion (aka websso profile). user makes request sp providing credentials via basic authentication. sp need send user's credentials idp , idp provide assertion through channel (server server). i'm using spring security saml extension. sample application in spring saml contains both basic authentication username , password , saml-based authentication basic auth portion uses local accounts defined in securitycontext.xml file. need use user accounts on idp. possible? if so, how configure spring saml? there no standard saml websso mechanism allow sp request assertion specific user providing credentials. might want ws-trust standard covers such use-cases using request security token methods (rst/rstr calls). quite standardized way client credentials grant of oauth 2.0 . both out of s...

dialog - AlertDialog for getting password android -

i'm programming in java using android studio. want get password user using alertdialog , show using alertdialog . problem without prompt entering password see second dialog. in other words message "your pass null" . wrong in codes? i run dialog codes in button onclick event: string s = messagebox.showpasswordbox(this, "", "enter password" , "ok" , "cancel"); messagebox.show(this, "showing pass", "your pass " + s , "ok" , "cancel"); where show , showpasswordbox codes are: public static messageboxresult show(context context, string title, string message, string positivemessage, string negativemessage) { result = messageboxresult.closed; alertdialog.builder builder = new alertdialog.builder(context); builder.settitle(title); builder.setmessage(message); builder.setpositivebutton(positivemessage, new dialoginterface.onclicklistener() { public void o...

algorithm - Scala - sort based on Future result predicate -

i have array of objects want sort, predicate sorting asynchronous. scala have either standard or 3rd party library function sorting based on predicate type signature of (t, t) -> future[bool] rather (t, t) -> bool ? alternatively, there other way structure code? i've considered finding 2-pair permutations of list elements, running predicate on each pair , storing result in map((t, t), bool) or structure effect, , sorting on - suspect have many more comparisons executed naive sorting algorithm would. if predicate async may prefer async result , avoid blocking threads using await if want sort list[(t,t)] according future boolean predicate, easiest sort list[(t,t,boolean)] so given have list[(t,t)] , predicate (t, t) -> future[bool] , how can list[(t,t,boolean)] ? or rather future[list[(t,t,boolean)]] want keep async behavior. val list: list[(t,t)] = ... val predicate = ... val listoffutures: list[future[(t,t,boolean]] = list.map { tuple2 => pr...

ruby - How to solve in `basename': no implicit conversion of Array into String -

i filename viddlrb without extension. if i'm running get_names method youtube url i'm getting array. i'm doing that: file = viddlrb.get_names(url) file.first file.to_s puts file filename = file.basename(file, '.*') but if i'm running i'm getting: in `basename': no implicit conversion of array string maybe knows why breaks? thought file.to_s job. when call file.to_s , it's returning result of string conversion, it's not modifying file variable. same call .first . consider example: file = ["filename.txt"] file.first file.to_s => "[\"filename.txt\"]" puts file => ["filename.txt"] the easiest way solve call first , to_s within basename argument. so: filename = file.basename(file.first.to_s, '.*') you alternately make variable before passing in.

polymer - Using the custom element body for data -

i looking implementing custom datagrid want data provided inline contents of custom element: <x-datagrid> <row> <col>value 1</col><col>value 2</col> </row> </x-datagrid> you can achieve menu , tab elements populate based on this...how done though? have looked @ component source core-dropdown-menu: https://github.com/polymer/core-dropdown-menu/blob/master/core-dropdown-menu.html doesn't tell me much...where else look? i able polymer.dom(this) in ready function. an example, loads data child <option> elements component's data property: ready: function() { var self = this; // since "this" gets lost in foreach polymer.dom(this).queryselectorall('option').foreach(function(opt) { self.push('data', {id: opt.value, text: opt.textcontent}); }); }, where component looks like: <my-component> <option value="1">option 1</option> ...

sqlite android extract contacts with phone number -

i'm facing sqlite issue in i'm trying extract contacts have phone number/s following query: cursor cursor = context.getcontentresolver(). query(contactscontract.commondatakinds.phone.content_uri, new string[]{ contactscontract.commondatakinds.phone.contact_id, contactscontract.commondatakinds.phone.number, contactscontract.contacts.display_name, contactscontract.contacts.photo_uri }, contactscontract.contacts.has_phone_number + ">?", new string [] {"0"}, contactscontract.commondatakinds.phone.display_name + " asc" ); the problem in case contact has more 1 phone number result in form: id: 451, name: maria, photouri: null, has_phone_number: 1, phone_number: 0700 000 000 id: 451, name: maria, photouri: null, has_phone_number: 1, phone_number: 0800 000 000 id: 451, name: maria, photouri: null, has_phone_number...

how to work around Ubuntu or gedit bug -

has heard of problem or have workaround? building application in coldfusion/javascript , in ubuntu 14.04. time time (rather often) bunch of text gets dumped random places in code. has showed on terminal when open. may have been on clipboard previously, i'm not sure case. "find" feature in gedit. or in ubuntu. i have changed both keyboard , mouse, problem persists, don't think hardware. slowing down development, random garbage keeps getting dumped code , have track down , remove it. can help?

opencv - Is it possible to make two grayscale images stastistically equivalent? -

i have 2 grayscale images g1 , g2 . have statistics (min ,max ,mean , standard deviation). change g2 such statistics of g2 (min ,max,mean , sd)match g1. have tried arithmetic scaling , got min , max values of both g1 , g2 match mean , sd still different. have tried histogram fitting of g2 in g1 did not wanted either. using software called spider question applicable image-processing can performed using different software packages(opencv matlabetc) .any ideas , suggestions appreciated. the easiest thing apply histogram equalization both images ( histeq in matlab). if not want change both images, can histogram matching , that's bit more complicated.

c++ - Value error in Python f\x00o\x00r\x00t -

i embedding python c++. sending big amount of data c++ python , doing manipulations on data in python. in c++ data stored in form of 2-d vector of float via tuple sending python. now, not sure in format data received in python. in str or utf-16 or utf-8(i dont know meanings of these things). aim receive data array on here in python , apply scikit-learn functions it. i able apply numpy.array functions , convert data received in python numpy arrays. now, when passing array scikit functions giving me error u"invalid mode, expected 'c' or 'fortran', got f\x00o\x00r\x00t" . by looking @ different posts, pretty sure has way data read in python i.e format solution provided everywhere dealing reading files , whenever open file use utf-16 in scenario dont have file have arguments in python. how read them in proper format pass them scikit functions? call c++ : pvalue = pyobject_callobject(pfunc, pargtuple); python side : import numpy np import scipy.io sk...

azure - AADSTS90093: Calling principal cannot consent due to lack of permissions -

i'm getting following error when non-global admin users trying access graph explorer 2 within our tenant: additional technical information: correlation id: 2346b0f5-bb5f-4138-8f9d-07fa96dcf02f timestamp: 2015-05-29 17:18:48z aadsts90093: calling principal cannot consent due lack of permissions. from within azure have "users may give applications permission access data" set use. have "users may add integrated applications" yes. just wanted check url going to. have 2 "graph explorers" - 1 exploring azure ad graph api, while other (called api explorer) exploring office 365 unified api . if going https://graphexplorer2.cloudapp.net - (aad) graph explorer, , should not require admin permissions. please let know if using , if causing issues. if on other hand going https://graphexplorer2.azurewebsites.net - api explorer, , due number of apis requires access to, requires admin consent. we'll way reduce number of scopes ...

android 5.0+ negative layout margins don't seem to work -

i've tested code on devices pre 5.0 , seem work. when try on above 5.0 images clipped because z position isn't @ front. here layout i'm trying fix. problem 5 images below cardview. want them "attatched" cardview" i.e cardview has 5 images hanging off of it. should 50% on card , 50% off. i've achieved negative layout margin on android 4.4 , below when @ on 5.0+ images underneath cardview instead of on top of it. i've tried encase cardview in framelayout , way views disappear entirely. any appreciated! <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <relativelayout android:layout_width="wrap_content" android:layout_height="wrap_content" a...

import - OSX C++ Xcode: Pasting long input into console gives upside down question marks -

Image
we've made program takes long string of tab-delimited input pasted console window , splits correct variables. however, lately long strings of metadata, bunch of upside down question marks have appeared - after has been pasted in, before, , both... here screenshots of when paste in bunch of filler numbers: it doesn't appear terribly consistent upside down question marks appear. pasting in normal english metadata, no special characters or other languages. here code getting information: string faimport; cin.ignore(1000, '\n'); cout << "\nplease copy , paste information finding aid , press enter: \n"; getline(cin, faimport); cout << faimport; i still don't know why problem exists, looks there character limit of around 1000 xcode... i switched on visual studio on pc , worked perfectly...

html - How can I make two iframes fit the width of the page? -

my issue have 2 iframes on page, 1 persistent side menu , 1 main body content. want side menu take 12% of screen (just personal choice) , content fit rest of page width. i've seen many solutions fitting single iframe onto page cannot find specific issue exactly. i tried setting bodycontent iframe's width 88% 88 + 12 = 100, makes iframe appear below menu iframe. guess 100% wide page in case...? rudimentary solution set width of bodycontent 87.6% (87.7% much) fits full width of page tiny sliver of white along right border. i know there must more simple solution problem 2 iframe's can cleanly fit full width of page. how go doing so? here's have right (the iframe's sources .aspx files have hidden): <!doctype html> <html> <head> <title>foo</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-language" content=...

linux - Install python-pip on Ubuntu 14.04.2 Issue -

attempting install python-pip on fresh ubuntu 14.04.2 vm. sudo apt-get update sudo apt-get install python-pip the error indicates basic libc package can't found: err http://archive.ubuntu.com/ubuntu/ trusty-security/main linux-libc-dev amd64 3.13.0-52.86 404 not found [ip: 91.189.91.15 80] fetched 26.1 mb in 4s (5918 kb/s) e: failed fetch http://archive.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_3.13.0-52.86_amd64.deb 404 not found [ip: 91.189.91.15 80] and indeed, hitting url listed browser throws 404. same issue happens when trying install python-dev , python3-pip . what's workaround? edit - solved the problem building vm using vagrant , docker. the run sudo apt-get update step in dockerfile cached reason, meaning being skipped. consequently, python-pip looking outdated dependency. i'm in virtualenv, had this: pip install --upgrade pip now virtualenv date - didn't have mess rest of ubuntu's pip on system. best...

assemblies - C#: Custom assembly directory -

say have application consists of 1 executable , 5 libraries. regularly of these contained in 1 directory , libraries loaded there. is possible can have example of libraries in 1 directory called lib, , rest in 1 called lib2? application directory contain executable , other assemblies contained in various logical directories. how can this? , know how loading of assemblies, how make building of application put assemblies in right directory. you can add additional search paths app.config looks in load assemblies. example <runtime> <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1"> <probing privatepath="lib;thirdparty" /> </assemblybinding> </runtime> you can see more details here .

ruby - When is an enumerator useful? -

an enumerator object can created calling methods without passing block, example array#reject : (1..3).reject.to_a # => [1, 2, 3] is rule of ruby easier chaining or there other way pass behavior enumerator? is rule of ruby easier chaining yes, reason exactly. easy chaining of enumerators. consider example: ary = ['alice', 'bob', 'eve'] records = ary.map.with_index |item, idx| { id: idx, name: item, } end records # => [{:id=>0, :name=>"alice"}, {:id=>1, :name=>"bob"}, {:id=>2, :name=>"eve"}] map yields each element with_index , slaps item index on top of , yields block. block returns value with_index , returns map ( does thing, mapping, and ) returns caller.

Importing Excel into SQL Server -

i want update table using data excel sheet. excel file have 2 columns, 1 uniqueidentifier , other reference. tried use openrowset command update table, database have security property doesn't allows me it. my idea create new table in database 2 columns, , update data in table later. create data in database tried use import wizard in sql server when tried it, got following messages: error 0xc020901c: data flow task 1: there error source - sheet1$.outputs[excel source output].columns[pst_wsi_refdes] on source - sheet1$.outputs[excel source output]. column status returned was: "text truncated or 1 or more characters had no match in target code page.". (sql server import , export wizard) error 0xc020902a: data flow task 1: "source - sheet1$.outputs[excel source output].columns[pst_wsi_refdes]" failed because truncation occurred, , truncation row disposition on "source - sheet1$.outputs[excel source output].columns[pst_wsi_refdes]" speci...

php - TEXT field in MySqli shows "undefined" when we try to add data -

i try insert data "studentremark" table. has field text data type. when insert data field content shows "undefined". here code" i'm using ajax page processing. $faculty=$_request['faculty']; $stcode=$_request['stcode']; $rem=$_request['rem']; $date = date('y-m-d'); $sql = "insert studentremark (stcode, tid, rdate, remarks) values (?, ?, ?, ?)"; $query = $mysqli->prepare($sql); $query->bind_param('siss',$stcode, $faculty, $date, $rem); if(!$query->execute()) { echo("some unknown error occurs, item cannot added."); } else { echo("student remarks added !!"); } please help. thank in advance. try this: $sql = "insert studentremark (stcode, tid, rdate, remarks) values (?, ?, ?, ?)"; $query = $mysqli->prepare($sql); $query->bind_param('siss',$stcode, $faculty, $date, $rem); $faculty=$_request['faculty']; ...

android - Source JAR with Buck's android_prebuilt_aar -

i'm adding dependency on aar file , specify source jar can browse sources in ide. with prebuilt_jar can specify source_jar . however android_prebuilt_aar doesn't seem have option: android_prebuilt_aar( name = 'android-support-v4', aar = 'support-v4-22.1.1.aar', source_jar = 'support-v4-22.1.1-sources.jar', visibility = [ 'public', ], ) > typeerror: android_prebuilt_aar() got unexpected keyword argument 'source_jar'

c# - StreamWriter not appending to file, instead creating a new file in different directory -

i attempting write 1 file temp file after making changes of data in source file. working until extracted logic own function. after running tests noticed first line being saved file in location specified. after debugging able see second call function , onward file location in different location. i have 2 questions, first - why happening? second - best way make sure gets fixed , not happen again? str[] file broken delimiter 1 line @ time. filename name of specific file contained in directory of files (this program loops through number of files). public static void writefile(string[] str, string filename) { rowcount++; using (streamwriter sw = new streamwriter(filename.substring(0, filename.length - 4) + "_tmp.txt", true, system.text.encoding.unicode)) { string tempstring = string.empty; (int = 0; < str.length; i++) { if (ismrt) { tempstring += str[i] + ","; } ...

c# - XML: let child-node inherit parent-node namespace? -

i'm trying create xml nodes runtime using xpath c#. see xml below: <package xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns="http://schemas.microsoft.com/appx/2010/manifest"> <application> <m2:visualelements> <!--- insert child nodes here have namespace 'm2' ----> </m2:visualelements> </application> </package> currently i'm doing following: xelement visualelements = doc.descendants().singleordefault(p => p.name.localname == "visualelements"); visualelements.add(new xelement(doc.root.getdefaultnamespace() + "initialrotationpreference")); i know wrong since reference default namespace, result in being added: <initialrotationpreference /> when want: <m2:initialrotationpreference /> is there way access parent-nodes namespace (m2) without "knowing" prefix or namespace-url? thank you! your document root...

c# - PostSharp Conflicting Aspects warning -

i'm using postsharp express in vs2013 create validation aspects can apply properties. followed this postsharp guide on location interception . work getting hundreds of warnings stating: conflicting aspects on "mynamespace.get_myproperty": transformations ".myvalidation1attribute: intercepted advice ongetvalue, onsetvalue" , "mynamespace.validation2attribute: intercepted advice ongetvalue, onsetvalue" not commutative, not ordered. order of execution undeterministic. which think result of placing multiple validation aspects on same properties. first tried comma-separate attributes, understand supposed order them: [validation1,validation2] warnings still remained. since aspects commutative (it doesn't matter order executed), the postsharp docs advise mark them such using aspecttypedependency follows: [aspecttypedependency(aspectdependencyaction.commute, typeof(ilocationvalidationaspect))] however, appears postsharp.aspec...

javascript - Google Maps draw mode measure distance -

Image
i'm trying implement "measure distance" in google maps v3, can in google maps web . i wonder if there library implmente drawingmode of drawingmanager. here's example found of simple ruler measures distance between 2 markers: http://www.barattalo.it/measure-distance-google-maps the source code available via link on page. i hope use same basic idea in my own topographic maps drag out series of markers, use resulting polyline draw elevation profile, etc. i'll post reference code here if i'm successful. that said, since "measure distance" ui has been part of standard desktop google maps since july 2014, hope google team might share via published google maps api soon, simplifying our work (not mention standardizing ui such user drawn paths). fyi, chris

matlab - selecting specific fields in a structure array based on the values of the field. -

i new matlab , appreciate help. have structure "s" , inside "s" have fields 1 of "t" trials , inside "t" have 20 other fields , have values written in 1xn matrices. have 900 trials , want select specific ones based on values of field inside each trial (s.t.a). how can this? bit lost cant figure out should for. thank you. it unclear me variables are, , matters lot how can operate on them. example, may want structfun problem - allows apply function each field of structure, must scalar, e.g. structfun(@(x) x==180,s.t) return result of ==180 each field of t . if struct isn't scalar, try logical indexing, e.g. [s.t([s.t.direction]==180)] return struct condition direction == 180 true. if supply actual variable working you'll more helpful answers.

php - Can't seem to make mysqli_insert_id work -

i have been trying make work few hours , can't seem make of it. code using below. working on phpbb page, explains template , sql query setup. $sql_query = 'insert ' . rosters . ' ' . $db->sql_build_array('insert', $sql_rost); $result_rost = $db->sql_query($sql_query); $roster_last = $mysqli->insert_id; $template->assign_block_vars('some_block', array( 'roster' => $roster_last, 'test' =>'test' )); $db->sql_freeresult($result_rost); the insert query works because see new entry in database, , on template used test make sure block showing up, is. also, didn't use mysqli_insert_id($link) because connected database snippet of code don't want replicate database connection. without $link error mysqli_insert_id expecting parameter. i dont think can use mysql make query, , use mysqli id. try this: $db->insert_id; edit: noticed said working phpbb. phpbb wiki sug...

ruby on rails - How to modify (encode and decode) routes id, but without changes in the model or controller? -

i want expose database ids , encode/decode id routes helper. encoding use hashids gem. now have: routes.rb get 'companies/:id/:year', to: 'company#show', as: 'companies' company url: /companies/1/2015 for id encoding have encode/decode helper methods: def encode(id) # encode... return 'abc123' end def decode(hashid) # decode... return 1 end how can implemented, id routes helper converted? must show url: /companies/abc123/2015 and controller must automatically params id 1. thanks answers! wont decode params id without changes in model or controller. after long consideration, have decided params id manipulate, before controller params. manipulate params in routes constraints. example helper: encoding_helper.rb module encodinghelper def encode(id) # encode... return 'abc123' end def decode(hashid) # decode... return 1 end end create path encode id: companies_path(id: e...

regex - Awk BEGIN example -

$ cat tables.txt | awk 'begin { rs="\nstation" fs="\n" } { print $1 } ' running above command in above format or script gives me desired output. 08594: sal , cape verde but if try running same in cli single gives me error syntax. doing wrong here? $ awk 'begin { rs="\nstation" fs="\n" }{ print $1 }' tables.txt you can use: awk 'begin { rs="\nstation"; fs="\n" }{ print $1 }' tables.txt i.e. use ; terminate 1 assignment before starting i.e. fs="\n" .

haskell - use runDB in a SubSite Yesod -

i want create post method in subsite create new entity, have aform demoform :: rendermessage master formmessage => maybe demo -> aform (handlert master io) demo demoform demo = demo <$> areq textfield (fieldsettingslabel ("fieldone"::t.text)) (demofieldone <$> demo) <*> areq intfield (fieldsettingslabel ("fieldone"::t.text)) (demofieldtwo <$> demo) <*> areq boolfield (fieldsettingslabel ("fieldthree"::t.text)) (demofieldthree <$> demo) <*> areq dayfield (fieldsettingslabel ("fieldfour"::t.text)) (demofieldfour <$> demo) and post method: postdemonewr :: (yesod master,rendermessage master formmessage) => handlert democrud (handlert master io) html postdemonewr = tp <- getroutetoparent ((result,widget), encoding) <- lift $ runformpost $ renderbootstrap3 bootstrapbasicform $ demoform n...

c# 4.0 - Insert XML to XML Document at specified tag -

i working on xml want insert below xml tag parent xml: <subject></subject> parent xml <school> <classb></classb> <classa> <students> </students> </classa> </school> want final out put <school> <classb></classb> <classa> <subject></subject> <students> </students> </classa> </school> tried below code: xmldocument xmlrequest = new xmldocument(); xmlrequest.loadxml(parentxml); xmldocumentfragment xmlfrag = xmlrequest.createdocumentfragment(); xmlfrag.innerxml = xmlsubjects; xmlrequest.documentelement.insertbefore(xmlfrag, xmlrequest.documentelement.firstchild); this insert subject element right after school. how insert @ specific path. in case under classa element. please me here. you need use getelementbyname or method classa node: xmlnode xnode = xmlrequest.selectsinglenode(...

New line or line break in HTML generated from XML -

i have string in xml should separated new lines when viewed on webpage generated xml. goal hello alice, my name bob. failed attempts <description>hello alice, name bob. </description> hello alice, name bob <description>hello alice, \n name bob. </description> hello alice, \nmy name bob <description>hello alice, &#xa;&#xd; name bob. </description> hello alice, name bob. <description><![cdata[hello alice,<br /> name bob.]]> </description> hello alice, <br /> my name bob. is possible, assuming have no control on how html generated xml file (i.e. able edit xml)? if possible, how can produce line break? i noticed lot of similar questions, haven't found solution (if there exists one). sorry in advance if seems duplicate. also, in advance!

Meteor Blaze template not showing filtered Mongodb embedded collection -

i have following example of data set: samplecol.insert({ name: "john doe", description: "nice guy", embedded_1: [{ key1: 'x1', key2: 'x2', tarifftypes: [{ tariffcode: 'promocional', price: 125, weekdays: ['sun', 'sat'] }, { tariffcode: 'lastminute', price: 150, weekdays: ['sun', 'sat'] }], }, { key1: 'x3', key2: 'x4', tarifftypes: [{ tariffcode: 'promocional', price: 175, weekdays: ['sun', 'sat'] }, { tariffcode: 'lastminute', price: 200, weekdays: ['sun', 'sat'] }] }] }); i trying filter ,...

php - Guzzle 6: no more json() method for responses -

previously in guzzle 5.3: $response = $client->get('http://httpbin.org/get'); $array = $response->json(); // yoohoo var_dump($array[0]['origin']); i php array json response. in guzzle 6, don't know how do. there seems no json() method anymore. (quickly) read doc latest version , don't found json responses. think missed something, maybe there new concept don't understand (or maybe did not read correctly). is (below) new way way? $response = $client->get('http://httpbin.org/get'); $array = json_decode($response->getbody()->getcontents(), true); // :'( var_dump($array[0]['origin']); or there helper or that? i use json_decode($response->getbody()) instead of $response->json() . i suspect might casualty of psr-7 compliance.

javascript - Input trigger with delay function, wait if input value changes -

i'm building angular directive, on input value change runs function, want wait 300ms before running function, if value changes before 300ms has gone, need reset delay 300ms. if value changes 300ms function should run: my code (function() { 'use strict'; angular .module('address',[]) .directive('address', ['address', function (address) { return { restrict: 'e', transclude: true, templateurl: 'partials/address.html', link: function (scope, elem, attrs) { var delay = "300"; scope.$watch('searchparam', function(){ if(!_.isundefined(scope.searchparam) && scope.searchparam.length >= 3) { // here need delay timer address.get(scope.searchparam).then(function(data){ console.log("data: ", data); scope.addresslist = dat...

angularjs: how to get the index in ng-repeat -

i want implement pagination large ng-repeat, because rendering of 200 objects slow. i want use bootstrap-ui pagination. based on selected page calculate object displayed. in ng-repeat have no index. initial plan doesn't work. example: <div ng-if="index >= min && index <= max"> ... show object... </div> can me how solve problem? thank you! angularjs provides $index on local scope of each template instance - iterator offset of repeated element (0..length-1). https://docs.angularjs.org/api/ng/directive/ngrepeat <div ng-repeat="(key, value) in myobj"> <div ng-if="$index >= min && $index <= max"> ... show object... </div> </div>

bigcommerce - Add products to Cart using cart.php in Big Commerce -

i trying add product cart using http post in remote.php like post /cart.php http/1.1 host: mobfirst.mybigcommerce.com cache-control: no-cache content-type: application/x-www-form-urlencoded action=add&product_id=35&variation_id=currency_id=&attribute[66]=11&qty[]=1 it works, wonder know how figure out number of attribute corresponding option product (66 in attibute[]). saw dynamic. ps: can't use api create order because don't have billing address @ moment. answer of support: i did not know of way find attribute number other scraping product page. digging , testing things though have found comes from. it appears attribute number comes "product option id" number can pull api (not confused "option id" number). easiest way explain example, wanted find attribute numbers product id 50. make request to: https://domain.com/api/v2/products/50/options this give me list of "product option" objects similar this: [...

c# - Adding XML to a table in Microsoft SQL Server -

i want table called testpack 3 coulmns - name, testcase number, testplan testplan xml file stored in c drive of computer how can go creating table? note: want entire file added instead of writing actual xml code in 3rd column. also, new asp.net, c# , microsoft sql server, spare dumb questions first need create table following this create table [mytable] ( id int, [myxmlcolumn] xml); and need insert data using sqlparameter public static void insertxmldataintotablebysqlparameter() { using (sqlconnection sqlconnection = new sqlconnection(@"data source=.\sqlexpress; initial catalog=morgandb; integrated security=sspi;")) { sqlconnection.open(); // create table if not exists string createtablequery = @"create table [mytable] ( id int, [myxmlcolumn] xml)"; sqlcommand command = new sqlcommand(createtablequery, sqlconnection); command.executenonquery(); ...

javascript - React event-handling (onClick) inconsistency -

sup. the following alerts on render, not onclick: render: function(){ return ( <div onclick={alert('i alert on render, not onclick.')} /> ); } same following: foo : function(text) { alert(text) }, render: function(){ return ( <div onclick={this.foo('i alert on render, not onclick.')} /> ); } this nothing: foo : function(text) { alert(text) }, render: function(){ return ( <div onclick={function(){this.foo('what click , must it, huh?')}} /> ); } although works expected: render: function(){ return ( <div onclick={function(){alert('i alert onclick only.')}} /> ); } note each code block exists inside react class , omitted styling creates area that's clickable. note alerts in first 2 cases pop twice each, believe because web app uses react-router. i have 2 questions: for first 2 cases, why need anonymous function prevent alert on render? why foo() n...

image - Javascript background changer no working -

i want implement background image changer in code, doesn't seem work. here js: function xax() { var p = document.getelementbyid("background1"); var o = document.getelementbyid("background2"); var = document.getelementbyid("background3"); if {p.checked === true} { document.body.style.backgroundimage = "url(gates.jpg)"; } else if {o.checked === true} { document.body.style.backgroundimage = "url(city.jpg)"; } else if {i.checked === true} { document.body.style.backgroundimage = "url(forest.jpg)"; } } here html: <input type="radio" id="background1" name="background" >gates of argonath</input><br> <input type="radio" id="background2" name="background" >minas tirith</input><br> <input type="radio" id="background3" name="b...

uistoryboard - Links to learn storyboard -

can me free tutorials learning storyboard auto layout & adaptive layout. comfortable programatically new storyboard.please share links. you can google it. anyway here examples ray wenderlich: autolayout , storyboard

javascript object array with multiple options -

i trying create array multiple object multiple options each in javascript. but seem going in wrong direction. doing wrong here? var group = {[ 'object1'[ 'option1' : 'data1.1', 'option2' : 'data1.2', 'option3' : 'data1.3', ], 'object2'[ 'option1' : 'data2.1', 'option2' : 'data2.2', 'option3' : 'data2.3', ], 'object3'[ 'option1' : 'data3.1', 'option2' : 'data3.2', 'option3' : 'data3.3', ], ]}; you have use name : value pairs. instead of [] use {} define map ( [] arrays). edit: i've overseen before. var group = { 'object1': { 'option1' : 'data1.1', 'option2' : 'data1.2', 'option3' : 'data1.3' }, 'object2...

excel - Making userform with vba, commandbutton does not work -

first of i'm holland, sorry bad english. i have excelsheet lot of records (from 10 1000, depending on user). idea dynamically make userform row of textboxes per record created. want make commandbutton per record change data in records. @ last add code userform define actions executed when commandbutton clicked. the textboxes , commandbutton visible when userform shown, nothing happens when click commandbutton, despite fact code created @ userform. i have examplefile, don't know how upload here. underneath code (placed under userform) private sub userform_initialize() dim ccntrl control dim txtb1 control dim cmb1 control 'deleting lines doesn't work yet 'with thisworkbook.vbproject.vbcomponents("efris").codemodule 'x = .countoflines 'y = sheets("data").range("a3").value 'if x > y .deletelines y, x - y 'x = .countoflines 'end ' 'sheets("data").range("a3") = x 'locatie ...

c# - Codebehind function not being called by Ajax POST -

my ajax post not running code behind method , not returning data. <%@ page language="c#" autoeventwireup="true" codebehind="test.aspx.cs" inherits="asptest.test" %> test.aspx (ajax script) <script> $(".avatarthumb").click(function () { $.ajax({ type: "post", url: "test.aspx/mymethod", //data: {"s": "some data passed through" }, //contenttype: 'application/json; charset=utf-8', //datatype: 'json', success: function (response) { alert(response.d); //returns "undefined" }, failure: function(response) { alert(response); } }); ...

mysql - wrong collation for column -

i have legacy system running mysql 5.0.67. columns collation set latin1_swedish_ci. php scripts data db , generates page charset=windows-1257 . in php page language specific characters shown correctly. when directly db data can see these characters not shown properly. see rûta instead of rūta, agnë instead of agnė. can't write database or change parameter. when run select a.name collate cp1257_general_ci agent i error collation 'cp1257_general_ci' not valid character set 'latin1' how data db proper characters? edit: show variables '%char%'; character_set_client latin1 character_set_connection latin1 character_set_database cp1257 character_set_filesystem binary character_set_results character_set_server latin1 character_set_system utf8 character_sets_dir /usr/local/share/mysql/charsets/ and show variables 'collation%'; collation_connection latin1_swedish_ci collation_database cp1257_lithuanian_ci collation...

html - CSS IDs not working when extension is hidden -

i developed site extensions visible, when finished , wanted make production. did htaccess hide extensions , add trailing slash, when people click on button redirects/links #tab1, url becomes: http://domain.com/terms/#tab1 and css id doesn't open (the tab). is there way fix this?

swift - binary operator * cannot be applied to operands of type Int and Double -

i'm trying build simple swift app calculate vat (value added taxes = 20%). class viewcontroller: uiviewcontroller { @iboutlet var resulttextview: uitextview! @iboutlet var inputtextfield: uitextfield! @iboutlet var calculatevatbutton: uibutton! override func viewdidload() { super.viewdidload() func taxesfree(number: int)-> double{ var textfield = self.inputtextfield.text.toint()! let vat = 0.2 var result = textfield * vat return result } for reason keep getting binary operator * cannot applied operands of type int , double on result line var result = textfield * vat inside function. you should convert 1 type other 1 both variable should same types: var result: double = double(textfield) * vat

c - Is it possible to peek at the next rand value -

assuming generator has been seeded, possible peek @ next random value without changing it? i.e. given: #include <stdlib.h> int r; r = rand(); // 99 r = rand(); // 80 is possible #include <stdlib.h> int r; r = peekatrand(); // give 99 r = rand(); // still gives 99 r = peekatrand(); // give 80 r = rand(); // still gives 80 furthermore, can extended peeking @ next n numbers ? you can implement peekatrand follows: int peekatrand() { int r,s; s = rand(); srand(s); r = rand(); srand(s); return r; } to make "worthy", call srand((unsigned int)time(null)) @ beginning of program.

php - Unique values of the array with four fields -

i've array this: array( 0 => array(1, 2, 3, 4), 1 => array(1, 3, 2, 4), 2 => array(1, 2, 4, 3), 3 => array(1, 2, 5, 6) ) i have remove records repeated. need have array: array( 0 => array(1, 2, 3, 4), 3 => array(1, 2, 5, 6) ) the script in php. who can help? :) this should work you: just go through each sub array array_map() , sort() arrays. return them implode() 'ed. created array can use array_unique() , explode() values again. <?php $result = array_map(function($v){ return explode(",", $v); }, array_unique(array_map(function($v){ sort($v); return implode(",", $v); }, $arr))); print_r($result); ?> output: array ( [0] => array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 ) [3] => array ( [0] => 1 [1] =...

Getting legend out of the plot in chart.TimeSeries in R -

Image
suppose have following data: data<- structure(c(103.7, 103.2, 103.1, 105.4, 102.1, 103.5, 103.1, 102.6, 102.2, 104.6, -2.1, -1.4, -2.6, 1.9, -0.7, 1.4, -0.6, -1.3, -1.4, 0, -25.3, -25.3, -25.3, -24.9, -24.7, -24.5, -21.4, -20.9, -20.4, -19.8, 25, 20.7, 25.5, 19.8, 12.8, 13.6, 15.5, 23, 12.8, 16.3, -16.1, -20.1, -16.9, -17.8, -18.6, -19.5, -16.4, -18.9, -16.1, -15.1), .dim = c(10l, 5l), .dimnames = list(null, c("edinburgh", "glasgow", "aberdeen", "st andrews", "highlands")), .tsp = c(1985, 1985.75, 12), class = c("mts", "ts", "matrix")) i figured out suitable way plot data use chart.timeseries function performanceanalytics package. did using : chart.timeseries(data, legend.loc = "right") and got: my question how legend outside plot right. tried reproduce same chart using g...

android - ToggleButton per Lollipop -

Image
i want togglebutton like . but code , shows me older toggle button. am running code in emulator api 21 only, missing here. code snippet is <togglebutton android:layout_width="wrap_content" android:layout_height="wrap_content" /> found solution. using android support library. code snippet is.. <android.support.v7.widget.switchcompat android:id="@+id/id_useridview_switch" android:layout_margintop="24dp" android:layout_width="wrap_content" android:layout_height="2dp" android:theme="@style/colortoggle" /> thanks selvin, got clue ur , on search

c# - Creating a file pickup process with a Blocking Collection -

what have got @ moment timer fires every 5000 ms: static timer _atimer = new system.timers.timer(); static void main(string[] args) { _atimer.elapsed += new elapsedeventhandler(ontimedevent); _atimer.interval = 5000; _atimer.enabled = true; console.writeline("press \'q\' quit sample."); while (console.read() != 'q') ; } on fire sets queues processing files: private static void ontimedevent(object source, elapsedeventargs e) { // stop timer dont reprocess files have in queue stoptimer(); // setup list of queues var lists = new list<incomingorderqueue>(); //get accounts in files looking in var accounts = new list<string>() { "account1", "account2" }; //loop through accounts , set queue foreach (var acc in accounts) { // create queue var tmp = new incomingord...