Posts

Showing posts from June, 2014

playframework - Forwarding in Play for Scala returns empty response -

Image
the http forward below ( futureresponse function) returns empty response browser. ideas wrong and/or should at? val request: wsrequest = ws.url("http://somehost/url2") val request2: wsrequest = request.withheaders("accept" -> "application/json") val data = json.obj( "aaa" -> some_data1, "bbb" -> some_data2 ) val futureresponse: future[jsvalue] = request2.post(data).map { response => val json= json.obj( "ccc" -> "111", "ddd" -> "222" ) json } ok(json) when message in browser, data in response empty: make action asynchronous , reply future[result], like: def someaction = action.async { implicit request => val request: wsrequest = ws.url("http://somehost/url2") val request2: wsrequest = request.withheaders("accept" -> "application/...

r - Take the difference based on ID -

i have df 212 rows in form of: id visit treatment value1 value2 value3 1 v0 2.6 3.4 .1 1 v1 2.3 4.6 .5 2 v0 b 1.3 5.4 .6 3 v0 1.6 5.4 .7 2 v1 b 1.8 4.5 .3 3 v1 1.3 7.3 1.2 so o have column id, 1 visit week , treatment , bunch of columns values. want take difference each id, treatment same each id, never change week 0 , 1. id don't comes in order. possible? it like: id visit treatment value1 value2 value3 1 v0-v1 0.3 -1.2 -.4 and on. here's data.table solution: dt[by=.(id,treatment),j={ z <- nrow(.sd); c( .(visit=paste0(visit[1l],'-',visit[z])), lapply(mget(grep(value=t,'^value',names(.sd))),function(x) x[1l]-x[z]) ); }]; ## id treatment visit value1 value2 value3 ## 1: 1 v0-v1 0.3 -1.2 -0.4 ## 2: 2 b v0-v1 -0.5 0.9 0.3 ## 3: 3 ...

forms - Microsoft Access Send email to Client and get Email address from database -

gday all, i'm trying send report microsoft access client. so have client table client details including email address etc.. and in form using button linked macro creates report , sends via email using "emaildatabaseobject" way cannot select email address list in clients section have type 1 in macro builder or leave blank , prompted it. is there anyway have select query linked "to" section of emaildatabaseobject? or there way should trying this? have @ this: public sub cmdterms_click() dim objoutlook new outlook.application dim objmail mailitem dim knownas string dim eml string dim text string dim pathname string dim pathname2 string dim quest integer dim rs dao.recordset docmd.transfertext acexportmerge, "", "qryterms", conaddrpth & "\datasource.txt", true, "", 1252 me.docname = conaddrpth & "\dbs service agreement.docm" openworddoc knownas = dlookup("fname", ...

ruby on rails 4 - Facing error sorry we cannot connect to PayPal in spree -

Image
i have ecommerce-application in had integrated paypal braintree using gem 'spree_braintree_vzero', github: 'spree-contrib/spree_braintree_vzero', branch: ‘3-1-stable’ have paypal sandbox account , included credentials in application. now when go checkout page < select paypal option < continue payment following error : please me out solve issue. in advance. since has been answered on github, i'm linking issue. https://github.com/spree-contrib/spree_braintree_vzero/issues/58 edit sum up, caused 1 of 2 things: 1. address verification, try 1 valid example: john doe 123 billing street apt. #1 chicago united states of america illinois 60618 555666555 2. braintree sandbox account has not been set process paypal (this can happen when account created outside u.s.). you can verify paypal valid payment method in sandbox clicking on settings > processing . you’ll see list of accepted payment methods next merchant account ( paypal integrati...

php - how to check duplicate value in form before insert into database -

i check duplicate data when insert duplicate in textbox display duplicate , tried insert not duplicate display "trying property of non-object" controller public function gamecheck(){ $this->load->library('form_validation'); // load validation $this->form_validation->set_rules('gamename', 'checkgamename', 'required'); if ($this->form_validation->run() == true) { if($this->input->post()) { $this->load->model('game_m'); $gamepost = $this->input->post('gamename'); $getgame = $this->game_m->get_game($gamepost); if($getgame->gamename!==''){ echo "duplicate"; }else{ echo "not duplicate"; } } } $this->load->view('header'); $this->load->view('menu'); $this->load->view('game/gamecheck');...

haskell - Expressing sum of money in terms of changes -

i have been studying haskell week , trying write real world functions myself. aim expressing sum of money in terms of respective coins , amount of said coins. not sure if thinking "functionally" when write functions. example code below; changes = [1,2,5,10,25,50] makechanges n cs = if n `div` (last cs) > 0 (coin_amount, last cs) : makechanges (n - coin_amount * current_coin ) (init cs) else makechanges n (init cs) coin_amount = n `div` (last cs) current_coin = last cs example output makechanges 126 changes [(50,2),(25,1),(1,1)] is there more fp way write intended function? feel function conversion of imperative function, in advance. a left fold solution be: change :: (foldable t, integral a) => -> t -> [(a, a)] change total coin = foldl go (const []) coin total go run c x = if x < c run x else (c, x `div` c): run (x `mod` c) then: \> chan...

html - show full page overlay while sub navigation is opened using css -

i wanted show overlay while sub menu opened using css, have tried below thing, it's doing trick not able nav links since overlay on top. .header .navbar .nav .nav-item div.big-menu { position: absolute; display: block; opacity: 0; width: 100%; max-height: 450px; top: 80px; left: 0; z-index: 399; visibility: hidden; overflow: hidden; background: #ffffff; color: #181717; -webkit-transition: 0.3s ease 0.15s; transition: 0.3s ease 0.15s; } .header .navbar .nav .nav-item div.big-menu .big-menu-body { position: relative; overflow: hidden; background-color: white } .header .navbar .nav .nav-item:hover > div { opacity: 1; visibility: visible; overflow: visible; } /* used :after apply overlay */ .header .navbar .nav .nav-item:hover > div:before { content: ''; position: fixed; z-index: auto; width: 100%; height: 100%; top: 0; left: 0; background-color: rgba(0, 0, 0, 0.6); ...

javascript - I want to build a minimap for my HTML5 game, how do I start? -

Image
assume have big map uses background image pattern. want place minimap @ corner when moving player around. need minimap display player in big map , other sprites in map, using coarse representation , keeping relative location shows in smaller map. think basic , simple minimap. player in middle of screen (i have done that) , minimap stay @ corner of screen. if want build such feature game, how start? assuming main map in container element, need measure scroll property of element establish @ position relative center of container (or screen). if calculate x , y proportion (eg %) of map, can place on mini map @ same relative position. the placing of mini map on main map of no importance. to position of map relative screen, try document.getelementbyid("map").getboundingclientrect() . x , y values in resulting array tell position of top left of map top left of screen. width , height of map included in array. add screen.width/2 , screen height/2 coordinates of ma...

delphi - How do I work with an array of type (TList, class) with Delphi7 -

i have old programm variable: modul : array[1..4] of array[0..5] of array[1..3] of tmodul; i can store modules in list: procedure test; var list: tlist; pmodul: pointer; begin pmodul := addr(modul); list:= tlist.create; list.add(pmodul); //... list.free; end; but how can read element list ? := modul[x,y,z].measvalue.value[i]; from list? and how can pass modul function/procedure this: ttest=class(tobject) private fmodul: tmodul; function getmodul: tmodul; procedure setmodul(const value: tmodul); // isnt't work public property modul: tmodul read getmodul write setmodul; end; so can work modul , tobjectlist? thanks in advance. i found following solution: http://docs.embarcadero.com/products/rad_studio/delphiandcpp2009/helpupdate2/en/html/delphivclwin32/classes_tlist_add.html

Disqus and iOS integration - UIImagePickerController -

Image
i'm trying integrate disqus ios app. i'm following written guide written guys @ disqus here https://help.disqus.com/customer/portal/articles/472096 i'm using uiwebview show hosted html page, loads disqus comments working fine. am able view comments , add comment seen here. now select add image option , menu here. now when select 'photo library' , view controller dismisses , throws warning in console warning: attempt present uiimagepickercontroller: 0x7faebb247a00 on uinavigationcontroller: 0x7faebb179400 view not in window hierarchy! basically comments view (as seen in screenshot) shown modally view controller shown modally. i wondering if cannot show multiple view controllers modally , disqus imagepicker trying present on top of 2 modally presented view controllers. issue? any pointers appreciated. thanks, kamyfc okay fixed this. i avoided showing view controllers modally , can select images.

Swift 2 Using Predicate can't get any result on my filter -

what doing wrong ? import uikit var values:nsmutablearray = [] let url = nsurl(string: "url") // php json result let data = nsdata(contentsofurl: url!) values = try! nsjsonserialization.jsonobjectwithdata(data!, options: nsjsonreadingoptions.mutablecontainers) as! nsmutablearray var searchtext = "royal" let resultpredicate = nspredicate(format: "self contains[cd] %@", searchtext) let filteredcars = values.filteredarrayusingpredicate(resultpredicate) change code this let resultpredicate = nspredicate(format: "self.vendor contains[cd] %@ or self.vendor contains[cd] %@ or self.email contains[cd] %@", searchtext, searchtext, searchtext) let filteredcars = values.filteredarrayusingpredicate(resultpredicate) you need add key in want filter text. hope you.

typescript - angularjs $watch watchExpression with promise is going into infinite digest loop -

angularjs watch method watchexpression returning promise. $scope.$watch(function() { var promise = myservice.getmethod(); promise.then(function(value){ return value; }) }, function(newvalue, oldvalue) { console.log("new value:", newvalue); }); typescript call method promise. public getmethod(): angular.ipromise<any> { var deferred: angular.ideferred<any> = this.$q.defer(); localforage.getitem(‘key’).then(function(value) { deferred.resolve(value); }).catch(function(err) { deferred.reject(); console.log(err); }); return deferred.promise; } i want return "value" localforage promise in myservice return $watch watchexpression function. you can use localforage.bind directly bind storage value scope: localforage.bind($scope, {key: 'key', scopekey: 'sckey'}); and use two-way binded $scope.sckey .

Sql remove milliseconds and Date Conversion -

please 1 suggest me getting right results? i have date field results in "2016-07-08 10:09:22.910" format , wish remove milliseconds , same time wish convert field in "08/07/2016 10:09:22" i managed remove milliseconds using convert(varchar, [datefilecreated], 20) unable convert in desired format. please suggest in sql server ,you can use format available sql server 2012 select format ( getdate(), 'yyyy-mm-dd hh:mm:ss' ) output: 2016-07-11 07:13:33

java - What is Object/Relational mismatch -

i newbie java , reading object relational mapping. found term object/relational mismatch on link hibernate can explain object/relational mismatch in terms of java. read haacked.com not properly.explanation example appreciable. hibernate orm (object relational mapping) tool. it's primary purpose translate concepts object oriented programming, such classes, inheritance , fields, concepts used in relational databases, such tables, rows , columns. for example, class corresponds database table, object (instance of class) corresponds database row, , field corresponds database column. the term "object/relational mismatch" refers fact there not clear way translate concepts object-oriented programming relational database concepts , vice versa. hibernate attempts solve problem. for example, how translate inheritance relational database concepts? there's no such thing inheritance in relational database, way has invented represent in database. hibernate has ...

android - Can't retrieve data from a Firebase's node -

Image
i'm developing android app , i'm using firebase database. want specific node i'm failing retrieve these data. i've written firebase's security rules , data structure: this android code: public void connect() { //setting connexion parameter final firebase ref = new firebase("https://test.firebaseio.com/test"); query query = ref.orderbychild("longitude").equalto("150"); //get data th db query.addlistenerforsinglevalueevent(new valueeventlistener() { @override public void ondatachange(datasnapshot datasnapshot) { //checking if user exist if(datasnapshot.exists()) (datasnapshot usersnapshot : datasnapshot.getchildren()) { //get each user has target username final location location = usersnapshot.getvalue(location.class); //if password true , data storaged in sharedpreferences file , home ac...

openerp - Odoo inheritance issue -

i have develop module odoo 8. when tried deploy got error: traceback (most recent call last): file "/opt/odoo/openerp/http.py", line 539, in _handle_exception return super(jsonrequest, self)._handle_exception(exception) file "/opt/odoo/openerp/http.py", line 576, in dispatch result = self._call_function(**self.params) file "/opt/odoo/openerp/http.py", line 312, in _call_function return checked_call(self.db, *args, **kwargs) file "/opt/odoo/openerp/service/model.py", line 118, in wrapper return f(dbname, *args, **kwargs) file "/opt/odoo/openerp/http.py", line 309, in checked_call return self.endpoint(*a, **kw) file "/opt/odoo/openerp/http.py", line 805, in __call__ return self.method(*args, **kw) file "/opt/odoo/openerp/http.py", line 405, in response_wrap response = f(*args, **kw) file "/opt/odoo/addons/web/controllers/main.py", line 948, in call_button ...

c# - How do I delete selected item from a combo box in the text file -

so list in combobox comes text file. program allows user choose 1 item combobox. selected item should removed combobox , text file clicking button. this code allows program items text file combobox: string location = @"c:\\users\\lmcpena98\\desktop\\coe114lproject_millennium_paws\\millenniumpaws\\millenniumpaws\\bin\\debug\\files.txt"; string[] temp = file.readalllines(location); int[] tagnumber = new int[temp.length]; string[] breed = new string[temp.length]; string[] name = new string[temp.length]; decimal[] price = new decimal[temp.length]; //getting values text file (int = 0; < tagnumber.length; i++) { tagnumber[i] = int.parse(temp[i].substring(0, temp[i].indexof("-"))); breed[i] = temp[i].substring(0, temp[i].indexof("+")); breed[i] = breed[i].substring(breed[i].lastindexof("-") + 1); name[i] = temp[i].substring(0, temp[i].indexof("=")); name[i] = name[i].substring(name[i].lastindexof("+") + 1); price[i] = deci...

java - Android (NDK) openSoftInput in landscape mode -

Image
i'm porting framework android ndk. , have use on screen keyboard once in while. opening , closing keyboard works far.. but have problem focus of keyboard in landscape mode (portrait mode works fine) - part of screen colored red still reacting on touch input if there no keyboard on it, 1 uncolored row of keyboard works expected , greenish part on keyboard not receive touch input. i have tested usual android app well. same result (code see @ end of question). i'm opening keyboard when klicking on "press me!" button , close softkey. code called open/close: //adapted https://groups.google.com/d/msg/android-ndk/tk3g00wlkhk/tjqucoae_asj void androidcore::openonscreenkeyboard(bool open){ // attaches current thread jvm. jint lresult; jint lflags = 0; javavm* javavm = view->native_activity->vm; jnienv* jnienv; bool attached = false; if(javavm->getenv((void**)&jnienv, jni_version_1_6) ==jni_edetached){ javavmat...

ios - Recurring local notifications using NSTimer don't work -

the user can select between couple of minute intervals in slider (3, 5, 8, 10 etc.). since, not possible set recurring local notifications on custom time (only once in sec, minute, hour, day...). i have created timer creates new local notification @ chosen time. weird thing here works on physical iphone 6 , iphone 5 simulator. not on physical iphone 5, running ios 9.3.2. below code starts timer, number integer value fetched slider (3, 5, 8...): @ibaction func savesettings(sender: anyobject) { var timer = nstimer.scheduledtimerwithtimeinterval(double(number*60), target: self, selector: selector("sendnotification"), userinfo: nil, repeats: true) print("notification interval set \(number)") } func sendnotification() { let localnotification = uilocalnotification() localnotification.firedate = nsdate(timeintervalsincenow: double(number)) localnotification.alertbody = "this test body." localnotification.timezone = nstimezone....

sql - How can I select a row having a BigInt and a DateTime field starting with a specigic value? -

i working on microsoft sql server database , have following problem implement these 2 simple select query. so have table named mytable has column otherfieldfk of type bigint value of 70016592107 . so example want search record in table have otherfieldfk starting value 70 . i tried use like in way: select * mytable otherfieldfk = '70%' but doesn't work. think clause works on string, right? in table have datetime column named datainiziogestione . i tried same thing: select * datainiziogestione otherfieldfk = '2016%' but in case doesn't work either. how can correctly implement these 2 queries? the first should right, wrote: select * mytable otherfieldfk = '70%' for second should converted date format in nvarchar (es 121 format aaaa-mm-gg hh:mi:ss.mmm(24h)); in way can make comparison like: select * mytable convert(nvarchar,datainiziogestione,121) = '2016%' or can directly compare year: select * myt...

sql server - which kind of record this like will get? -

like ',%,%,' i using above in case statement record. it's not working expected. my query - select case when row_id ',%,%,' 'a' when row_id not ',%,%,' '' end 'af' myview row_id = '2464,2465,2466' order 1 desc expected output - getting blank. this like: row_id ',%,%,' will match every single row_id starts , ends comma , has @ least comma in between. your query, because of clause where row_id = '2464,2465,2466' will return empty set because row_id doesn't match previous pattern.

angular - svg circle for angular2 -

i need progress arc based on calculated percentage, have created custom directive access svg attributes user, while updating in template, getting following error: "can't bind 'cx' since isn't known native property ", "can't bind 'cy' since isn't known native property " etc.. i getting above error svg attributes. below code in jade: progress-arc([size]="200", [strokewidth]="20", [stroke]="red", [complete]="0.8") below directive code: import {component,input,afterviewinit} '@angular/core'; @component({ selector:'progress-arc', template:` <svg height="100" width="100"> <circle fill="white" cx="{{parsedsize/2}}" cy="{{parsedsize/2}}" r="{{radius}}" stroke="{{stroke}}" stroke-width="{{strokewidthcapped}}" s...

angularjs - How to save base64 images into device using Cordova application? -

how save base64 images device gallery using cordova application.i getting base64 text response. you can find here http://ionicframework.com/docs/v2/native/base64-to%20gallery/ http://ourcodeworld.com/articles/read/80/how-to-convert-a-image-from-the-device-to-base64-with-javascript-in-cordova https://cordovablogsblogs.wordpress.com/2015/05/29/phonegap-plugin-to-convert-base64-string-to-a-png-image-in-android/ reference code here window.requestfilesystem(localfilesystem.persistent, 0, function (filesystem) { var filetransfer = new filetransfer(); var uri = encodeuri("http://www.example.com/image"); var path = filesystem.root.tourl() + "appname/example.jpg"; filetransfer.download( uri, path, function(entry) { refreshmedia.refresh(path); // refresh image gallery }, function(error) { console.log(error.source); console.log(error.target); console.log(error.code); }, false, { header...

android - Handling app updates (AlarmManager) -

i developing app connects , modifies data in database executing php files. if need make changes database or php files, may cause old versions of app behave unexpectedly , crash. reason, want force users update app when such changes made. right now, have method connects database , compares apps version databases version. works fine call every time access database (very often) slows down usage of app. there better way this? have read use alarmmanager or broadcastreceiver check updates every x amount of hours. if user closes , doesn't use app few days. these timers called user starts app , able force update? the android alarmmanager api let communicate , program alarm android alarm service. think of similar linux cron job. alarm programmed, it'll triggered if app isn't running, because alarm triggered alarm service , not app. instance, thing need program alarm. it's important note when restart device alarms cleared, need reprogram in every reboot. can ...

xcode - stringByReplacingOccurencesOfString() for Swift 3.0 -

i'm having problem when using stringbyreplacingoccurencesofstring() latest version of xcode 8.2 beta. when using function, xcode showing value type of string has no member. var clockworksmsurl = "https://api.clockworksms.com/http/send.aspx?" + "key=123456789abcd" + "to=" + usersnumber! + "&content=" + userstextmessage! clockworksmsurl.stringbyreplacingoccurrencesofstring(" ", withstring: "+") var clockworksmsurlconvert = nsurl(string: clockworksmsurl) any ideas? you can fix snippet using ... clockworksmsurl.replacingoccurrences(of: " ", with: "+") swift 3 changed way how objc apis imported. please note there issues code posted: the result of replacingoccurrences discarded. there more characters escaped. urlcompontents exposes safer ways construct urls. ...

.net - Set a variable to a module -

in project, have several modules, same set of subs. each module use different brand of rfid card reader, access methods , reader output different, exact same steps followed. in application want make generic calls these steps, have application setting determines module call from, prevent having change of calls project project. want like: public card_reader_module modmti 'which doesn't work then card_reader_module.connect() ... etc or there better way this? for design have described should use interface describe methods want use , implement interface in new class each type of device. so example interface looks this: public interface idevice sub connect() end interface then create class each device has specific implementation each device in here: public class devicetype1 implements idevice public sub connect() implements idevice.connect 'connect type of device here end sub end class the beauty of design can define va...

Test cases getting skipped with Selenium WebDriver using TestNG framework -

i using selenium webdriver testng framework running test suite on windows , mac platform on different browsers - chrome, ie, firefox , safari . have around 300 test cases in test suite. the problem of test cases gets skipped in between believe driver becomes unresponsive. logs failed capture details why test cases getting skipped. the reporter class extends testlisteneradapter , hence skipped test cases gets listed in log file use of onconfigurationskip method. prints particular test case has been skipped. below code snippets reference code reporter class @override public void onconfigurationskip(itestresult testresult) { logger.info(string.format("skipped configuration : %s", testresult.getmethod().getmethodname())); } sample test class public class testclass { private webdriver driver; @parameters({ "platform", "browser"}) @beforeclass public void setup(string platform, string browser) { // creates new driver instance ba...

php - How to add browser file or image button in Tinymce -

i have written below code in php file. got image option upload image need add url tinymce.init({ // general options mode : "exact", elements : "descp", theme : "advanced", plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount", // theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect", theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backco...

ios - How to call API in background thread? -

i using alamofire api calling in app. now want call api in background thread when api called, other functionality work propely. how can in alamofire? this how calling api func getdesignationlist(pharmacyid : string,completion:(managedesignation : managedesignationlistmodel)-> void) { let url = "\(vendorurl)all_employee_designation_list" let param : [string : anyobject] = [ "pharmacyid" : pharmacyid ] alamofire.request(.get, url, parameters: param, encoding: .url).responseobject { (response:response<managedesignationlistmodel, nserror>) in switch response.result { case.success(let value) : var managedesignationobject : managedesignationlistmodel? managedesignationobject = value completion(managedesignation: managedesignationobject!) case.failure(let error) : break } } } you doing right already. alamofire calls web services in background threads. if want test works asynchronlusly, can add...

javascript - set zoom in google map -

i creating project using javascript. in project have integrated google map.the google map works successfully. problem when set zoom level below 2 gives me error.i want set zoom level below 2. here code: <script src="https://maps.googleapis.com/maps/api/js?key=aizasydspoae1uhgq8hxk9mox3sazdedj5lslps&libraries=geometry,drawing"></script> var mapoptions = { zoom: 1.5, minzoom: 1.5, disabledefaultui: true, maptypecontrol: false, scrollwheel: false, navigationcontrol: false, maptypecontrol: false, scalecontrol: false, draggable: false, maptypeid: google.maps.maptypeid.hybrid, maptypecontroloptions: { style: google.maps.maptypecontrolstyle.horizontal_bar, position: google.maps.controlposition.top_center, }, disabledoubleclickzoom: true, center: new google.maps.lat...

sql - missing rows, how to select values -

how accomplish this: have bunch of numbers (for example: 2342423; 34443123; 3523423) , of them in database table primary key value. want select numbers, not in table. best way this? if few numbers can do select tmp.num ( select 2342423 num union select 34443123 union select 3523423 ) tmp left join your_table t on t.id = tmp.num t.id null if more few numbers should insert these table , left join against table this select twntc.num table_with_numbers_to_check twntc left join your_table t on t.id = twntc.num t.id null

Linux - Shell script run curl command in parallel -

i create linux shell script run curl command in parallel for example: have 3 command curl -s http://localhost/process.php?id=1 curl -s http://localhost/process.php?id=2 curl -s http://localhost/process.php?id=3 i want call above 3 command simultaneously. any appreciated. i think bash script like: #!/bin/bash curl -s http://localhost/process.php?id=1 & curl -s http://localhost/process.php?id=2 & curl -s http://localhost/process.php?id=3 & however, starting tasks background processes. don't know how crucial simultaneous starting of process is.

c - is this the right way to initialize a semaphore with two threads -

i new using concept of semaphores. trying integrate sender , receiver single project such if run project both sender , receiver exchange data simultaneously. below tried eclipse cdt ide showing an **error: ‘receiver’ undeclared (first use in function) pthread_create(mythread2, null, (void*)receiver, null);** any appreciated. sem_t semaphore; void sender() { while (1) { sem_wait( & semaphore); printf("hello sender!\n"); sleep(1); /* not run fast! */ /* write number of messages, re-using existing string-buffer: no leak!!. */ (i = 1; <= num_msg; i++) { msg - > index = i; snprintf(msg - > content, max_msg_len, "message no. %d", msg - > index); printf("writing message: %s\n", msg - > content); status = chat_chatmessagedatawriter_write(talker, msg, userhandle); checkstatus(status, "chat_chatmessagedatawriter_write"); ...

javascript - How can I check DNSSEC compliance with nodejs? -

i'm building web analytics tools, i'm having difficulty checking dnssec compliance in nodejs application. none of dnssec record types seem accepted dns module in standard library. i'm attempting rrsig , ds , nsec , nsec3 docs not list them valid rrtypes resolve. possible nodejs? unless you're planning on implementing dnssec validation in javascript (good luck that!) you're going dependent on external validator indicate valid, invalid, or insecure (dnssec not configured). largest dnssec validator in world in google public dns (better known 8.8.8.8), , conveniently have added https-based api should pretty easy use node.js code (the api responses json). you can check successful resolution , without &cd=1 parameter disable dnssec validation: servfail ("status": 2) both queries bad delegation servfail without &cd=1 invalid dnssec configuration success ("status": 0) no authenticated data ("ad": false) non-dnss...

java - Write j-text utils table to file -

Image
i working on project handles orders customers. i using util display data table: j-text utils . know if possible write table how printed file? this display table this old question. others. have use texttable tt = new texttable(columnnames, data); tt.printtable(outputfile, 0); where outputfile object of printstream

java - No mapping found for HTTP request with URI in DispatcherServlet, with Thymeleaf and Spring 4 -

i want integrate spring 4 thymeleaf, got warning [http-apr-8080-exec-4] org.springframework.web.servlet.pagenotfound.nohandlerfound no mapping found http request uri [/hire-platform/] in dispatcherservlet name 'mvc-dispatcher' and content of /web-inf/templates/index.html not displayed. here mvc-dispatcher-servlet-xml : <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" > <bean id="viewresolver" class="org.thymeleaf.spring4.view.thymeleafviewresolver" p:templateengine-ref="templateengine" p:characterencoding="utf-8" > </bean> <bean id=...

angular - CanActivate is giving error after switching to r.c.3 -

i using canactivate in angular2 app this @canactivate(() => isvaliduser()) it working fine until switched r.c.3 , started giving me error. please suggest me recent changes regarding property. you create auth.guard.ts in app folder: app/auth.guard.ts: import { canactivate } '@angular/router'; export class authguard implements canactivate { canactivate() { console.log('authguard#canactivate called'); return true; } } then in routes.ts: { path: 'admin', component: yourcomponent, canactivate: [authguard] }, if don't have routes.ts, need create one, see reference here: https://angular.io/docs/ts/latest/guide/router.html

Chaining Multiple IF Statements in Excel to Calculate Work Shifts from Times -

Image
i trying calculate work shift based on time entered in excel worksheet. shift allocation below: if time >= 05:30 pm & <= 01:30 - 1st shift if time >= 01:30 & <= 09:30 - 2nd shift if time >= 09:30 & <= 01:30 - 3rd shift i using if , conditions still it's showing incorrect results. below formula using. =if(and(d2>=timevalue("05:30:00 pm"),(d2<=timevalue("01:30:00 am"))),"1", if(and(d2>=timevalue("01:30:00 am"),(d2<=timevalue("09:30:00 am"))),"2","3")) any idea doing wrong? the first problem in shift definitions. time 1:30 am falls in 3 shifts due use of less-than-or-equal-to operators. these should changed less-than operators, such following: if time >= 5:30 pm & < 1:30 - 1st shift if time >= 1:30 & < 9:30 - 2nd shift if time >= 9:30 & < 5:30 pm - 3rd shift (note: corrected apparent t...

java - Jersey 1.17 download large files -

i want download large files rest service, have code: @get @path("/labodownloadanytype") @produces(mediatype.application_octet_stream) public response labodownload() throws filenotfoundexception { final string filename = "samplevideo_1280x720_50mb.mp4"; final inputstream fileinstream = new fileinputstream(filename); return response.ok(fileinstream, mediatype.application_octet_stream_type) .header("content-disposition", "attachment; filename=\"" + filename + "\"" ) //optional .build(); } and when i'm using small files works great, want download large file (from 500mb 3gb) i'm getting java.lang.outofmemoryerror: java heap space how solve problem? use mappedbytebuffer instead of inputstream , can check implementation of mappedbytebuffer here check link hope provide functionality need.

javascript - JS/CSS Combo - Getting 3D Image Wrap Effect -

i'm trying 3d wrap effect images on website. 3d wrap 1 in image the effect require in image the following pure css i'm using implement @ moment. .gallery-wrap{ background-color: rgba(0,0,0,0); -webkit-box-shadow: 0 0px 0px 0px black !important; -moz-box-shadow: 0 0px 0px 0px black !important; box-shadow: 0 0px 0px 0px black !important; } .gallery-wrap img{ transform: perspective(400px) rotatey(10deg) translatex(7.5%) translatey(30px); margin-bottom: 5em !important; background-color: rgba(0,0,0,0); -webkit-box-shadow: 0 5px 7px -1px black; -moz-box-shadow: 0 5px 7px -1px black; box-shadow: 0 5px 7px -1px black; } .gallery-wrap div:after{ content: ''; width: 5%; height: 96%; background-image: url('<url of same image wrapped>'); position: absolute; top: 0px; transform: perspective(250px) rotatey(-55deg) translatey(7px) translatex(-10px); left: 0px; background-size: 1...

javascript - Make an element lose focus in jquery -

i have button class "scrolltotop" scrolls top of page when clicked on. here's js file: $(document).ready(function(){ //check see if window top if not display button $(window).scroll(function(){ if ($(this).scrolltop() > 100) { $('.scrolltotop').fadein(); } else { $('.scrolltotop').fadeout(); } }); //click event scroll top $('.scrolltotop').click(function(){ $('html, body').animate({scrolltop : 0},800); return false; }); }); so button has :hover property: .scrolltotop:hover{ opacity: 1.0; box-shadow: 0 10px 20px rgba(0,0,0,0.25), 0 8px 8px rgba(0,0,0,0.22); -webkit-transition: 0.4s ease-in-out; -moz-transition: 0.4s ease-in-out; -o-transition: 0.4s ease-in-out; transition: 0.4s ease-in-out; } now, know :hover doesn't work in mobile devices i.e. 1) have click on button change opacity 1.0 & 2) have tap elsewhere change opacity before (let's say, 0.5). ...

listener - How to add a calculated field in the FormEvents::PRE_SUBMIT Event -

in listener need access entity when in formevents::pre_submit event. in post_set_data no problem, use $event->getdata(); . so event listening post_set_data fine code: public function postsetdata(formevent $event) { $form = $event->getform(); $day = $event->getdata(); $total = $this->daymanager->calculatetotal($day); // passing day object, yay! $form->get('total')->setdata($total); } however in method pre_submit event. i need function because on submitting, total not calculated newly submitted data. public function presubmit(formevent $event) { $form = $event->getform(); // $day = $event->getdata(); // raw array because $event->getdata(); holds old not updated day object $day = $form->getdata(); // ough! had create , call seperate function on daymanager handles raw event array $total = $this->daymanager->calculatetotalfromarray($event->getdata()); // modify event data ...

Multiple Variable Non Linear Regression OR Curve Fitting Matlab -

Image
i have set of noisy data , want fit custom equation though in matlab. next take values of coefficients , utilize them in algorithm. stuck , cant figure out why. use non linear equation a+b*log10(x1-dcos(alpha-x2)) x1,x2 , response value known. first problem coefficients of ,b, , alpha must bounded. alpha here being in degrees can vary 0 360 example.i dont know how achieve using curve fitting toolbox. i have tried other options non linear regression techniques in matlab( fitnlm,lsqcurvefit etc) proved disappointing cant have bounds on these variables. in spite of fit being quite good, coefficients way bad. so, question 1 : how fit multiple variables using curve fitting ? question 2 : if thats not possible other techiniques can use except non linear regression . many thnaks in advance ! have great day ! well if problem have set of data, variables x1 , x2 , thre result y, , want model equation: y = + b * log10(x1 - cosd(alpha - x2)) % suppose dcos = cosd, not known...