Posts

Showing posts from May, 2015

ios - Proper way to get swift dictionary item index -

i have dictionary in app written in swift var cities: [string: string] = ["":"not specified", "ny":"new york", "la":"los angeles", "sf":"san francisco"] i use dictionary build pickerview. when user selects 1 of items - city code saving device memory. when user opens app next time want pickerview show saved city. how should it? you can find index of key in dictionary higher-order functions: let desiredkey = "ny" let pos = x.enumerate().filter { (pair: (index: int, element: (string, string))) -> bool in return pair.element.0 == desiredkey }.map { (pair: (index: int, element: (string, string))) -> int in return pair.index } pos optional(int) containing position of "ny" in current iteration order of dictionary. store value of key somewhere (say, in user defaults), retrieve it, index of key-value pair using code above, , pass selectedrowincomponent: ...

php - fetch data based on another table -

i have table users , table zebra friend list. want t fetch details of friends connected particular user here code using. not working. $user_friend_pro_query= "select * users user_id in (select zebra_id zebra user_id='$uid');"; $user_friend_pro_fetch = $conn->query($user_friend_pro_query); while($friend_pro_rows = $user_friend_pro_fetch->fetch_assoc()) { $friend_id=$friend_pro_rows['user_id']; $user_avatar_thumb=$friend_pro_rows['user_avatar_thumb']; ?><li> <a href="memeber-profile.php?user_id=<?php echo $friend_id ?>"> <img src="<?php echo $user_avatar_thumb ; ?>" width="42" height="42"></a></li> please help can try change code segment (select zebra_id zebra user_id='$uid');"; to (select zebra_id zebra user_id='".$uid."')"; this escape $uid variable, mi...

c# - Blending an image together with a control's background -

Image
i'm trying blend image reduced opacity control's background. code i'm using following one: colormatrix matrix = new colormatrix(new float[][]{ new float[] {1f, 0, 0, 0, 0}, new float[] {0, 1f, 0, 0, 0}, new float[] {0, 0, 1f, 0, 0}, new float[] {0, 0, 0, opacity, 0}, //opacity in rage [0 1] new float[] {0, 0, 0, 0, 1f}}); imageattributes imageattributes = new imageattributes(); imageattributes.setcolormatrix(matrix); g.compositingmode = compositingmode.sourceover; g.compositingquality = compositingquality.highquality; //g comes background painted on it; img bitmap g.drawimage(img, new rectangle(0, 0, img.width, img.height), 0, 0, img.width, img.height, graphicsunit.pixel, imageattributes); speed performance quality has problems dark images. following 2 images background (left) , foreground(right): when using opacity of 0.9 foreground produce output on left here below. same images photoshop , 90% opacity on foreground produce more consistent ...

java - ResultSet is empty, event though the sql query is ok -

i have following stored procedure: alter procedure uspinformation3 (@typenr varchar(50), @process varchar(50), @startdate varchar(50), @enddate varchar(50)) begin try set dateformat dmy; select count(rownr) diff_ct type_number = @typenr , process = @process , full_time_stamp between @startdate , @enddate end try if execute procedure sql server, gives me wanted answer exec uspinformation3 1137328582, 427, {ts '2015-05-24 12:00:00'}, {ts ' 2015-05-24 16:00:00 '} but, when try java, result set empty. doing mistake? guess has data types using? try { class.forname("com.microsoft.sqlserver.jdbc.sqlserverdriver").newinstance(); connection conn = drivermanager.getconnection(db_connection); string partno = pn.g...

java - Why are JPA changes using an EntityManager not committed in a Spring Service when JtaTransactionManager is used? -

i need use org.springframework.transaction.jta.jtatransactionmanager transactionmanager in spring service . however, not commit change in jpa entities. know if use jpatransactionmanager works. but, need jtatransactionmanager . so, please don't recommend use jpatransactionmanager . spring service class is: package testspring.view; import javax.persistence.entitymanager; import javax.persistence.persistencecontext; import org.springframework.stereotype.service; import org.springframework.transaction.annotation.transactional; import testspring.model.regions; @service public class hellobs { @persistencecontext private entitymanager entitymanager; public hellobs() { super(); } @transactional() public void dosomething() { regions region = new regions(); region.setregionname("antarctica"); entitymanager.persist(region); } } and spring xml config is: <?xml version="1.0" encoding="ut...

javascript - Styling embedded Tumblr blog with CSS -

i've embedded tumblr blog on website using <script type="text/javascript" src="http://blogname.tumblr.com/js"></script> i've managed style body/content of posts in css #tumblr_body { font-family: 'helvetica'; color: #000000; } now want change style of each posts title make these bold i.e. tried implement div in css file #tumblr_title no effect. guys have solutions this? cheers

c# - Extend asp.net session timeout to 24 hours -

i developing asp webapplication website using webforms. have 3 4 sessions in whole application. e.g session["rate"], session["webinformation"], session["userinformation"] . problem want extend timeout of session["rate"] 24 hours approximately, doing in webconfig file not me. how can in asp.net store , expire after 5 minutes (you can modify 24 hours) session.addwithtimeout("key", "value", timespan.fromminutes(5)); get stored value session.getwithtimeout("key"); you can find source code here

python - Send data processed from one window to mainwindow in pyqt -

i using pyqt build gui, using .ui file qt designer, , convert pyuic4. i have 2 windows, 1st - mainwindow (which has label , buttons) 2nd - window numeric keypad input window. i have .py of ui file seperate , load in main program class mainwindow(qtgui.qwidget): def __init__(self, parent = none): super(mainwindow, self).__init__(parent) self.ui = ui_main() self.ui.setupui(self) # same keypad window also.. # inside keypad window class have added functions click & display events. when click button in mainwindow, num keypad window should open. (i have done successfully) the main code follows, def main(): app = qtgui.qapplication(sys.argv) home = mainwindow() #mainwindow object keypad = keypad() #keypad object home.ui.set_btn.clicked.connect(keypad.show) #keypad window show if press set_btn homewindow.show() sys.exit(app.exec_()) i enter values using keypad , shown in space provided in same window. now ha...

Create a loop for a list of list from RasterBrick in R -

i'm on project in remote sensing running on r. i've got rasterbrick(x) raster dates i'm interested in, time serie dates corresponding (called time in function), , function works want when processed manually (z pixel want) : function(x,z) { d<-bfastts(as.vector(x[as.numeric(z)]),time,type="16-day") n<-bfast(d, h=0.15, season="harmonic", max.iter = 1) l[[z]]<-list(n$output[[1]]$tt) } the bfastts function used create ts object containing values of 1 pixel along time serie, bfast processing statisticals of want 1 result (this third line)? none of 2 functions mine, , stable , foundable in r package repository. so, add "another level" of function (sorry vocabulary may not precise) allow run function automatically. expected result list of result of function above, in other words list of each pixel's time series. i've tried (x still rasterbrick) : function(x) { z<-nrow(x)*ncol(x) j<-last(z[[1]]) l<-vector(...

algorithm - How do i determine the first digit of a number without knowing the number of digits?c++ -

for example, 42556 . how determine first digit if don't know number of digits in number? could't find algorithm suits me anywere! (i mean determine 4 in 42556) assuming a input number. #include <iostream> #include <cmath> using namespace std; int main() { long = 42556; long num; num=floor(log10(a))+1; //cout<<num<<" "<<"\n"; //prints number of digits in number cout<<a/(int)pow(10,num-1)<<"\n"; //prints first digit cout<<a%10<<"\n"; //prints last digit return 0; } live demo here .

global variables - UnboundLocalError in Python -

this question has answer here: how change variable after defined in python 5 answers what doing wrong here? counter = 0 def increment(): counter += 1 increment() the above code throws unboundlocalerror . python doesn't have variable declarations, has figure out scope of variables itself. simple rule: if there assignment variable inside function, variable considered local. [1] thus, line counter += 1 implicitly makes counter local increment() . trying execute line, though, try read value of local variable counter before assigned, resulting in unboundlocalerror . [2] if counter global variable, global keyword help. if increment() local function , counter local variable, can use nonlocal in python 3.x.

python - What can cause a seemingly infinite loop in my parallelized code? -

here code looks like: def data_processing_function(some_data): things some_data queue.put(some_data) processes = [] queue = queue() data in bigdata: if data meets criteria: prepared_data = prepare_data(data) processes += [process(target=data_processing_function, args=prepared_data)] processes[-1].start() process in processes: process.join() results = [] in range(queue.qsize()): result += [queue.get()] when tried reduced dataset, went smoothly. when launched full dataset, looks script entered infinite loop during process.join() part. in desperate moved, killed processes except main one, , execution went on. hangs on queue.get() without notable cpu or ram activity. what can cause this? code designed?

python - String formatting argument reference with item lookup -

is possible use value of format string argument key other argument? mins = {'a': 2, 'b': 4, 'c': 3} maxs = {'a': 12, 'b': 7, 'c': 21} '{0} {1[{0}]} {2[{0}]}'.format('a', mins, maxs) i'd expect a 2 12 keyerror: '{0}' thrown literal string {0} used lookup , not a . the lookup done in call format i'm after if it's possible reference other positional arguments in string. key = 'a' '{} {} {}'.format(key, mins[key], maxs[key]) no, according pep3101 , cannot nest replacement fields : format specifiers can contain replacement fields. example, field field width parameter specified via: "{0:{1}}".format(a, b) these 'internal' replacement fields can occur in format specifier part of replacement field. internal replacement fields cannot have format specifiers. this implies replacement fields cannot nested arbitrary levels. you h...

javascript - html2canvas not working for pseudo element -

i working on saving image of div. div has pseudo element , come know html2canvas not support pseudo element. how solve ? there other library save div image ? i using below link create tree structure : https://codepen.io/p233/pen/kzbsi , want save image. for purpose using html2canvas $(document).ready(function() { html2canvas($("#home1"), { onrendered: function(canvas) { var image = new image(); image.src = divbytearray; document.getelementbyid('image').appendchild(image); //window.open(divbytearray); /* $("#test").attr('href', canvas.todataurl("image/png")); $("#test").attr('download', 'checkfile.png'); $("#test")[0].click(); */ } }); }); please don't put comment on function bracket. not putting whole function. want know if there library save div image? you can use html2canvas.js , ...

nzec error in codechef while writing code in python -

this code giving runtime error (nzec) when compile in codchef. test_cases = int(raw_input()) result = 0 def output(x): if(x/2 >= 2): global result; result += x/2 - 1; output(x-2); else: print result; result = 0; while(test_cases > 0): base = int(raw_input()); output(base); test_cases = test_cases - 1; nzec error thrown code in codechef if there exception thrown. input not work c, c++ while using python on codechef - you can use import sys test_cases = sys.stdin.read().split() now iterate on test_cases. more info here also use sys.stdout.write() outputs rather print

swing - Timer works with println but not label using java -

i have labels become visible when letter pressed. private void formkeypressed(java.awt.event.keyevent evt) { // todo add handling code here: if(evt.getkeycode()==keyevent.vk_a){ jlabel7.setvisible(true); jlabel8.setvisible(true); jlabel9.setvisible(true); myblink(); } i have label8 on timer myblink() public void myblink() { new timer(1000, new actionlistener() { public void actionperformed(actionevent e) { system.out.println("begin"); jlabel8.setvisible(false); jlabel8.setvisible(true); system.out.println("timer"); } }).start(); } i have placed printlns see if timer begins , ends , when press key "a" output shows begin timer multiple times label not appear , disappear. tweak code need? missing? set of eyes. this because call successively setvisible...

kerberos - Konfiguring Hortonworks NiFI with kerberized Kafka -

i have been trying configure hdf 1.2.0 nifi work kerberized kafka, no avail. here zookeeper-jaas.conf: client { com.sun.security.auth.module.krb5loginmodule required usekeytab=true keytab="./conf/user.keytab" storekey=true useticketcache=false principal="user@realm.com”; }; kafkaclient { com.sun.security.auth.module.krb5loginmodule required useticketcache=true renewticket=true servicename="kafka" usekeytab=true keytab="./conf/user.keytab" principal="user@realm.com"; }; i getting errors when starting putkafka processor: caused by: java.io.ioexception: configuration error: line 8: expected [option key] @ sun.security.provider.configfile$spi.ioexception(configfile.java:666) ~[na:1.8.0_66] @ sun.security.provider.configfile$spi.match(configfile.java:562) ~[na:1.8.0_66] @ sun.security.provider.configfile$spi.parseloginentry(configfile.java:477) ~[na:1.8.0_66] @ sun.security.provider.configfile$spi.readconfig(configfile.java:427) ~[na:1....

asp.net mvc - Insert data in another table through entity framework MVC -

i want save student's data in student table , address in student details table can't insert data in second table. error object reference not set instance of object. student model public partial class student { public int id { get; set; } public string name { get; set; } public nullable<system.datetime> createddate { get; set; } } studentdetails public partial class studentdetail { public int id { get; set; } public string address { get; set; } public nullable<system.datetime> createddate { get; set; } } view model public class studentviewmodel { public student students { get; set; } public studentdetail studentdetails { get; set; } } dbset public partial class sampleentities : dbcontext { public sampleentities() : base("name=sampleentities") { } protected override void onmodelcreating(dbmodelbuilder modelbuilder) { throw new unintentionalcodefirstexception(); }...

reactjs - defaultState of Redux store from API -

how can make default state of redux store data comes in api request? i want make request this, pass returned data defaultstate when creating store: const request = new xmlhttprequest(); request.open('get', '/api', true); request.onload = function load() { if (this.status >= 200 && this.status < 400) { const data = json.parse(this.response); } else { // reached our target server, returned error } }; const store = createstore(rootreducer, defaultstate, enhancers); if you'd set asynchronously loaded state default, should try loading before starting application in index.js : import reducer './reducer'; function asyncstateloadingfunction(callback) { const request = new xmlhttprequest(); request.open('get', '/api', true); request.onload = function load() { if (this.status >= 200 && this.status < 400) { callback(json.parse(this.response)); } else { callback(nu...

java - Spring security issue with Http tag -

Image
my spring configuration file follows <?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" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:security="http://www.springframework.org/schema/security" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springfra...

c++ - Polynomial++: How to increment p(x) by 1 -

i have polynomial class, , trying define operator++ , both pre- , post- incrementation, trying define pre- , post- decrementation, namely operator-- . here snippet of code: class polynomial { public: polynomial(); polynomial(vector<int>coeffs); /* . . . */ polynomial operator++(); polynomial& operator++ (int unused); polynomial operator--(); polynomial& operator-- (int unused); /* . . . */ private: vector<int> coefficient; }; polynomial polynomial::operator++() { coefficient[0]++; return *this; } polynomial& polynomial::operator++ (int unused) { polynomial copy(*this); coefficient[0]++; return copy; } polynomial polynomial::operator--() { coefficient[0]--; return *this; } polynomial& polynomial::operator-- (int unused) { polynomial copy(*this); coefficient[0]--; return copy; } i error when trying in main: polynomial p( ...some vector... );...

html5 - How can disable open color palet when i click on <input type="color">? -

i have input: <input type="color"> and when click on automaticaly open windows color palet, how can disabled this? example: <input type="color" colorpallet="disable"> ? try this <input type="color" disabled></input> or document.getelementbyid("mycolor").disabled = true; these way disable inputs in html. if looking bootstrap color picker <input type="color"> here fiddle .

scala - mapping an integer to an object in slick -

i using slick 3 scala , play , wondering how can transform, in table definition, id object. let's have list of values similar enum in java , id database must correspond id defined in enum. it's similar having table in database referenced through id. object x extends table[(int, string)]("x") { ... def typeid = column[int]("type_id") def type = ... (aaa or bbb) // filled in type_id ... } in slick can define own projections (instead of usual apply/unapply of case classes) data in database objects , again. can use string define type in database. your types might like: sealed trait x case class aaa() extends x case class bbb() extends x then slick mapping this: object xs extends table[x]("x") { def typename = column[string]("type_name") def tox(from: (string)): x = match { case ("aaa") => aaa case ("bbb") => bbb } def fromx(x: x): (string) = x match {...

javascript - How to include a new file js in a project? -

i'm trying include new js file containing new scene on cocos2d js project, every time try occurs following error: uncaught referenceerror: gamescene not defined. i included file in jslist , in applist: "jslist" : ["src/game_scene.js"], "appfiles" : ["src/game_scene.js"] the code of scene looks normal: var gamescene = cc.scene.extend({ onenter:function(){ this._super(); var gamelayer = new gamelayer(); this.addchild(gamelayer); } }); the code on app.js call scene looks too: var gamescene = new gamescene(); cc.director.runscene(gamescene); what have do? thanks!! :-) i solved problem. included file in "jslist" of "project.json".

python - Is it possible to make wrapper object for numbers, e.g. float, to make it mutable? -

in python 3 supposed object, numbers, they're immutable . is possible create wrapper object numbers, e.g. float, such behave ordinary numbers except must mutable? i've wondered whether feasible using built-in type function creating anonymous wrapper object deriving float, changing behaviour mutable. >>> f = lambda x : type('', (float,), dict())(x) >>> = f(9) >>> 9.0 what parameters must change f make number a mutable? how verify if number mutable: i must able create such function f create integer value float value , after shallow copy behave in following manner: >>> list_1 = [f(i) in [1, 2, 3, 4]] >>> list_1 [1.0, 2.0, 3.0, 4.0] >>> list_2 = copy.copy(list_1) >>> list_1[0] *= 100 >>> list_1 [100.0, 2.0, 3.0, 4.0] >>> list_2 [100.0, 2.0, 3.0, 4.0] modification of first list, have changed both of them. maybe must add fields dict() or add additional base class enforce...

Processing Power In Python -

this question has answer here: how current cpu , ram usage in python? 8 answers is there way monitor amount of processing power used in program in python? goal kill program if using power while connecting server in case of malicious intent. even if psutil provides os-level information in relatively os-independent way, better indicated interact directly local os. doing @ api level can seen complex , difficult debug. if case, useful alternatives in case of windows are: wmic process list full and wmic path win32_perfformatteddata_perfproc_process name,percentprocessortime that's closest windows equivalent *nix's better known ps . the suggestion is, then, "popen" them, , pipe output analysis. understanding @ least first ( wmic process ) supports continuous mode.

java - Force hibernate to leave id empty -

so using postgres , hibernate 4.2.2 , entity this @entity(name = "users") @check(constraints = "email ~* '^[a-za-z0-9._%-]+@[a-za-z0-9.-]+[.][a-za-z]+$'") @dynamicinsert public class users { @id @generatedvalue(strategy = generationtype.identity) @column(name = "id_user",unique = true) @index(name = "user_pk") private integer iduser; hibernate still inserts id in table, instead of leaving emtpy database fill in. hibernate forces ids based on cache not checking database whether has lates id. how can force can leave id blank , let database insert it? first thought because using int , int default 0 when using object forces id there cache. so goal let database fill ids instead of hibernate or @ least hibernate before filling in check database id first. so error getting was caused by: org.postgresql.util.psqlexception: error: duplicate key value violates unique constraint "users_pkey" detail: key (i...

node.js - How do I populate mongoose schema values from a schema referenced from inside another schema in Nodejs? -

i have mongoose schema of "products" includes array of colors(another schema). orders schema contains user , array of products. products contain product, quantity , color. color here schema specific product. i want user able order product of specific color (color available product) how populate color of selected product ? models\product.js var mongoose = require('mongoose'), schema = mongoose.schema; var colorschema = new schema({ value : {type : string} }); var productschema = new schema({ name: { type: string, default: '' }, colors : [colorschema] }); module.exports = mongoose.model('product', productschema); module.exports = mongoose.model('color', colorschema ); models\order.js var mongoose = require('mongoose'), schema = mongoose.schema; var orderschema = new schema({ timestamp : { type: date, default: date.now }, user : {type: mongoose.schema.types.objectid, ref: ...

php - Import CSV data and trigger column matching -

i'm having trouble finding solution - i've found plenty of guides on importing csv files via jquery and/or php, problem next step - need find way of importing csv data (ideally jquery php fine) starting column matching routine user can define column what, i.e. name/description/date etc. anyone know of out-the-box solutions or how begin? thanks in advance, graham you may try below steps. 1st form : in need allow csv file. 2nd form : fetch first row(header) of uploaded csvfile. may columns of user ex : user upload column d,e,f requirement need column name a,b,c in case have 1 form in left hand side may show columns required validation. right hand side may show uploaded header(d,e,f) user have choose =d or = e or = f once user choose columns , submit button press may validate columns , allow submit once data has been submitted have check in php function column match column , based on need operations.

adding numbers from n subsequent lines with bash or awk -

i have file: foobar 4 barfoo 3 forabo 2 afoorb 5 and want add numbers in second row n lines. if n=2 result like barfoo 7 forabo 5 afoorb 7 how do that? for general solution works n , save values in array using line number index, , delete values after using. sort of queue. awk -v n=2 ' nr >= n { print $1, ($2 + q[nr - n + 1]); delete q[nr - n + 1]; } { q[nr] = $2 } ' after clarification, seems want sum of values, example n=3 , expected output: forabo 9 afoorb 10 in case: awk -v n=2 ' nr >= n { idx = nr - n + 1; sum = 0; (i = 0; < n - 1; i++) sum += q[idx + i]; print $1, $2 + sum; delete q[idx]; } { q[nr] = $2 } '

amazon web services - Ansible: Create instances in different subnets -

i'm trying use ansible create 2 instances, 1 each in 2 subnets using play below. i'm using exact_count tag name keep track of instances. there 2 issues here: ansible ends creating 2 instances in first subnet , reports [ok] second subnet. ansible doesn't seem care stopped instances. creates new instances, instead of starting existing ones, or atleast considering them part of group of instances. - name: create kafka instances with_items: - "{{ vpc_pvt_subnet_2 }}" - "{{ vpc_pvt_subnet_1 }}" ec2: group: "{{ kafka_sg }}" key_name: "{{ ec2_keypair }}" region: "{{ region }}" image: "{{ ami_id }}" wait: true instance_type: "{{ kafka_inst_type }}" vpc_subnet_id: "{{ item }}" instance_tags: name: "kafka-instance" owner: data exact_count: 2 count_tag: ...

java - Verifying RSA SHA256 signature fails getting private key from certificate -

i'm trying verify data string , rsa-sha256 signature received webservice , i'm stuck loading private/public key certificate. i have following code retrieve info cer file, think in der format because it's not in typical base64 encoded: inputstream in = new fileinputstream(path1); certificatefactory factory = certificatefactory.getinstance("x.509"); x509certificate cert = (x509certificate) factory.generatecertificate(in); system.out.println(cert.tostring()); it outputs whole info of certificate: version: v3 subject: emailaddress=... ... algorithm: [sha256withrsa] ... but if try load , retrieve private key following code: keyfactory kf = keyfactory.getinstance("rsa"); x509encodedkeyspec bobpubkeyspec = new x509encodedkeyspec(encodedkey); keyfactory keyfactory = keyfactory.getinstance("rsa"); publickey bobpubkey = keyfactory.generatepublic(bobpubkeyspec); signature sig = signature.getinstance("sha256withrsa"); sig....

html - nokogiri screen scrape css selector issue -

i'm trying css working on rake task. namespace :task task test: :environment ticketmaster_url = "http://www.ticketmaster.co.uk/derren-brown-miracle-glasgow-04-07-2016/event/370050789149169e?artistid=1408737&majorcatid=10002&minorcatid=53&tpab=-1" doc = nokogiri::html(open(ticketmaster_url)) #psec-p label doc.css("#psec-p").each |price| puts price.at_css("#psec-p") byebug end end end however i'm returning this: #<nokogiri::xml::element:0x3fd226469e60 name="fieldset" attributes=[#<nokogiri::xml::attr:0x3fd2281c953c name="class" value="group-price widget-group">, #<nokogiri::xml::attr:0x3fd2281c9528 name="id" value="psec-p">] children=[#<nokogiri::xml::text:0x3fd2281c8d44 "\n ">, #<nokogiri::xml::element:0x3fd2281c8c7c name="legend" attributes=[#<nokogiri::xml::attr:0x3fd2281c8c18 name=...

Visual Studio 2015 CodeLens Github Support -

Image
has got codelens work github? of settings enabled. however, reference count github projects. uninstalling , re-installing vs2015 update 2 fixed issue. repairing not fix, , update not fix. uninstalling , re-installing seemed fix it. i not sure if because upgraded community edition professional edition (because still had community in programs , features listing).

elixir - Implementing a protocol by delegating to existing functions -

i'm learning elixir modeling board game, , have code: defprotocol board def can_handle_move(self) def handle_move(self, move) end defimpl board, for: list def can_handle_move(self), do: enum.empty?(self) def handle_move(self, move), do: list.delete(self, move) end the implementation looks more complicated is. actually, can_handle_move enum.empty? , handle_move list.delete . elixir have way of expressing this? like: defimpl board, for: list def can_handle_move = &enum.empty?/1 def handle_move = &list.delete/2 end ...which doesn't compile. i've tried without def s. try kernel#defdelegate/2 it. defimpl board, for: list defdelegate can_handle_move(self), to: enum, as: :empty? defdelegate handle_move(self, move), to: list, as: :delete end

.net - How to open proxy channel when endpoint defined in config file? -

i work on wcf project. here contract: [servicecontract] interface icontract { [operationcontract] string methodtest(string s); [operationcontract] list<hydrants_log_maxtime> getdata(datetime datetime); } and here how access host service end point: icontract proxy = channelfactory<icontract>.createchannel(new basichttpbinding(), new endpointaddress("http://localhost/hydrantevents/hydrant.svc")); using (proxy idisposable) { var rows = proxy.getdata(new datetime(2000, 5, 1)); var result = proxy.methodtest("sss"); } i move definition of end point on client app.config file: <system.servicemodel> <client> <endpoint address="http://localhost/hydrantevents/hydrant.svc" binding="wshttpbinding" contract="hydrantseventsconsumer.icontract"...

php - Searching for Paypal records by paymentId at Paypal account -

i have site uses paypal rest api sdk , capture paymentid after transaction. i capture return_url's $_server['query_string'] using php. i hoping client able go paypal account , search records using these paymentid's. doesn't seem case. there transactionid not match paymentid. any idea how either: search record in paypal account using paymentid (using paypal account interface record tools - not api programming) grab transactionid after transaction (the return url gives me paymentid, token, , payerid.) i've realized need take paymentid , use sdk retrieve more detailed payment information. $apicontext = $this->getapicontext(); $payment = new payment(); $payment = $payment->get( $paymentid, $apicontext ); $execution = new paymentexecution(); $execution->setpayerid( $_get['payerid'] ); // ### retrieve payment // retrieve payment object calling // static `get` method ...

php - sql how i get username from seesion id? -

now have doing chatroom message username getting seesion username. log in name username same you. how getting username user database session_user id? my table is user - have id,username chatroom have id,name chatroom_chat have chatroom_id whihc relationship chatroom,chat_id relationship chat chat have id,user_id,chat.date how user_id chat , username user table? here code php , sql $chatroomid=$_get['chatroomid']; $userid = $_session['id']; $sql="select * chatroom_chat"; $result1 = mysqli_query($connection, $sql) or die(mysqli_error($connection)); while ($row = mysqli_fetch_array($result1)) { $chat = $row['chat_id']; $getchatdata = mysqli_query($connection,"select * ( select * chat id = '$chat' order id desc limit 0,40 ) sub order id asc ") or die(mysqli_error($connection)); while($row3 = mysqli_fetch_array($getchatdata)) { $username = $_session[...

to load the same prolog file into different modules in jpl -

i trying use jpl load same swipl file different modules. reason had because want have module can assert new predicates to, while leave other untouched. problem swipl seems forbidding this, jpl.prologexception: prologexception: error(permission_error(load, source, 'load.pro'), context(/(load_files, 2), 'non-module file loaded module stable; trying load to_mess')) @ jpl.query.get1(query.java:336) @ jpl.query.hasmoresolutions(query.java:258) @ jpl.query.onesolution(query.java:688) @ jpl.query.hassolution(query.java:759) i have tried set redefine_module(true) load_files, still no go val query = new query(s"load_files(${m}:'${loader}', [redefine_module(true)])") query.allsolutions() i have been blocked hours, cannot find solution online. can please help?? you can use logtalk running on swi-prolog + jpl accomplish having 2 encapsulation units (objects instead of modules in case) sharing common initial definition (the cont...

javascript - Instant search using optional Logical Operators to filter results -

i'm trying write search function can use logical operator filter results. way code works can type out string search or can put < or > @ beginning of text field filter greater or less numerical values. i'm looking better version or way write it. have (semi) working version, way wrote have put 1 or 2 zeros if value isn't more 3 digits. example, <050 has used search items under 50. using <50 brings wrong results. in addition, if result under 100 i'm having convert value 5 005. works if largest value under 1k otherwise have convert 0005. function fulllistsearch() { $("#infosearch").keyup(function() { var v = this.value; var value = this.value.tolowercase(); operator = value[0]; len = $(this).val().length; if ( operator == ">" ) { $("#info").find(".fulllist").each(function() { var ths = $(this).text(); var npattern = /[0-9]+/g; var nmatches = ths.match(npatt...

uitableview - Why is the UITableViewController numberOfRowsInSections called before the init method? -

my uitableviewcontroller won't load information have downloaded parse. know link working because when ask print out pfquery, results want. however, problem method numberofrowsinsection called before init method. i'm not sure how download data before init method. here .m file @implementation picklertable @synthesize picklersarray; - (id) init { // call cuperclass's designated init self = [super initwithstyle:uitableviewstylegrouped]; if(self){ // insert initial data here pfquery *picklerquery = [pfquery querywithclassname:@"picklers"]; [picklerquery findobjectsinbackgroundwithblock:^(nsarray *objects, nserror *error) { if (!error) { picklersarray = [[nsarray alloc] initwitharray:objects]; } }]; } return self; } -(id) initwithstyle:(uitableviewstyle)style { return [self init]; } - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { return p...

c# - Server start method throws exception, port already in use? -

i creating server-client application server , client can talk each other. when call start method on server, error saying this: only 1 usage of each socket address (protocol/network address/port) permitted here program.cs: using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using system.net; using system.net.sockets; namespace networkingtest { class program { static void main(string[] args) { bool readline = true; string input = ""; while (true) { if (readline == true) { input = console.readline(); } if (input == "server") { server server = new server(ipaddress.any, 12346); readline = false; } if (input == "client") { client client = new client(ipaddress.parse("myipv4...

git - Restore deleted files from commit -

i've done following series of steps , don't know how recover files. git add file.txt git commit -m "message" rm file.txt git commit -am "message" ideally should have pushed changes after step 2 , delete forgot. there way recover file? many thanks! you can recover file previous revision checkout command: git checkout head^ file.txt or, if haven't pushed commit yet, might rather want reset commit instead: git reset --hard head^ this reset working tree same state of previous commit. changes after previous commit gone. if don't want changes gone, undo act of commit itself, can reset without --hard option, , restore deleted file with: git reset head^ git checkout file.txt

javascript - removeAttr() and remove() doesn't work -

i want use removeattr() , remove() remove <div> , seems doesn't work. since have $('#div1').removeattr('style').remove(); in last line of javascript, shouldn't <div> appear moment? not sure if javascript event-driven programming or top-down programming? or depends on code. i want because want delete , clear <div> every time before drag new <div> , , try put line of code everywhere, doesn't work. i not computer science major, please forgive ignorance. don't understand why last line doesn't execute? if can help, appreciated. thank much. my code: $(document).ready(function() { var dragging = false; var clickedx, clickedy; // right click event $("#displaywindow").mousedown(function(e) { // when mouse pressed, div appended displaywindow if (e.button == 2) { // append div start @ location click $("#displaywindow").append("<div id='div1'...