Posts

Showing posts from January, 2015

python - Loading data from a csv file and display in list of tuples -

does have idea on how write function loading_values(csvfilename) takes string corresponding name of data file , returns list of tuples containing subset name (as string) , list of floating point data values. result should when function called >>> stat = loading_values(`statistics.csv`) >>> stat [('pressure', [31.52, 20.3, ..., 27.90, 59.58]), ('temp', [97.81, 57.99, ..., 57.80, 64.64]), ('range', [79.10, 42.83, ..., 68.84, 26.88])] for code returns separate tuples each subheading not joined (,) f=open('statistics.csv', 'r') c in f: numbers = c.split(',') numbers = (numbers[0], (numbers[1::])) [('pressure', [31.52, 20.3, ..., 27.90, 59.58]) ('temp', [97.81, 57.99, ..., 57.80, 64.64]) ('range', [79.10, 42.83, ..., 68.84, 26.88])] try: def loading_values(csvfile): f=open(csvfile, 'r') results = [] line in f: numbers = list(

c - Does this program only crash on x32 because of alignment differences? -

the following code taken here : #include<stdio.h> int main() { char = 30; char j = 123; char* p = &i; printf("pointer points to: %p\n", p); void* q = p; int * pp = q; /* unsafe, legal c, not c++ */ printf("%d %d\n",i,j); *pp = -1; /* overwrite memory starting @ &i */ printf("%d %d\n",i,j); printf("pointer points to: %p\n", p); printf("%d\n", *p); } on x32 linux machine crashes in last line. on x64 linux not crash. because pointers 4 bytes on x32 , 8 bytes on x64 , due alignment requirements there max 6 bytes hole between char j , char *p on x64 machine overwritten *pp = -1 , therefore nothing happens *p on x32 machine hole maximum 2 bytes *pp = -1 overwrites fist 2 bytes of char *p resulting in segmentation fault when dereferencing? reasoning correct or idiotic? the reasoning not idiotic, not guaranteed correct. the layout of function stack not fixe

how to transpose a 5x5 matrix using mapreduce -

i have tried mapper dividing matrix 2x2 , giving reducer. reducer perform transpose each 2x2 matrix. while dividing odd order matrix 2x2 leaving 1x1 matrix @ end. how write map , reduce function overcome problem. please send me solution. assuming matrix in csv delimited columns , new line rows. can read line line in map task each line, split based on comma , token each column. need custom value object reducer(inherit writable), store line_number & value @ specific column. the map task emit, key column number @ column value read , value custom value object defined above. you need secondary sort/comparator sort based on custom value object's line_number filed when order can maintained when values iterated @ reducer end. at reducer, read keys sorted based on line number, iterator each key , create csv string , write output file.

php - PHPUnit constraints extension gives error "PHPUnit_Util_Type::export()" not found -

i want mock object can tell me if: when 1 of methods called that 1 of arguments passed method is array and has particular key/value pair. i want use phpunit's constraints achieve, this, test code this: $mock = $this->getmock('\jodes\myclass'); $mock->expects($this->once()) ->method('mymethod') ->with( $this->logicaland( $this->istype('array'), $this->arrayhaspair('my_key', 'my_value'), ) ); // ... code here should call mock method in this previous question , guy ended writing own constraint. i found this library seems implement quite few nifty things. installed adding line in composer.json 's require section: "etsy/phpunit-extensions": "@stable" but when try using it, error. use so: class myclasstest extends phpunit_framework_testcase { public function arrayhaspair($k

javascript - Child row datatables - row data value undefined -

i have datatable child rows populated following function: $('#mydatatable tbody').on('click', 'td.details-control', function () { console.log(table.row(this).data()); var tr = $(this).closest('tr'); var row = table.row(tr); if (row.child.isshown()) { // row open - close row.child.hide(); tr.removeclass('shown'); } else { // open row row.child(format(row.data())).show(); tr.addclass('shown'); } }); the format function: function format(d) { // `d` original data object row return '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">' + '<tr>'+ '<td><strong>blabla1</td&g

ruby on rails - Is it wise to use Google Tables as a Database? -

i found out unhosted movement . i understand points being made advantages on classical web app approaches including database being sql or non-sql database. from point of view there concerns regarding security , privacy. believe disadvantages outweigh advantages. if sensitive data involved. i love hear more pros/cons , experiences guys. rather use laravel/ror or similar framework scaffolding etc. i'm try that. far security/privacy concerned, can grant limited access tables , use ssl. google still knows of course. but fusion tables isn't full blown database after all. sql highly limited, have no joins in select, no group in views , left outer joins, no subqueries, no exists clause, no users/transactions/locking/isolation levels etc, might reason use database in first place. not meant that . there no standard connectors i'm aware of, you'll have use api. last post asking jdbc driver years old, , there still isn't any.

amcharts - Synchronize ValueAxis grids -

i have these 2 valueaxes : { ... minimum: 0, maximum: 100, strictminmax: true, autogridcount: false, gridcount: 10 }, { ... minimum: -15, maximum: 215, strictminmax: true, autogridcount: false, gridcount: 10 } now grid lines of both axes creating total mess in chart , hard not confused while trying read values. reason is, amcharts rounds labels or down ten-steps, not respecting gridcount . i need know if there's way amcharts stop trying round labels. i'm totally fine have numbers 62 label, long reduces amount of grid lines. my workaround pretty easy. i introduced new option, normal strictminmax still work: strictgridcount i used implementation of strictminmax , added these lines few lines above place strictminmax used: if(_this.strictgridcount) { if (!isnan(_this.minimum)) { _this.min = _this.minimum; } if (!isnan(_this.maximum)) { _this.max = _this.maximum; } _this.st

c++ - Variadic template couples -

is possible write variadic couples of templates? like: template<typename<typename a, typename b>...> class : public std::tuple<a<b>...> { }; thanks! :) using type list got compile: #include <iostream> #include <tuple> using namespace std; template <typename ...args> struct type_list {}; template<typename b, template <typename> class ...a> class test; template<typename ...b, template <typename> class ...a> class test<type_list<b...>, a...>: tuple<a<b>...> {}; template<typename t> class t1{}; template<typename t> class t2{}; template<typename t> class t3{}; int main() { auto t = test<type_list<int, double, char>, t1, t2, t3>(); return 0; } i don't know, why need this, should make want.

vb.net - list of listening TcpListener on specific port -

i have following vb.net code dim serversocket tcplistener serversocket = new tcplistener(system.net.ipaddress.any, port) port = 8080 i want list of tcplistener listening port or other port i have 2 applications first contain above code , second app contain dim clientsocket tcpclient i want second app detect tcplistener

haxe - Need Help Uninstalling Stencyl -

when try install openfl haxe error: c:\users\dude>haxelib install openfl have openfl version 3.3.0 installed [file_contents,c:\program files (x86)\stencyl\plaf\haxe\lib/openfl/.current] i have uninstalled stencyl program files (win8.1_64bit) , ran ccleaner make sure wiped out. checked system , user environmental variables didn't found stencyl anywhere. then have reinstalled haxe on again, reason keep getting same error. after fresh installation, have checked installation location of haxe using >haxelib config command still weird output c:\users\dude>haxelib config c:\program files (x86)\stencyl\plaf\haxe\lib/ currently haxe installed @ c:\haxetoolkit on machine well entered stencyl keyword in windows search bar , saw file: .hxcpp_config.xml . file , 1 called .haxelib located in user home folder. the problem fixed after deleting both of files. also found stencyl hiding (ಠ_ಠ ). file .hxcpp_config.xml directs appdata folder in user directory (c

windows - How does Microsoft Storport work with SATA legacy mode? -

i have driver designed in storport-miniport model. i'm trying modify driver support sata legacy mode. here questions looking help: the i/o address in native mode, io address shown in bar0 bar3. in legacy mode, io address fixed(0x1f0 command, 0x3f6 control in channel-0). in native mode, used storportgetdevicebase memory-map of io address, doesn't work legacy mode since storport handle io space announced in pci space. therefore, tried use mmmapiospace allocate memories. correct way? the irq just io address, irq fix legacy mode. whole thing irq done storport, should or here? the hwstorinitialize not called msdn says hwstorinitialize should called if hwstorfindadapter return true. in driver legacy mode, hwstorinitialize not called adapter in device manager shows not ready yellow mark. did miss something? ataport-minoport when trying figure out problems, found there's driver mode called ataport-miniport. mean should design driver in model if adapter in legacy m

php - how to hide an array type of entity in a form in symfony2 -

i have array type in entity want add form type hidden field. tried following doesnt work. kills browser. any appreciated. //entity class test{ /** * @orm\column(name="test_image_files", type="array",nullable=true) */ private $testimages; /** * @return mixed */ public function gettestimages() { return $this->testimages; } /** * @param mixed $testimages */ public function settestimages($testimages) { $this->testimages = $testimages; } } // formtype class testtype extends abstracttype { public function buildform(formbuilderinterface $builder, array $options) { $builder->add('testimages','hidden'); } } //twig {{ form_widget(form.testimages) }} this handle current situation, echo form_widget(form.testimages) inside <div style

Populate JSON List To C# Object -

i'm trying populate json/xml string c# object. convert xml json , use json.net. example: json string { "persons":[ { "age":30, "name":"david", "hobbies":[ { "name":"tennis", "hours":5 }, { "name":"football", "hours":10 } ] }, { "name":"adam", "age":23, "hobbies":[] } ] } c# classes public class hobbies { public string name; public int hours; } class person { public string name; public int age; public list<hobbies> hoobies = new list<hobbies>(); } i'm trying populate data list of persons: list<person> persons = new list<person>(); jsonconvert.populateobject(myjsontext, persons); and i'm getting exception: cannot populate json obje

php - What should be the value of redirect URI in Google Developer console -

Image
i running project on localhost. current project path on local system http://localhost/upload_gd2/google-api/examples/user-example.php . i have tried entering redirect uri shows following screen after clicking on accept button. seems small problem i'm facing issue last 4 days. please solve it. thanks.

mysql - how to fix sql query error -

i have request delete t1 permission_id = 'x' , 0<(select * t2 "substr"(pid,1,1)=1) or '1'='1' but got the sql statement " delete t1 permission_id = 'x' , 0<(select * t2 substr(pid,1,1)=1) or '1'='1'" contains syntax error[s]: - 1:101 - sql syntax error: token "(" not expected here please help, how can fix it? update remove "substr" substr, sql statement delete t1 permission_id = 'x' , 0= (select * t2 substr(pid,1,1)=1) or '1'='1' contains syntax error[s]: - 1:99 - sql syntax error: token "(" not expected here update 2 i change select count(*) t2 substring("asdqweasd",1,1)) and - sql syntax error: token "," not expected here - expecting "from", found ',' you not need double quotes around substr. can not use select * . use count(*) delete t1 permission_id = 'x' ,

c# - Access ObservableCollection items from property set -

given following class used wpf datacontext: class viewmodel { public observablecollection<task> tasks { get; set; } } and task class: public class task { private string starttime; public task id { get; set; } public string starttime { { return starttime; } set { // access observablecollection items starttime = value; onpropertychanged("starttime"); } } } how can i, @ place in code see "// access observablecollection items", access other items in tasks observablecollection can compare starttime of instance being set starttime of other task items in tasks observablecollection? you have 2 options: you can inject viewmodel task public class task { private viewmodel viewmodel; public class task(viewmodel viewmodel) { this.viewmodel = viewmodel; } ... } however, makes task class usable viewmodel class, because loosely c

convert an HTML DOM structure (or cloned) to JSON by using JavaScript, JQuery possible -

this question has answer here: map html json 7 answers i saw question here before ( here , here ) still haven't seen solution. since asked in 2011 thought might try myself :) i need convert whole html structure json. structure: <body> <div class="container"> lorem ipsum dolor </div> <h1>this heading 1 <div class="footer"> tessssst </div> </h1> </body> desired json: { "body": { "div": { "text": "loremipsumdolor", "class": "container" }, "h1": { "div": { "text": "tessssst", "class": "footer" } } }

python - Cannot add external libraries with PyCharm -

i'm trying add external libraries project in pycharm using the pycharm > preferences... > project interpreter > python interpreters -> cog on upper right hand side -> click on + icon in project interpreters dialog in resulting screen, add paths external libraries i'd include in project, , added list of paths in dialog, when expand external libraries entry in project window, paths added not shown. i tried going through contents of .idea folder identify references external libraries kept using .idea folder of colleague couldn't figure out related settings file. how can external libraries added phcharm in case?

mysql - SQL Check duplicated values in different fields -

Image
hello have database , table named datalist , has dummy data. here's screenshot of table in phpmyadmin . what wanted output duplicates in every field. can see there 2 1111 , 2 2222 data, they're both different fields. how can output like: duplicates: 1111 2222 i'm sorry question, know checking of duplicate data on same field only. hope can me, thank you! select f, count(*) overall_occurrences, count(case when field = 1 f end) f1_occurrences, count(case when field = 2 f end) f2_occurrences, count(case when field = 3 f end) f3_occurrences, count(case when field = 4 f end) f4_occurrences ( select 1 field, f1 f, datalist.* datalist union select 2 field, f2 f, datalist.* datalist union select 3 field, f3 f, datalist.* datalist union select 4 field, f4 f, datalist.* datalist ) pivotted somefield = 0 group f having count(*) > 1 edit : updated additionally show duplicates occur. edit ; alte

Oracle 11g SQL - Relpacing NULLS with zero where query has PIVOT -

Image
i have following sql code returning data require, im trying replace occurrences of null zero. select * ( select table1.itmcod, table1.itmdsc, table2.grpdsc, table3.zondsc,coalesce(table4.casqty,0) qty,coalesce(table4.qastat,'0') qastat table5 join table1 on blditm.itmcod = table1.itmcod join table3 on table5.put_zonlst = table3.zonlst join table2 on table2.group = table1.group left join table4 on table1.itmcod = table4.itmcod ) pivot (sum(qty) qastat in ('rl' rl,'hd' hd) )order itmcod; i have tried replacing coalesce nvl still same results shown. nulls im trying rid of in rl , hd columns.they not actual fields in of tables, produced pivot function. note first occurrence of coalesce in code replaces nulls actual zero, while second character '0'. tried 0 gave error. should both numbers (zero) im not experienced in sql , appreciate on this. solution found! out of trial , erro

Javascript Blob upload is corrupted -

so have code modifies image file , converts new image. the new image (represented canvas.todataurl() ) working perfectly, conversion blob generating corrupted images. var reader = new filereader(); reader.onload = function (e) { var canvas = document.createelement("canvas"); var context = canvas.getcontext("2d"); var imageobj = new image(); imageobj.src = e.target.result; imageobj.onload = function () { canvas.width = this.width; canvas.height = this.height; context.drawimage(imageobj, 0, 0); context.textalign = 'right'; context.fillstyle = "#fff"; context.font = "15pt calibri"; context.filltext(new date().tolocalestring(), this.width - 30, this.height - 30); var blb = new blob( [canvas.todataurl()], {type: 'image/jpeg', encoding: 'utf-8'}); buildingservice.addfile({file: blb, filename: guid}); category.pictures

angularjs - ng-bind-html and ng-model together in select dropdown -

i have json file below var locationlist = [ {"id":1,"value":"abc"}, {"id":2,"value":"xyz"}, . . . ] i'm trying dynamically populate dropdown on html below angular code: .factory('locationservice', function($filter){ var location = {}; location.template = ""; location.getlocation = function(){ var template = '<option direction="ltr" value="" id="theoption2">' + $filter('translate')('lsummary_location_text') + '</option>'; locationlist.foreach(function(loc){ var value = loc.value + ' / id: ' + loc.id; template += '<option direction="ltr" value="' + value + '">' + loc.value + '</option>'; }); location.template = template; }, location.gett

nose - Disabling tgscheduler while running nosetests -

i have turbogears 2.3.6 project i've been working on quite time. in project i'm using tgscheduler. i want learn how use tests, , have difficulties starting. when run nosetests –v i error of default tests comes turbogears: valueerror: task name nameofmytask exists and test fails. can tell nose ignore tgscheduler somehow? thanks the test suite in turbogears creates new application instance each test, tests run in separated , isolated environment. reason appglobals created multiple times (one each application). while documentation states start scheduler in appglobals.__init__ , works in simple cases, has side-effect of starting scheduler multiple times when more 1 turbogears application instance created inside same python interpreter (which what's happening when run test suite). i suggest start scheduler through milestone , guaranteed run once each python interpreter ( http://turbogears.readthedocs.org/en/latest/turbogears/configuration/appconfi

ios - how to change xcode app icon? -

Image
i have been trying change apps icon, cannot seem it. have been following example: https://developer.apple.com/library/ios/recipes/xcode_help-image_catalog-1.0/chapters/addinglaunchimagestoanassetcatalog.html but no matter do, cannot icon change. whenever add image, gives me error saying incorrect size, when change size of image xcode tells me new size. is there isn't in example missing? this is way, should this: for example: 40pt - 120:120 @3x, 80:80 @2x , 40:40 @1x for artworks 512:512 @1x , 1024:1024 @2x be attentive icon sizes, , ok :)

What is the use of Icon in the new Android Marshmallow -

what use of icon class in android m. similar thing vectordrawable (introduced in lollipop). it's wrapper class around different image resource types. believe it's meant convenience class situations, , make easier genericize use of different image types. one particular use case notifications, there methods setsmallicon(icon icon) , setlargeicon(icon icon) , allowing set icon using of static createwith* methods in icon class.

python - Discover devices plugged in via ethernet cables? -

i have controller hardwire ethernet cable into. find devices connected via ethernet cable or similar , devices are. eg: >>> ??? [{ host: "192.168.1.4", port: 23, device: 'galil dmc-4143' }] is possible via python? take @ netifaces . should help. here example documentation: >>> netifaces.interfaces() ['lo0', 'gif0', 'stf0', 'en0', 'en1', 'fw0'] >>> netifaces.ifaddresses('lo0') {18: [{'addr': ''}], 2: [{'peer': '127.0.0.1', 'netmask': '255.0.0.0', 'addr': '127.0.0.1'}], 30: [{'peer': '::1', 'netmask': 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', 'addr': '::1'}, {'peer': '', 'netmask': 'ffff:ffff:ffff:ffff::', 'addr': 'fe80::1%lo0'}]} and should work on os x, linux , windows.

python - How to return a value from a method back to the input value -

i have created helper method check zip code format country. because have multiple zip codes (e.g. visit, postal) like use helper method. when debug can see self.zip put value zipcode, when runs trough method zipcode updates should, not return value self.zip. could explain me how work? def onchange_zip(self): self.postal_code_format(self.zip, self.country_id) def postal_code_format(self, zipcode, country): if country.name == "netherlands": zipcode = zipcode.replace(" ", "").upper() if len(zipcode) == 6: numbers = zipcode[:4] letters = zipcode[-2:] if letters.isalpha() , numbers.isdigit(): zipcode = str("{0} {1}").format(numbers, letters) else: raise valueerror("could not format postal code.") else: raise valueerror("could not format postal code.") return zipcode when say zipcod

c++ - How to make header files included by <ClInclude Include=.../> visible globally in the project? -

when have line in .vcxproj file <clinclude include="..\include\something_*.h"/> and in .c file located somewhere else use simple #include "something_a.h" the header file won't visible in compilation, although visible in project/solution explorer in visual studio. i know can add include folder additional include directories list, , compiler use directory search include files, isn't tag supposed itself?

objective c - Find mid-point between two rectangles, intersection + edge aware -

Image
as seen in image, find mid-point between 2 rectangles. if rectangles intersecting mid-point between centers of rectangles. if rectangles not intersecting, mid-point from/between edges of rectangles. i write in obj-c or swift. thx in situation should check first check wether there rectangles overlapped or not. to check wether overlapped or not cgrect recta = cgrectmake(50, 50, 50, 50); cgrect rectb = cgrectmake(100, 100, 50, 50); if (cgrectgetminx(recta) < cgrectgetmaxx(rectb) && cgrectgetmaxx(recta) > cgrectgetminx(rectb) && cgrectgetminy(recta) < cgrectgetmaxy(rectb) && cgrectgetmaxy(recta) > cgrectgetminy(rectb) ) { nslog(@"overlapped"); } else { nslog(@"not overlapped"); } after finding overlapped or not find centres of both rectangles , whatever want. to find center. cgpoint centerb = cgpointmake((cgrectgetminx(rectb) + cgrectgetmaxx(rectb))/2, (cgrectgetminy(rectb) + cgrectg

android studio - Eclipse (SDK Error) -

i'm having problem error in eclipse application. what's reason behind error? how can correct it? hope can me this. [2015-08-19 22:05:28 - android sdk] error when loading sdk: error: error parsing c:\program files (x86)\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\system-images\android-22\android-wear\armeabi-v7a\devices.xml cvc-complex-type.2.4.d: invalid content found starting element 'd:skin'. no child element expected @ point. every time opened it, that's first message popped-up.

html - Adding a scroll to left panel in bootstrap powered page -

i wrote page restaurant shown here . want scroll added left panel. i'm using over-flow-y: scroll left panel shown below: <div class="col-sm-4 col-md-4" id="offers"> <div id="offerone"> <img src="images/images.jpg" class="img-responsive center-block"> </div> <div id="offertwo"> <img src="images/images.jpg" class="img-responsive center-block"> <button class="btn btn-primary center-block">view offer</button> </div> <div id="offerthree"> <img src="images/images.jpg" class="img-responsive center-block"> <button class="btn btn-primary center-block">view offer</b

licensing - .NET reactor : date expiration lock and system date tampering -

with .net reactor api, i've generated 'expirated @ date" license (for instance, software protected , under license until 16th feb 2016). what if, on host machine (winserver 2008), system date tampered because tries extend license indefinitely ?

android - Getting information friends on facebook -

i started studying facebook graph api. take list of friends, , output personal information (general information, employment , education, , etc). how can this? friends list getting so: accesstoken token = accesstoken.getcurrentaccesstoken(); new graphrequest( accesstoken.getcurrentaccesstoken(), "me/taggable_friends?name,id", null, httpmethod.get, new graphrequest.callback() { public void oncompleted(graphresponse response) { //parse json } } ).executeasync(); i tried use "me/friends/{getting_higher_id}", it's not work. {getting_higher_id} looks -> aard2kuv4vbnwfsauz2brt2t3x4su8mpfii4ztb_20jwdbgqcmxzdhhlu2cdylb-paxzqt2muxdambepjotrkqror2dc first of all, taggable_friends tagging friends only, not allowed use else. if want information, must use /me/friends , , can friends authorized app too. more information:

c# - Dictionary with single key multiple values in a list -

i have linq query want put in dictionary. dictionary is dictionary<string, list<string>> how can put query below defined dictionary? ... ... select new { b.propertyname a.propertyvalue, a.propertyorder, }).distinct().todictionary(x => x.propertyname, x => x.tolist() // rest of 2 values should in list ); select new { b.propertyname a.propertyvalue, a.propertyorder}) .distinct() .todictionary(key => key.propertyname, value => new list<string>{ value.propertyvalue, value.propertyorder});

python - How to iterate through security groups in AWS ec2? -

i trying iterate through ec2 security groups. have wrote following code connect , security groups: security_groups = ec2_conn.get_all_security_groups() next step need use group id each security group. in loop used code print : print(security_groups[group_id]) i tried many different attributes instead of [group_id] keep getting error : "nameerror: name 'group_id' not defined" what right way retrieve or print 1 attribute security groups ? here working example of how iterate on security groups, , print group ids import boto ec2_conn = boto.connect_ec2() security_groups = ec2_conn.get_all_security_groups() group in security_groups: print(group.id) some additional information on manipulating security groups: http://boto.readthedocs.org/en/latest/security_groups.html

centos - issue with install newest version of ruby on cetos -

please help!!! have issue installing new version of ruby in centos6. i'l try install using rvm : /usr/local/rvm/bin/rvm install 1.9.2 and got next message : error running 'requirements_centos_libs_install libyaml-devel readline-devel libffi-devel sqlite-devel', showing last 15 lines of /usr/local/rvm/log/1439995406_ruby-1.9.2-p330/package_install_libyaml-devel_readline-devel_libffi-devel_sqlite-devel.log if don't want/need both architectures anymore can remove 1 missing update , work. you have duplicate versions of libffi installed already. can use "yum check" yum show these errors. ...you can use --setopt=protected_multilib=false remove checking, never correct thing else go wrong (often causing more problems). protected multilib versions: libffi-3.0.5-3.2.el6.i686 != libffi-3.0.9-1.el5.rf.x86_64 ++ return 1 ++ return 1 requirements installation failed status: 1. i try remove l

javascript - Jquery each data object attribute -

i trying create table rows containing data each attribute object response using $.each, id, purpose, , amount coming undefined. have tested response in fiddler , data being received correctly, problem seems in "item" part. here jquery: $.ajax({ type: "get", url: "https://chad-test4.clas.uconn.edu/api/commitments/getcommitmentpurposes/2", contenttype: "application/json; charset=utf-8", datatype: "json", success: function (response) { var purposes = $("#purposes tbody"); if (response.success == true) { purposes.empty(); var buttons = '<tr><td><button type="button" class="btn-primary">save</button>' + '<button type="button" class=".btn-danger">delete</button></td>' var list = respons

java - JavaFX app with SOAP communication. Is it possible? -

i new javafx , soap. want make javafx app able receive xml files using soap. i found link: http://abhisarswami.blogspot.sk/2009/05/soap-request-from-javafx.html unfortunately tutorial javafx 1.0, means .fx script files aren't supported in newer versions. is possible it? have useful articles, advices or code snippets?

javascript - class not removing as expected with click counter -

var clickcount = 0; $(".arrowright").click(function () { clickcount++; if (clickcount >= 3) { clickcount = 0; $(".arrowright").removeclass("active"); $(".arrowright").addclass("disable"); } else { $(".arrowright").removeclass("disable"); // line isnt working $(".arrowright").addclass("active"); // works } }); everything works above until ' disable ' class. adds after 3 clicks, idea clicks reset after 3rd well, hints else , ' active ' gets added correctly ( eg. within else after 3rd click resets -- but disable class not remove! .disable { pointer-events: none; cursor: default; } changes required css remove line css class pointer-events: none; so class be .disable { cursor: default; } here example jsfiddle https://jsfiddle.net/stt2632m/

awk - Find the value of a variable and replace it with new value in UNIX -

i want access text file , read of contents change them new value. this find , replace helpful requirement different. say if these file contents image.description=template image 08182015 image.version=1.3.111 baseline.name=001_08_18_2015 i want change them to image.description=template image 08192015 #19 instead of 18 image.version=1.3.112 #112 instead of 111 baseline.name=001_08_19_2015 #19 instead of 18 at point of time not knowing value of each variable know variable name "image version" need script find value of variable image.version , auto increment value next possible integer. any suggestions/ thoughts? with gnu awk 3rd arg match(): $ awk 'match($0,/(image\.version.*\.)(.*)/,a){$0=a[1] a[2]+1} 1' file image.description=template image 08182015 image.version=1.3.112 baseline.name=001_08_18_2015 for others since no arithmetic involved should able use gensub() similarly. or, maybe kind of thi

android - Samsung KNOX enabling KIOSK Mode with package name does not work -

i trying use kiosk mode sample app on galaxy s4 (android 4.4.2). functionality works fine except method: public void enablekioskmode(string kioskpackage) the kioskreceiver gets action_enable_kiosk_mode_result message, kiosk mode not started. what need achieve kiosk mode starting custom application on pressing home button. perhaps i'm using wrong method? difficult what's going on few details, there requirements able enable kiosk samsung knox : your app must device administrator your knox license must have been activated device administrator app (be careful, asynchronous process , requires user interaction. i.e. user must approve license if didn't yet) your device administrator app must have permission : android.permission.sec.mdm_kiosk_mode note kiosk mode samsung knox disable home key. (i.e. not redirect kiosk app.)

c# - Checking Elasticsearch Heap Size -

how can check heap size assigned elasticsearch engine, there way check using url api ? , can use nest check it? thanks use get _nodes/stats then @ following in return /jvm/mem/heap_committed_in_bytes

Bootstrap 3: Stack cols only when screen size is less than 500px -

i want bootstrap stack columns when device size less 500px, below code stacks them after reach small threshold 768. how can change that? <div class="row"> <div class=" col-sm-4"> 1 </div> <div class=" col-sm-4"> 2 </div> <div class=" col-sm-4"> 3 </div> you can change less file variables change screen-sm-min = 768px to screen-sm-min = 500px if want small devices in general (default < 768px ) use class=" col-sm-4 col-xs-12" http://getbootstrap.com/css/#grid

ios - Auto capture video using Swift -

i'm working on piece of code responsible starting video recording on button click. when click button camera view opening .startvideocapture() function doesn't start recording. i strange output every time button pressed: 2015-08-19 16:48:09.588 record video swift[922:227442] snapshotting view has not been rendered results in empty snapshot. ensure view has been rendered @ least once before snapshotting or snapshot after screen updates. also, there way hide camera view , instead of place there progress bar or something? class viewcontroller: uiviewcontroller, uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate, uigesturerecognizerdelegate { let capturesession = avcapturesession() var previewlayer : avcapturevideopreviewlayer? var capturedevice : avcapturedevice? var imagepicker = uiimagepickercontroller() override func viewdidappear(animated: bool) { if uiimagepickercontroller.issourcetypeavailable(uiim

python - Windows Powershell not quitting script with Ctrl-C -

so running python 3.4 scripts on windows, , when run particular script, have infinite loop (while true:) using, when try quit script ctrl-c, not exiting script. prints keyboard interrupt, if has quit, leaves blinking cursor , not let me type, have exit out red x. import serial import time import pyfirmata #from pyfirmata import arduino, util, pwm board = pyfirmata.arduino('com4', baudrate = 9600, timeout = 5) time.sleep(2) #sleep in units of sec = pyfirmata.util.iterator(board) it.start() digital1 = board.get_pin('d:5:p') digital2 = board.get_pin('d:6:p') digital3 = board.get_pin('d:10:p') digital4 = board.get_pin('d:11:p') digital = (digital1, digital2, digital3, digital4) distobject = 1.5 #start warning @ 4 inches away objects (arbitrary) forcegraspl = 0 forcegraspr = 0 maxforcel = 60 maxforcer = 60 motormaxforcel = maxforcel / 2 motormaxforcer = maxforcer / 2 while true: left = 0 right = 0

How to fix basename of containers when using docker-compose? -

it seems docker-compose adds current folder name base-name each created container. following directory structure: /myproj/docker-compose.yml and docker-compose.yml content: web: ... worker: ... docker-compose create following containers: myproj_web_1 myproj_worker_1 i don't mind suffix ( _x ) "fix" myproj constant "always_same" move docker-compose.yml file around , still have containers same names. how can it? there 2 ways this. set environment variable with export compose_project_name=foo or starting stack -p switch docker-compose -p foo build docker-compose -p foo

powershell - Best way to detect key combination in windows using built in scripting languages -

i thinking of scenario detect key combination [preferably window key + a] using built in scripting languages vb script, powershell script, batch script etc.. there way ? i love autohotkey create script , detect key combination. fast , easy use , have dozens of key combinations have scripted , use every day. if must use built-in scripting language, easiest create desired script in whatever language prefer (for ex. powershell). create shortcut run script (for ex. powershell.exe -file "c:\myscript.ps1" ). then after testing shortcut , script, go shortcut's properties, , there "shortcut key" field can bind key combination to. using built in languages bit more cumbersome, , have have separate script , shortcut each key combination. compared autohotkey can combine key combinations 1 file.

c# - Use external existing file as resource file in .NET -

i'm writing integration tests sql scripts live in folder separate project. since setup of machine i'm writing on tests on differs machine run on, include them resource files rather hard coding paths. default behavior adding existing file resource file copies file, not want in case of sql scripts updated. does know best way resource file reference sql scripts in folder separate project, or somehow copy them assembly @ compile time don't have load them via absolute/relative paths? edit: clarity, i'm trying resource file act symlink original file @ compile time. adding existing file resource in file in visual studio makes copy of file, means changes original not propagated resource file. after asking on irc, guided me looking for. able add existing file project as link (there arrow on add box when in file dialog), , set it's build action property embedded resource https://support.microsoft.com/en-us/kb/306234 daniel posted link on how read embedd

java - class path resource [../EnableTransactionManagement.class] cannot be opened because it does not exist -

i'm having error in mvc spring project made in spring tool suite. java file there , there no compilation error in there, have included respective jars. stand-alone program test runs fine, when try publish on test server, web page display http 500 status error. i made default web project spring, , works,the server display home page, used template make own project, , since didn't touched configuration files unrelated webserver (only spring , hibernate xml files) i'm not sure why i'm getting this. here full message stack trace(only error) http 500 status - servlet.init () servlet threw exception appservlet org.springframework.beans.factory.beandefinitionstoreexception: failed load bean class: mvc.test.hib.hibernateconfig; nested exception java.io.filenotfoundexception: class path resource [org/springframework/transaction/annotation/enabletransactionmanagement.class] cannot opened because not exist here mentioned java file supposed error packa

c# - Why is possible to call static methods of a non-static class? -

taking consideration following class structure: [public non-static class] using unityengine; using system.collections; public class gamemanager : monobehaviour { public static void play() //static method { print("play audio!"); } } another class calling: using unityengine; using system.collections; public class testclass : monobehaviour { // use initialization void start () { gamemanager.play(); } // update called once per frame void update () { } } because possible call method without instantiating class gamemanager? from here a static class same non-static class, there 1 difference: static class cannot instantiated the fact it's not static class doesn't affect way static methods can used.

html - How to return X results in PHP where variable is true -

i'm having hell of time figuring out. i'm able pull data database no problem , show of results, however, want limit number of results returned, want show results have status of 1 , ignore 0. here's have far... <?php $query = "select * " . $dbtable . " order `id` desc;"; $result = mysql_query($query) or die('error: ' . mysql_error()); ?> ...other stuff... <?php while ( $row = mysql_fetch_array( $result ) ) { $username = $row["username"]; $user_photo = $row["user_photo"]; $location = $row["location"]; $status = $row["status"]; ?> <li><img src="<?= $user_photo ?>" class="collab" data-username="<?= $username ?>" data-location="<?= $location ?>" /></li> <?php } ?>

How to create a signature for the Ascentis API using PHP -

i trying create proper signature ascentis api. there documentation http://www.ascentis.com/api/ascentis_api_documentation.pdf . page 4 describes signature format. here php code. doing wrong? "not authorized error". $url='https://selfservice2.ascentis.com/mycompany/api/v1.1/employees'; $timestamp=gmdate('y-m-d\th:i:s\z'); $path=strtolower(str_replace('https://selfservice2.ascentis.com','',$url)); $signature_string="get {$path} {$timestamp}"; $signature=hash_hmac("sha1",$signature_string,$secret_key); $authorization=encodeurl($client_key).':'.encodeurl($signature); after playing trial , error game able working. turns out have set hash_hmac raw_output. here working code: $url='https://selfservice2.ascentis.com/mycompany/api/v1.1/employees'; $timestamp=gmdate('y-m-d\th:i:s\z'); $path=strtolower(str_replace('https://selfservice2.ascentis.com','',$url)); $signature_st

Difference between CallTo/To and CallFrom/From in Twilio -

when make outgoing call using twilio api & twiml app twilio makes request server following params: 'accountsid' => '...', 'applicationsid' => '...', 'caller' => 'client:2', 'callstatus' => 'ringing', 'callfrom' => 'some_phone_number', 'called' => '', 'to' => '', 'callto' => 'some_phone_numeber', 'callsid' => '...', 'from' => 'client:2', 'direction' => 'inbound', 'apiversion' => '2010-04-01', what's difference between callto (which equals actual phone number i'm calling to) , (which empty reason) ? same , callfrom. couldn't find info in docs callto/callfrom. plus, why empty? update some additional info. make call twilio number real russian phone number. hangup call. there no forwarding/redirecting. twiml app out

c++ - Integer Compression Library -

i trying use library https://github.com/lemire/simdcompressionandintersection/ visual studio 2012 getting few compilation errors. headers #include <sys/resource.h> #include <sys/time.h> , #include <sys/mman.h> doesn't exist. can remove them. after getting errors in many lines have format: __attribute__((const)) inline uint32_t gccbits(const uint32_t v) { return v == 0 ? 0 : 32 - __builtin_clz(v); } missing type specifier - int assumed. note: c++ not support default-int does know how use library visual studio 2012? edit: compiling in g++. in terminal type make example , ./example . segfault before output. know wrong? from requirements section: a recent gcc (4.7 or better), clang or intel compiler. ... tested on linux , macos. should portable windows , other platforms. good luck port.

javascript - How to download HTML page for temporary use with chrome extension -

i'm working on chrome extension getting direct link of video vimeo. far can make (?content?) script, can id url link, there problem, need download page id http://player.vimeo.com/video/ /config , after need parse regex (this should not problem). main problem download page temporarily . i'm new in making extensions don't know if content script way start. practice have different content scripts different pages (like 1 vimeo, 1 tedtalks example) or should in 1 script? in advance imho, type of apps better built using server behind scene process urls. can build them using php/python/whatever want use. can caching, etc there too. the decision if it's going server or chrome app you. tried both ended server codebase more manageable , no need keep updating chrome app when video sites changes algorithm might happen frequently. on other hand though advantage of building using chrome extension may able access loggedin user's videos, or ip restricted vid

Lucene.Net range subquery not returning expected results (RavenDB related) -

i'm trying write lucene query filter data in ravendb. of documents in specific collection assigned sequential number, , valid ranges not continuous (for example, 1 range can 100-200 , 1000 1400). want query ravendb using raven studio (v2.5, silverlight client) retrieve documents have values outside of these user-defined ranges. this overly simplified document structure: { externalid: something/1, sequentialnumber: 12345 } to test, added 3500 documents, of have sequentialnumber that's inside 1 of following 2 ranges: 123-312 , 9000-18000 , except 1 has 100000123 . externalid field reference parent document, , test documents have field set something/1 . lucene query came with: externalid: something/1 , not (sequentialnumber: [123 321] or sequentialnumber: [9000 18000]) running query in ravendb's studio returns documents sequentialnumber isn't in 123-321 range. expect return document has 100000123 sequentialnumber . i've been trying google h

c# - Accessing the actual value of a RadGrid DataItem rather than its text -

i have radgrid autogenerate columns set true . my datasource looks following: datatable dt = new datatable(); dt.columns.add("column1", typeof (double)); dt.columns.add("column2", typeof (double)); dt.columns.add("column3", typeof (double)); dt.rows.add(0.05547, 0.03432, 0.03444); dt.rows.add(0.54612, 0.77764, 0.86763); dt.rows.add(0.65711, 0.88735, 0.67864); in grids itemdatabound event formatting values percents this: double number; if (double.tryparse(item[col.uniquename].text, out number)) { item[col.uniquename].text = string.format("{0:p2}", number); } now lets want loop through grid dataitems somewhere else in code , original values, not formatted percent values. best way this? foreach (griddataitem item in radgrid1.items) { // returning value 5 %, need 0.05547 item["column1"].text; } since formatting text in itemdatabound , cannot original value somewhere e

swift - NSMutableDictionary path "unexpectedly found nil while unwrapping an Optional value" -

i have simple: let documentspath = nssearchpathfordirectoriesindomains(.documentdirectory, .userdomainmask, true)[0] as! string let datapath = documentspath.stringbyappendingpathcomponent("images") let imagespath = datapath.stringbyappendingpathcomponent(filename) var dictionary = nsmutabledictionary(contentsoffile: imagespath)! and after gets last line crashes , gives me ol' fatal error: unexpectedly found nil while unwrapping optional value the variable filename declared var filename: string! i'm unable write path well. doing wrong? another potential issue in addition gnasher729's suggestion contentsoffile initializer nsdictionaries , subclasses: return value: an initialized dictionary—which might different original receiver—that contains dictionary @ path, or nil if there file error or if contents of file invalid representation of dictionary. so if there issue dictionary, when force unwrap in line var dictionary = ns

java - Trying to get a Border near on JPanel but it's vanishing -

Image
i have field of little jbuttons[15][30] (35px) , want border around field. thought it's enough write following: private void gamefield() { fieldpanel = new jpanel(); box box = box.createverticalbox(); gridbaglayout bag = new gridbaglayout(); fieldpanel.setlayout(bag); gridbagconstraints gbc = new gridbagconstraints(); fieldpanel.setborder(new compoundborder(new emptyborder(50, 0, 0, 0), borderfactory.createlineborder(color.black))); fieldpanel.setmaximumsize(new dimension(800, 500)); fieldpanel.setminimumsize(new dimension(800, 500)); box.add(fieldpanel); (int line = 0; line < field.length; line++) { (int column = 0; column < field[line].length; column++) { field[line][column] = new jbutton(); field[line][column].setpreferredsize(new dimension(25, 25)); field[line][column].setopaque(true); field[line][column].setcontentareafilled(false);

php - Creating dropdown menu in form with mixture of input type text from main table and dropdown options for secondary tables -

i attempting display data 3 different database tables in php form. want edit page shown below if inventoryid isn't set show current selection of inventoryid have selected. other tables working through inventory table fetch data. example, type has table named typeid , id table 1 , name tyid desktop monitor. type entry inventory table integer 1. same descriptor table name descriptorid , id 1 selected on main inventory table. have used left join display tables want know how can add dropdown box form instead of integers tables typeid , others. code below shows current values of inventory table integers selected secondary tables how can make selections dropdown boxes while still displaying current selection , still allow input text other selections? <form action="" method="post"> <div> <?php if ($inventoryid != '') { ?> <input type="hidden" name="inventoryid" v

swift2 - How do you enumerate OptionSetType in Swift? -

i have custom optionsettype struct in swift. how can enumerate values of instance? this optionsettype: struct weekdayset: optionsettype { let rawvalue: uint8 init(rawvalue: uint8) { self.rawvalue = rawvalue } static let sunday = weekdayset(rawvalue: 1 << 0) static let monday = weekdayset(rawvalue: 1 << 1) static let tuesday = weekdayset(rawvalue: 1 << 2) static let wednesday = weekdayset(rawvalue: 1 << 3) static let thursday = weekdayset(rawvalue: 1 << 4) static let friday = weekdayset(rawvalue: 1 << 5) static let saturday = weekdayset(rawvalue: 1 << 6) } i this: let weekdays: weekdayset = [.monday, .tuesday] weekday in weekdays { // weekday } as of swift 4, there no methods in standard library enumerate elements of optionsettype (swift 2) resp. optionset (swift 3, 4). here possible implementation checks each bit of underlyin

selenium webdriver error when searching by.id. -

i new selenium, , first webdriver code using java. trying open google page , search seleniumhq.org. question - when check element using name, code works , same code if change find element id. error message "exception in thread "main" org.openqa.selenium.invalidelementstateexception: element disabled , may not used actions" kindly me understand issue. package com.webdriver.chapter1; import java.util.list; import org.openqa.selenium.by; import org.openqa.selenium.webdriver; import org.openqa.selenium.webelement; import org.openqa.selenium.firefox.firefoxdriver; public class navigatetourl { public static void main(string[] args) { webdriver driver = new firefoxdriver(); driver.get("http://www.google.co.in"); webelement searchbox = driver.findelement(by.id("gs_htif0")); //system.out.println(searchbox.gettext()); //list<webelement> buttons = driver.findelements(by.classname("gsfi")); //system.out.println(buttons.size());