Posts

Showing posts from March, 2012

java me - Clearing the canvas with J2ME -

i'm trying create program shows 2 images @ random locations , changes them every second. problem when image redrawn can still see image in previous position. i'm using wtk 2.52 if that's relevant. public void run() { while(true) { dvert = rand.nextint(136); dhorz = rand.nextint(120); rvert = 136 + rand.nextint(136); rhorz = 120 + rand.nextint(120); try { thread.sleep(1000); } catch (interruptedexception e) { system.out.println("error"); } repaint(); } } public void paint(graphics g) { int width = this.getwidth() / 2; int height = this.getheight() / 2; g.drawimage(imgr, rvert, rhorz, g.top | g.left); g.drawimage(imgd,dvert,dhorz,g.top | g.left); //g.drawstring(disp, width, 50, graphics.top | graphics.hcenter); //g.drawstring(centermsg,width, height, graphics.top | graphics.hcenter); system.out.println(wi

Swift L-System Algae -

so i'm doing fun in ibm swift sandbox. did l-system algae in scala , though cool in swift see how language compares. https://github.com/i2obin/l-system-algorithms-and-fractals/blob/master/algae.scala that's scala 1 show i'm aiming for, , have in swift; /** * created t.hood on 26/01/16 * l-system algae * */ import foundation // mapping function string func stringmap(x: string) -> string { var str = x; // replace characters in string str = x.stringbyreplacingoccurrencesofstring("a", withstring: "ab") + str.stringbyreplacingoccurrencesofstring("b", withstring: "a"); // return mapped string; return str; } func lsys() { // declarations var iteration : int = 2; var x = 0; var lsystem: string = "a"; let chara: character = "a"; let charb: character = "b"; while(x != iteration) { print(lsystem) // iterate through characters in string chars in lsy

jquery - Bouncing divs in their own place? -

i'm trying create simple bouncing effect divs. bouncing effect works in way don't why divs go under each-other when bounce not want. need divs bounce in own place. this fiddle and code: $(document).ready(function() { $(".balls").effect('bounce', { times: 3 }, 'slow'); }); the bouncing effect kicks in on page load. appreciated. the issue because library adding containing div element around each .balls element default display: block , hence each element pushed it's own line. when animation ends element removed , return sitting on same line. fix need add rule css: .ui-effects-wrapper { display: inline-block; } updated fiddle

javascript - Three.js - Questions about (the use of) THREE.BufferGeometry -

Image
as understood using buffer geometries increase performance , decrease memory usage because it reduces cost of passing data gpu . and understood from @westlangley post here: three.buffergeometry replacing three.geometry computationally more efficient. i using three.js - r72 . when draw geometries make meshes , add them scene see there 2 properties inside geomtries __directgeometry , _buffergeometry . here in three.boxgeometry : here in three.geometry : here in three.shapegeometry : my questions: what three.directgeometry , do? (i cannot seem find documentation on this) is three.buffergeometry stored in _buffergeometry automatically used? if not, can use instead of geometry boost performance? there conversion methods: three.buffergeometry has togeometry , three.geometry has tobuffergeometry . if convert normal geometries buffer geometries using method, give me same performance increase compared drawing them three.buffergeometry start? how ,

Awk error message targeting a parentheses -

i'm running awk command cant find why keeps on telling me wrong, variables instantiated (i have replaced them string here show error, error same), braces closed, advice? key=$(echo "hello,there" | awk -f"," -v index=2 '{for(i=1; i<=nf; i++) if ($i ~ $index) print i}') i'm not perfect awk user, cant spot issue here advice? index built-in function (keyword) cannot use variable name. change to: awk -f"," -v idx=2 '{for(i=1; i<=nf; i++) if ($i ~ idx) print i}') the field specifier, $ , prefixing idx not correct, want use string is.

c++ - Compile error when using std::cout between if/elseif statements -

i wondering why compile error when try use std::cout in between, say, if statement , else if statement. example: if (condition) {body} std::cout << "hello world" << std::endl; else if (condition) {body} gives error error: 'else' without previous 'if' let me right first: want execute cout statement in between conditional no matter whether condition met or not, i.e. no matter whether body of if got executed or not. as previous commenters noted, cannot place between end of scope of if-block , else keyword. what approaching splitting if-else-if block 2 separate if-blocks: if (condition1) { body1 } cout << "hello world" << endl; if (!condition1 && condition2) { body2 }

angularjs - How to use ng-include from code? -

i want use ng-include directive code. var html = '<div ng-include="\'mytemplate.html\'"></div>'; $compile(html)($scope); angular.element(document.getelementbyid('mydiv')).append(html); but, 1 not working expected. can explain how achieve properly? if want include html webpage, should use ng-bing-html instead : html <div id="mydiv" ng-bind-html="template"></div> js .controller('name', function($scope, $http, $sce, ...) { $http.get('mytemplate.html').success(function(template) { $scope.template = $sce.trustashtml(template); }); });

Can we use pthread library for opencv C++ programming? -

i have implemented opencv program can capture frames video file , process , create new file. doing single in file . want multiple files . have idea posix thread pthread library . is or bad idea . when implement pthreads in opencv program got errors following : opencv error: assertion failed (_src.samesize(_dst) && dcn == scn) in accumulate, file /home/satinder/opencv_installation/opencv/opencv/modules/imgproc/src/accum.cpp, line 915 what(): /home/satinder/opencv_installation/opencv/opencv/modules/imgproc/src/accum.cpp:915: error: (-215) _src.samesize(_dst) && dcn == scn in function accumulate aborted (core dumped) corrupted double-linked list: 0x00007fcd048f73d0 *** aborted (core dumped) seg fault time . is there possible way how can implement multi-threading or equivalent goal make program can more 1 input files same processing. following code snapshot : #include "opencv2/highgui/highgui.hpp" #include <

Metaprogramming oracle sql select statement -

let's imagine have query following: select case when 1 = 1 1 else 0 end, case when just_one = 1 1 else 0 end, case when another_one = 1 1 else 0 end, case when 2 = 1 1 else 0 end, case when just_two = 1 1 else 0 end, case when another_two = 1 1 else 0 end -- 20 more things changes columns name some_table; as can see, difference between these 2 groups in first 1 use columns have 'one' , in second ones have 'two' , have around 30 groups in actual query wonder if there way shorten somehow? since different columns, must explicitly mention them separately in select list. cannot dynamically in pure sql . i suggest, using text editor , hardly take minute or 2 write entire sql. you use decode have less syntax instead of case expression verbose. for example, decode(one, 1, 1, 0) col1, decode(just_one, 1, 1, 0) col2, decode(another_one, 1, 1, 0) col3, decode(two, 1, 1, 0) col4, decode(just_two, 1, 1, 0) col5, decode(an

php - inserting multiple checkboxes into one column but in multiple rows -

i have page multiple checkboxes. code inserts each checkbox separate column, although causing issues when looking pull information out again. i had been able insert 1 column answers went 1 field rather separate rows. need user_id of user logged in insert each row each box checked well. can please copy , amend code able insert 1 column (response) , separate rows, along user_id. here code, thank you <?php session_start(); include_once 'dbconnect.php'; if(!isset($_session['user'])) { header("location: index.php"); } $res=mysql_query("select * users user_id=".$_session['user']); $userrow=mysql_fetch_array($res); if(isset($_post['submit'])) { header("location: enisatvids.php"); @$userid=$_session['user']; @$checkbox1=$_post['log']; @$checkbox2=$_post['worktray']; @$checkbox3=$_post['visual']; @$checkbox4=$_post['changepd']; @$checkbox5=$_post['logout']; @$che

Filter array of dictionaries - SWIFT -

i have following array: [[user1id: nsdate], [user2id: nsdate], [user3id: nsdate]] can filtered out dictionary user2id ? let test = [["user1id": nsdate()], ["user2id": nsdate()], ["user3id": nsdate()]] let newarray = test.filter { $0.keys.contains("user2id") }.flatmap { $0 } print(newarray) // ["user2id": 2016-01-28 10:52:29 +0000] i've edited dictionary bit testing purposes. answer comment: if want know if array contains dictionary "user2id" key can following: test.contains { $0.keys.contains("user2id") } ? print("yep!") : print("nope!") // "yep!"

javascript - WooCommerce - Triggering variation select with custom select boxes -

i'm trying use fancyselect.js style select boxes used on woocommerce , have managed few i'm struggling variation form on product pages. while fancyselect triggers change event on original select box, appears affect nothing. looking @ javascript used in variations form, looks they've unbinded change event on select box , handling other way, triggering events on .variations_form instead. can't seem work though. my code along lines of: $('.summary select').fancyselect().on('change.fs', function() { $(this).trigger('change.$'); $('.variations_form').trigger('woocommerce_variation_select_change'); }); i've tried triggering multiple events none seem have affect. any ideas? thanks. so turns out original trigger didn't work, reasons can't quite work out. however, manually triggering change event on original select box worked degree, wouldn't update fancyselec

Confused about integration of Java file, JSPs, servlets? -

this first time working java , tomcat , i'm little confused how fits - i've googled endlessly can't seem wrap head around few concepts. i have completed java program outputs bufferedimages. goal these images display on webpage. i'm having trouble understanding how java file (.java) running in netbeans interacts servlet and/or jsp. ideally, servlet or jsp (not 100% clear on how either of works. understand syntax looking @ various examples, however) output (the bufferedimages) when program runs , html file somehow interact whatever doing images displayed on webage. i'm not sure if possible. if suggest general order of going things, awesome. in every example/tutorial find, no 1 uses .java files - there .classes in web-inf folder -- doesn't seem people using full on java programs. however, need .java program run can retrieve output , use on webapp. any general guidance appreciated! i think kind of documentation sadly lacking; many think exampl

Cannot create emulator via Jenkins' Android Emulator Plugin -

when jenkins tries generate emulator, errors out with: tools/android create avd -f -a -c 256m -s 1080x1920 -n hudson_de-de_480_1080x1920_google_inc._google_apis_23_x86 -t "google inc.:google apis:23" --abi x86 error: invalid --tag default selected target. but tools/android list targets outputs id: 6 or "google inc.:google apis:23" name: google apis type: add-on vendor: google inc. revision: 1 description: android + google apis based on android 6.0 (api level 23) libraries: * com.android.future.usb.accessory (usb.jar) api usb accessories * com.google.android.media.effects (effects.jar) collection of video effects * com.google.android.maps (maps.jar) api google maps skins: hvga, qvga, wqvga400, wqvga432, wsvga, wvga800 (default), wvga854, wxga720, wxga800, wxga800-7in tag/abis : google_apis/x86 what doing wrong? apparently, --abi parameter needs fix, not --t

api - Could not install search plugins and theme in wordpress -

Image
i have installed wordpress manually using ftp in 1and1 windows shared hosting. not see see plugins when open "add new" plugins page wordpress not able connect tcp://api.wordpress.org:80 fetches plugins. happens in theme page. the error - "warning: stream_socket_client() [function.stream-socket-client]: unable connect tcp://api.wordpress.org:80 (a connection attempt failed because connected party did not respond after period of time, or established connection failed because connected host has failed respond. ) in e:\kunden\homepages\25\d611218669\www\hosting\wp-includes\class-wp-http-streams.php on line 150" i have given wp-content permissions. see attached image i can solve problem? windows server have these issues usually, wordpress such cms need proper folder permission wp-content folder. when try install plugins or themes, wordpress need wp-content folder write permission. more details folder permissions wordpress, refer : https://codex.wor

Transpose Columns to Row in Access SQL with INNER JOIN -

i trying hard figure out how transpose columns rows following query: select roomcalendar.roomcalendarid, rateroomcombination.ratetypeid, rateroomcombination.roomtypeid, ratetype.ratetypename+' '+roomtypes.roomname rooms, hotels.hotelid, hotels.hotelname, roomcalendar.availability, roomcalendar.bookednights, roomcalendar.finalavailability, roomcalendar.rate, roomcalendar.pricingdate hotels inner join (roomtypes inner join (ratetype inner join (rateroomcombination inner join roomcalendar on rateroomcombination.rateroomcombinationid = roomcalendar.rateroomcombinationid) on ratetype.ratetypeid = rateroomcombination.ratetypeid) on roomtypes.roomtypeid = rateroomcombination.roomtypeid) on (hotels.hotelid = roomtypes.hotelid) , (hotels.hotelid = ratetype.hotelid) hotels.hotelid=1 , roomcalendar.pricingdate between #01/01/2016# , #31/01/2016# , roomcalendar.rateroomcombinationid=17 the results query following: pricingdate rooms availability bookednights finalavail

matlab - Extract the diagonal of data and regroup the numbers -

i have data shown in below: for a=1:2 b=1:3 m{a,b}=zeros(3,3) end end m{1,1}=[6 1 1;1 7 1;1 1 6]; m{1,2}=[3 2 2;2 5 2;2 2 6]; m{1,3}=[5 3 3;3 9 3;3 3 7]; m{2,1}=[2 4 4;4 5 4;4 4 8]; m{2,2}=[2 1 1;1 6 1;1 1 5]; m{2,3}=[6 2 2;2 7 2;2 2 8]; i take diagonal of each set of data , regroup these numbers.for example, %result row_1_1=[6;3;5] %which 6 m{1,1}(1,1), 3 m{1,2}(1,1) , 5 m{1,3}(1,1) row_1_2=[7;5;9] %which 7 m{1,1}(2,2), 5 m{1,2}(2,2) , 9 m{1,3}(2,2) row_1_3=[6;6;7] %which 6 m{1,1}(3,3), 6 m{1,2}(3,3) , 7 m{1,3}(3,3) row_2_1=[2;2;6] %which 2 m{2,1}(1,1), 2 m{2,2}(1,1) , 6 m{2,3}(1,1) and on. any idea how these result??thanks~ you do: row_result = zeros(a,b,3); i=1:a j=1:b k = 1:3 row_result(i,k,j) = m{i,k}(j,j); end end end for sample data provided, yield results follows: >> row_result(1,:,1) ans = 6 3 5 >> row_result(1,:,2) ans = 7 5 9 >> row_re

javascript - Require local node modules with absolute paths doesn't work on Windows -

i'm developing node application several modules. node-application transpiled babel /dist/app . this example-structure . |- main | |- config.js | |- factories | | |- example.js this config.js : const ex = require("/main/factories/example"); i launch config.js node dist/app/main/config.js . resulting error is: error: cannot find module '/main/factories/example"; however when using const ex = require("./factories/example"); works should. this problem occurs on windows (testing windows 8.1), both os x , linux fine. what problem here? it's other way around, code works expected on windows. /main/factories/example means c:/main/factories/example on windows. works on osx/linux because of reason (node_path being set probably). i'd suggest not rely on side effect have working code , don't use relative path either (entirely dependant on working directory), should build absolute path this: const ex = re

git - TortoiseGit fatal : can not hash , permission error -

Image
whenever switch new branch of file permissions change if assign permissions here once switch again new branch, again permissions change. i tried revert option without success. i tried using new clone repository experienced same problem ... due problem cannot switch new branch. can 1 me? first check branch folder present inside htdocs if there then..if htdocs folder present inside c: drive cause permission issue in computer ... change xampp installation in other drive try.. because in windows system uac settings may cause problem

ios - Cannot implement Swift SSLCreateContext -

i new ios development, , trying implement ssl connection custom port. i found code answer best/easiest implementation of secure connection on socket https://stackoverflow.com/a/30733961/2306428 however, getting these errors: use of unresolved identifier 'ksslclientside' use of unresolved identifier 'ksslstreamtype' use of unresolved identifier 'ksslsessionoptionbreakonclientauth' i have checked , running swift version 2.1.1, using ios 9.2 sdk , xcode 7.2. have tried adding import security has no effect. what reason these constants not being found? the line being tested here: https://github.com/ksred/bank-ios/blob/master/bank/tcpclient.swift#l209 please use identifiers declared in swift: if let sslcontext = sslcreatecontext(kcfallocatordefault, sslprotocolside.clientside, sslconnectiontype.streamtype) { sslsetiofuncs(sslcontext, sslreadcallback, sslwritecallback) sslsetconnection(sslcontext, &socketfd) sslsetsessionopti

xaml - Xamarin Forms List View Showing Row items in Frames -

Image
can please recommend me sample code create framed lines shown in picture. can see in image, example first row, m should in 1 frame , other 3 items in row should in row. below please see code, appreciated. <?xml version="1.0" encoding="utf-8" ?> <contentpage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:class="xyzclass.views.exams.examspage" title="{binding pagetitle}"> <stacklayout verticaloptions="fillandexpand"> <image source="xyzclassheader.png" aspect="aspectfit" /> <grid backgroundcolor="#0075c1"> <grid.rowdefinitions> <rowdefinition/> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="*"/> <columndefinition width="*"/&g

python - What is global format() function meant for? -

there str.format() method in python familiar not work same way format() function (global-builtin). what purpose of global format() function? the format() function formats one value according formatting specification. the str.format() method parses out template , , formats individual values. each {value_reference:format_spec} specifier applied matched value using format() function , format(referenced_value, format_spec) . in other words, str.format() built on top of format() function. str.format() operates on full format string syntax string , format() operates on matched values , applies format specification mini-language . for example, in expression 'the hex value of {0:d} {0:02x}'.format(42) the template string has 2 template slots , both formatting same argument str.format() method. first interpolates output of format(42, 'd') , other format(42, '02x') . note second argument in both cases format specifier, e.g. comes a

sms - Cannot convert gsm to unicode -

dears i using kannel 1.5.0 gateway smpp on rhel6 , when receive sms these errors: 2016-01-28 13:28:07 [8613] [6] warning: not convert gsm (0xd4) unicode. 2016-01-28 13:28:07 [8613] [6] warning: not convert gsm (0xf2) unicode. ..... and receive messages incorrectly application, here request captured: http://127.0.0.1:9091/services/smsreceive?msisdn=%2b353872849216&coding=0&smstext=%c3%85%3ch%c3%b9a%c3%91%c3%b9%25evm%c3%b9)zx%c3%acp&dcs=-1&charset=utf-8' and kannel configuration: group = core admin-port = 13001 smsbox-port = 13002 admin-password = bar log-file = "/home/user/logs/kannellogs/smscgateway.log" log-level = 0 box-deny-ip = "*.*.*.*" box-allow-ip = "127.0.0.1;172.*.*.*;192.*.*.*;10.*.*.*" admin-allow-ip = "127.0.0.1;172.*.*.*;192.*.*.*;10.*.*.*" admin-deny-ip = "*.*.*.*" access-log = "/home/user/logs/kannellogs/access.log" # smsbox setup group = smsbox bearerbox-host = localhost sen

objective c - Display PDF downloaded from URL according to individual pages -

in application have requirement displaying pdf according pages.only single page @ time next & previous buttons @ bottom.on clicking "next" load next page , on... i know working uiwebview can display pdf, whole pdf document displayed @ time.just need display single page each time nsurl* url = [nsurl urlwithstring:@"http://exmonthly.pdf"]; nsurlrequest* request = [nsurlrequest requestwithurl:url]; wbview.scalespagetofit=yes; [wbview loadrequest:request]; [self.view addsubview:wbview]; this code displays available pages of pdf.how can individual pages any ideas/help thankful apple have qlpreviewcontroller, there whole pfd if i'm not mistaken. can save pdf, next split pdf single pages ( for ios see answer ), make custom uiviewcontroller uiwebview , 2 buttons next & prev. next reload uiwebview read each individual page. something this: - (void)savepdfdatalocally { nsdata *datapdf = [nsdata datawithcontentsofurl:[nsurl urlwithstri

python 2.7 - compare two numpy arrays by first column in sorted order and create new array -

i have 2 numpy arrays , b. want compare 2 numpy array column 0 contains time series data.i want create new numpy array sorted time series in column 0 , associated values time. , if no values found insert null data. example = np.array([[0.002, 0.998], [0.004, 0.997], [0.006, 0.996], [0.008, 0.995], [0.010, 0.993]]) b = np.array([[0.002, 0.666], [0.004, 0.665], [0.0041, 0.664], [0.0041,0.663], [0.0042, 0.664], [0.0043, 0.664], [0.0044, 0.663], [0.0045, 0.663], [0.005, 0.663], [0.006, 0.663], [0.0061, 0.662], [0.008, 0.661]]) expected ouput c= [[0.002, 0.998, 0.666], [0.004, 0.997, 0.665], [0.0041, null, 0.664], [0.0041, null ,0.663],

php - The Doctrine repository "Doctrine\ORM\EntityRepository" must implement Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface -

i'm receiving error the doctrine repository "doctrine\orm\entityrepository" must implement symfony\bridge\doctrine\security\user\userloaderinterface. this done following symfony own login , databases , doctrine examples, thought customization. customer.php: ` // src/appbundle/entity/customer.php namespace appbundle\entity; use doctrine\orm\mapping orm; use symfony\component\security\core\user\userinterface; use symfony\component\security\core\user\advanceduserinterface; /** * @orm\entity(repositoryclass="appbundle\entity\customerrepository") */ class customer implements advanceduserinterface, \serializable { /** * @var integer */ private $id; /** * @var string */ private $customer_firstname; /** * @var string */ private $customer_lastname; /** * @var string */ private $customer_email; /** * @var string */ private $customer_password; /** * @var string */ private $customer_salt; /** * @var string */ private $custome

javascript - Easy filter from HTML divisions with jQuery -

i'm trying change background-color css property of item matches input criteria given: my html: <!doctype html> <html> <meta charset="utf-8"> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <link rel="stylesheet" type="text/css" href="plantilla.css"> <script src="plantilla.js"></script> <head> <title>plantilla</title> </head> <body> <input type="text" id="input" class="input" value="" /> <div id="main" class="main"> <div id="header">main</div> <div id="global1" class="global">

javascript - SVG gets cropped -

so got svg , i'm having couple problems related fact instead of being resized fit container, svg image gets cropped out instead. html: <!doctype html> <html> <head> <title>eye</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="js/snap.svg.js"></script> <script src="js/eye.js"></script> </head> <body> <svg id="svg"></svg> </body> </html> js: window.onload = function() { var s = snap("#svg"); var circle = s.circle(90,120,80); var square = s.rect(210,40,160,160); var ellipse = s.ellipse(460,120,50,80); } jsfiddle now, css code surely isn't cropped anymore since user agent stylesheet on google chrome contains "overflow:hidden" regarding svgs. right way resolve matter? also, why cr

mysql - how do i reinsert a deleted record with auto incremented id in hibernate java -

contact contact7 = new contact(7,"jobs", "jobsatapplet.com", "coffeebeans", "0123456789"); contact7.setid(7); //session.update(contact7); contact contact8 = (contact)session.load(contact.class, new integer(7)); contact8 = new contact(7,"jobs", "javaatapplet.com", "cupertino", "0123456789"); session.save(contact7); // commits transaction , closes session session.gettransaction().commit(); session.close(); this code, instead of reinserting record 7 inserts new record increments number of records duplicate values. i not sure trying do, if update existing record, can this: contact c = (contact)session.load(contact.class, new integer(7)); c.setlocation("cupertino"); session.gettransaction().commit(); session.close(); this is, if contact class has setlocation() method. without mapping , class files can't more precise.

java - Catching UnknownHostException which is the cause of an exception -

in program of interest, during execution of method() http related exceptions can occur. due something, method set able throw expexception. interest in specific type of exception, i.e. unknownhostexception, can accessed using if (e.getcause().getcause().getcause() instanceof unknownhostexception) which hope agree nasty way. thus, works fine: public class exportexception extends exception; class sth{ method() throws expexception; } class main{ try{ method() } catch(expexceptione e){ if (e.getcause().getcause().getcause() instanceof unknownhostexception){ dosthelse(); } } however, hoping described below. unfortunately, eclipse yells unreachable catch block unknownhostexception. exception never thrown try statement. is there me? don't want use getcause()^3. an addition: big big project , i'm new newbie , rather not mess outside classes, "main". my program like: public class exportexception extends exception; class

stored procedures - Inserting into Table from Oracle View -

i have view dynamically returns values different tables. needed insert or delete table view, whenever view adds or decreases data. should using stored procedure or that as @michaelbroughton stated, view not physically store data , view has no "knowledge" when base data changes. i suggest think creating triggers on base tables , let these triggers handle updates of target table. if applicable in context, can of course have several triggers executing same stored procedure data propagation done. a matrialized view can solution, too, since can create trigger on view, @ cost of storing data view provides.

multithreading - How can these sync methods be effectively unit tested? -

based on answers this question , feel happy simplicity , ease of use of following 2 methods synchronization: func synchronized(lock: anyobject, closure: () -> void) { objc_sync_enter(lock) closure() objc_sync_exit(lock) } func synchronized<t>(lock: anyobject, closure: () -> t) -> t { objc_sync_enter(lock) defer { objc_sync_exit(lock) } return closure() } but sure they're doing want, want wrap these in piles of unit tests. how can write unit tests test these methods (and show synchronizing code)? ideally, i'd these unit tests simple , clear possible. presumably, test should code that, if run outside synchronization block, give 1 set of results, give entirely separate set of results inside these synchronized blocks. here runnable xctest verifies synchronization. if synchronize delayedaddtoarray, work, otherwise fail. class delayedarray:nsobject { func synchronized(lock: anyobject, closure: () -> void) {

Getting MethodNotAllowedHttpException in RouteCollection.php line 219: on laravel -

im getting errors above. tried read on other forums same problem no luck. create, store , edit working. when updating form im getting error above. can me on this. thanks {!! form::model($enrollment['method'=>'post','route'=>['/enrollment',$enrollment->id],'class'=>'form-horizontal']) !!} <div class="form-group"> <label for="subject_code" class="col-md-3 control-label">subject code</label> <div class="col-md-8"> <select class="form-control" name="_method" value="put" id="subject_code"> <option value="{{ $enrollment->subject_code }}">{{ $enrollment->subject_code }}</option> @foreach($subjects $subject) <option value=&q

Bootstrap CSS file cannot be loaded into chrome locally -

when running html code on chrome , firefox ,the bootstrap file(local) not loaded .but when run in ie working fine. <!doctype html> <html lang="en"> <head> <link rel="stylesheet" href="scripts/bootstrap-3.3.6/dist/css/bootstrap.min.css"> </head> <body> <nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="#">websitename</a> </div> <div> <ul class="nav navbar-nav"> <li class="active"><a href="#">home</a></li> <li><a href="#">page 1</a></li> <li><a href="#">page 2</a></li> <li><a href="#">page 3</a></li> </ul> </div>

d3.js - Get group from D3js selectAll in console? -

in context of understanding better details of d3.js, bit puzzled how selectall works. for example, based on codepen , possible write: vis.selectall("circle.nodes") or: vis.selectall("my_own_tag_group") but after d3js code executed, expect selectall gives group access web console too: document.getelementsbyclassname('my_own_tag_group') htmlcollection [ ] (empty) what missing explanations given in http://bost.ocks.org/mike/selection/ at least code, looks you're doing selection wrong. selectall follows css3 selector rules : d3 uses css3 select elements. example, can select tag ("div"), class (".awesome"), unique identifier ("#foo"), attribute ("[color=red]"), or containment ("parent child"). selectors can intersected (".this.that" logical and) or unioned (".this, .that" logical or). if browser doesn't support selectors natively, can include sizzle b

activerecord - How to query nested associations in rails -

my models campaign.rb has_many: views_logs user.rb has_many :views_logs views_log.rb belongs_to :campaign belongs_to :user i want campaign.first.views_logs.uniq.users.genders know query wrong want this you need define direct relationship through parameter: class modelname has_many :views_logs has_many :users through: :views_logs end then can query this: model_name.user.where(gender: 'male')

ruby - XML:Mapping and object to table -

my task make xml mapping xml:mapping in ruby , save object database. here class: class offer < activerecord::base include xml::mapping text_node :offer_id , "@id" array_node :pictures, "picture", :class => picture text_node :scu, "vendorcode" end binding works fine irb(main):003:0> o = offer.new => #<offer id: nil, offer_id: nil, scu: nil, created_at: nil, updated_at: nil> irb(main):004:0> o= offer.load_from_file("c:\\simple.xml") => #<offer id: nil, offer_id: nil, scu: nil, created_at: nil, updated_at: nil> hash empty , not good. but: irb(main):005:0> o.scu => "52.61.037" o.save makes blank row in database because of empty hash. how can save xml-mapping object database?

info.plist - iOS plist.info: where should I put additional keys with a nested dict tag? -

in nativescript app (compiles native including plist.info file) i'm trying add key plist.info solve ios 9 transport security issues. the solution i'm trying apply comes https://blog.nraboy.com/2015/12/fix-ios-9-app-transport-security-issues-in-nativescript/ specifically it's adding following key plist.info file: <key>nsapptransportsecurity</key> <dict> <key>nsallowsarbitraryloads</key> <true /> </dict> however during building process following error: code-info.plist': data couldn’t read because isn’t in correct format. since i'm new ios development guess due syntax error in xml file (specifically where put code above : before closing plist tag or whatever) my original plist file (build works) is: <?xml version="1.0" encoding="utf-8"?> <!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd">