Posts

Showing posts from July, 2012

How to translate text into another language with HTML tags in PHP? -

i want translate text, including text , html tags different language, still retain html tags, such <p> have nide day </ p> <p> passez une bonne journée nide </p> ; know can can translate manually using https://translate.google.com , there way can send automatically content translated page " https://translate.google.com " , results returned using php?.thanks much.

python - py2exe and assimulo - No module named algebraic -

i trying build executable using py2exe on soft uses library assimulo (differential equation solver). problem encountered during execution receive: importerror: no module named algebraic the exact error message is: traceback (most recent call last): file "main.py", line 89, in <module> simulation.simulation import simulation file "simulation\simulation.pyc", line 18, in <module> manages action linked simulation, running, saving, replay, etc... file "solver\assimulosolver.pyc", line 7, in <module> explicit solver choose in list of assimulo solvers: file "assimulo\solvers\__init__.pyc", line 25, in <module> file "assimulo\solvers\kinsol.pyc", line 12, in <module> file "assimulo\solvers\kinsol.pyc", line 10, in __load file "kinsol.pyx", line 1, in init assimulo.solvers.kinsol (assimulo\solvers\kinsol.c:19711) importerror: no module named algebraic he

java - Knapsack algorithm optimized for weight instead of values -

is possible modify 1-0 knapsack algorithm optimize final total weight of items in bags first choice (and values second choice), maintaining same algorithmic complexity? i'm working on this java implementation (in end of article). more specifically, i'm thinking of changing piece of code if (wt[item-1]<=weight){ v[item][weight]=math.max (val[item-1]+v[item-1][weight-wt[item-1]], v[item-1][weight]); }else{ v[item][weight]=v[item-1][weight]; } with other condition firstly control if weight closer threshold adding item , than, if weight not change, if value better. have got idea how without change complexity? thank you edit with "firstly control if weight closer threshold adding item" mean reaching weight limit of backpack. in other words "maximizing weight can carry in bag" without breaking it are trying following? choose items weight maximized, while still respecting weight limit. if there multiple optimal solutions

ios - use an array to pass values into a TIMER IN SWIFT -

i have working countdown can increase pushing add button , thats time counts down (so user can set countdown) i display starting time 00:00 in label. when click button increase countdown begins @ 1 because @ moment int can create array , increase individual indexes, display them within label? can or point me in write code direction have below thanks var timearray: [double : double] = [00, 00] var timer = nstimer() var countdown = 0 func runtimer() { timer = nstimer.scheduledtimerwithtimeinterval(1, target: self, selector:selector("updatetimer"), userinfo: nil, repeats: true) } func updatetimer() { if countdown > 0 { countdown-- timerlabel.text = string(countdown) } else { countdown = 0 timerlabel.text = string(countdown) } } @iboutlet weak var timerlabel: uilabel! @ibaction func increasecountdown(sender: anyobject) { countdown++ timerlabel.text = string(countdown) } @ibaction func startcountdown(s

php - Displaying an array that's within an array -

say have array, how assign variables values behind a,b,c,d , e? code: <?php $request = "https://www.kimonolabs.com/api/6xlbn85i?apikey=daiceifxondovm18barko8uekzje1p6c&bondsnummer=21169152"; $response = file_get_contents($request); $results = json_decode($response, true); print_r($results); echo '<pre>'; print_r($results); echo '</pre>'; ?> and output: array ( [name] => tennismix2 [count] => 1 [frequency] => on demand [version] => 11 [newdata] => [lastrunstatus] => success [lastsuccess] => wed nov 19 2014 08:34:23 gmt+0000 (utc) [thisversionrun] => wed nov 19 2014 08:34:21 gmt+0000 (utc) [thisversionstatus] => success [url] => http://status.mandrillapp.com/ [results] => array ( [collection1] => array ( [0] => array ( [a] => 21169152

php - Laravel - 2 forms on single page -

i have 2 forms placed in single view: {{ form::open(array('action' => 'mycontroller@verifychangelogin')) }} {{ form::open(array('action' => 'mycontroller@verifycreatelogin')) }} i have 2 post routes defined controller methods: route::post('changelogin', array('uses' => 'mycontroller@verifychangelogin', 'before' => 'auth')); route::post('createlogin', array('uses' => 'mycontroller@verifycreatelogin', 'before' => 'auth')); problem when click on submit button of second form, calls wrong route, allways 'changelogin' instead of 'createlogin'. i have studied simmilar posts on stackoverflow, none of solutions worked me. cant find out what's wrong here. that? are closing first form before open second? {{ form::close() }}

jpa - Transform SQL statement into JPQL to get latest entries for each user -

i want transform sql statement select * (select * `votes` order `date` desc) sub group `username` into jpql. idea latest vote (order date desc) each user (group username ). i understand jpql not support subqueries in from, tried "in" # not work! select v vote v v.id in (select tmp.id vote tmp order date desc) group v.username but gives me first entries. tried "max" # not work! select v vote v v.date in (select max(tmp.date) vote tmp group tmp.username) as well, gives me multiple entries of same user date not unique... edit: i thought of creating view sql syntax workaround, jpql query refers class (not table) didn't me far ;-) edit: then thought of joins , lead me native queries . turns out can use above sql nativequery = true : @query(value = "select * (select * `votes` order `date` desc) sub group `username`", nativequery = true) and works! see final update: can use initial sql statement if use nativequery = tr

Unable to connect DB2 Zos with bluemix using cloud integaration -

we used cloud integration connect mainframe db2 in bluemix, downloaded secure connector in linux os , configured db2 jars. status in bluemix got changed "connected" ,but unable proceed further create api db2 ip's endpoints getting error "database connected , please check secure connection" .but have checked our secure connection in terminal in start mode. please provide on same. are able connect z/os server without secure connector; using other client? you can use db2jcc - ibm data server driver jdbc , sqlj diagnostic utility test database connectivity , validate db2 authentication using java. sample command , it's output shown below: $ java com.ibm.db2.jcc.db2jcc -url jdbc:db2://myhost.ibm.com:446/mydb -user myuserid -password mydbpasswd [jcc][10521][13706]command : java com.ibm.db2.jcc.db2jcc -url jdbc:db2://myhost.ibm.com:446/mydb -user myuserid -password ******** [jcc][10516][13709]test connection successful. db product version = ds

How to update the Aapache Solr's stopword.txt file using Php-Solr -

i using solr in application , want ignore of search queries "country", "black friday", "cine" etc. want return nothing if encounters such queries strings. i can add phrases in stopword.txt file in solr don't want add directly. there methods, functions in php-solr can add using php script? there view site admin can add/delete list of phrases & i'll add/remove terms using php script. you should solr 4.8+ features of managed synonym , stopword filter factories. these provide rest api managing content of these dictionaries.

Javascript toFixed Not Rounding -

i'm using javascript bind checkboxes, , tofixed(2) not rounding up. ideas why it's not rounding? instance, if number 859.385 it's displaying 859.38 instead of 859.39 . i've read tofixed can round differently depending on browser using, know of way around javascript calculations match php calculations? var standardprice = parsefloat($('#hsprice_'+this.id.split('_')[1]).val()); var price = parsefloat($('#hprice_'+this.id.split('_')[1]).val()); var discount = parsefloat($('#hdiscount_'+this.id.split('_')[1]).val()); var deposit = parsefloat($('#hdeposit_'+this.id.split('_')[1]).val()); var currsprice = parsefloat($('#htotalsprice').val()); var currprice = parsefloat($('#htotalprice').val()); var currdiscount = parsefloat($('#htotaldiscount').val()); var currdeposit = parsefloat($('#htotaldeposit').val()); currsprice += standardprice; currprice += price; currdisc

ios - Hiding a specific cell hides random cells -

when create uicollectionviewcells , tried in cellforrowatindexpath (if indexpath.row == 3){ cell.hidden = yes; } i have 6 cells. they're randomly set hidden when refresh collectionview. not 1 cell hidden (even though hardcoded 3 make sure @ least 1 cell). any clue? its because cell reused. keep in mind, when use if in cellforrowatindexpath , must implement else part. if (indexpath.row == 3){ cell.hidden = yes; } else { cell.hidden = no; } or cell.hidden = indexpath.row == 3;

asp.net mvc - Calling same partial view from multiple parent pages -

i have partial view using in 2 parent pages. want detect parent page calling partial view. does there event find this? the partialextensions.partial helper has extension takes viewdatadictionary partial name, see http://msdn.microsoft.com/en-us/library/ee407439(v=vs.100).aspx . can use pass in whatever want key:value pairs, e.g. parentviewname string. parent views can do @html.partial("partialname", new viewdatadictionary { {"parentviewname", "parentview1"} }) then in partial can access view data via: @viewdata["parentviewname"]

excel vba - Accessing ActiveX control from Module -

i guess have basic wrong here, can please correct me? i have activex control in "home" worksheet. now, when code, this works: msgbox (thisworkbook.worksheets("home").quantity.value) so this: with thisworkbook.worksheets("home") msgbox (.quantity.value) end but not: dim wh worksheet set wh = thisworkbook.worksheets("home") msgbox (wh.quantity.value) can please explain difference? the worksheet class not have quantity member compiler object it. either need use object variable (as in both of prior examples), or access control using oleobjects property of worksheet: msgbox wh.oleobjects("quantity").object.value for example.

java - How to link two xml pages in Android app when a button is clicked? -

i making simple app in on home page, button placed. when button clicked, must display new page (xml in layout). how .. my app contains in src directory, there 2 java files. 1. activity2 2. main_activity , 2 xml files in layout: 1. fragment_main.xml 2. activity.xml i want when click "technical button", should display activity.xml page layout.. my codes: main_activity.java package com.example.vit; import java.util.locale; import android.util.log; import android.support.v7.app.actionbaractivity; import android.support.v7.app.actionbar; import android.support.v4.app.fragment; import android.support.v4.app.fragmentmanager; import android.support.v4.app.fragmenttransaction; import android.support.v4.app.fragmentpageradapter; import android.app.activity; import android.content.intent; import android.os.bundle; import android.support.v4.view.viewpager; import android.view.gravity; import android.view.layoutinflater; import android.view.menu; import android.view.me

Converting to json correct way using php? -

i need o/p ["12","13"] when following json operation i have 2 varaiables , getting these values post data $a = $_post['cas']; $b = $_post['casty']; $final1 = json_encode($a); $final2= json_encode($b); $final_value = '['.$final1.','.$final2.']'; i getting output ["12","13"].i doing correct way in php ? other ways json object apart ? use array this: $array = array($_post['cas'], $_post['casty']); $final_value = json_encode($array); note: no need create $a , $b . by adding json_force_object 2nd parmeter you'll key => value data normal php array. json arrays don't have keys, therefore of time json_force_object useful. json array ["data", "data2", "data3"] json object {0:"data", 1:"data2", 2:"data3"}

java - "Unpress" JButton which is looking pressed -

i have jbutton in java application. when button pressed, actions developed actionlistener take seconds finish, , button looks pressed time. i want remove look, since looks application had frozen. i have seen this related question , prefer different solution avoid changing lot of code. is possible achieve? resource sensitive tasks must not performed in ui thread (the thread handles ui clicks , other activities visible user), need separate time consuming tasks other thread. another option show progress bar or till action over.

python - How to monitor the GET methods of a URL? -

not sure if i'll make sense or not here goes. in google chrome, if rightclick page , go resources, refresh page, can see get/post methods pop happen. i'm wanting know if there way, in python, input url , have generate list of each call listed (not sure if possible) would love direction on it! thanks i believe can clarify parts of original question. one 1 hand, using browser-built-in debugging tools investigating how website behaves when loaded browser technique, , not replaceable custom code. on other hand, looks looking html parser, such beautifulsoup . also, seem confuse meaning of url , html document. url can point html document, in many cases points other things, such json-api endpoint. assuming wanted ask how "to input url html document , have generate list of each remote resource call browser perform" : before rendering website, web browser fires off initial http request , retrieves main html document. parses document and, among others

matlab - How to find all lines in a set that coincide in a single point? -

suppose given set of lines, how can partition set number of clusters, such lines in each cluster coincide in single point? if number of lines n reasonable, can use o(n^3) algorithm: ever pair of lines (in form a*x+b*y+c=0 ) check whether intersect - exclude pairs of parallel , not-coincident lines determinant |a1 b1| = 0 |a2 b2| for every intersecting pair if line shares same intersecting point, determinant: |a1 b1 c1| |a2 b2 c2| = 0 |a3 b3 c3| if n large cubic algorithm using, calculate intersection points (upto o(n^2) of them) , add these points map structure (hashtable, example). check matching points. don't forget numerical errors issue.

html - How can I create div with a pointed top with CSS -

Image
i've see lot of threads remotely related suggest css triangles in ::after or ::before pseudos, none have panned out. i'm throwing out see if has ideas. i'm looking create div pointed or pitched top still maintains uniform border , box-shadow rest of div. see link image of i'm trying create: if dont want use image this. working image lot easier in case. body { background-color: #ccc; } .wrapper { } .outer { width: 0; height: 0; border-style: solid; border-width: 0 205px 32px 205px; border-color: transparent transparent #ffffff transparent; position: absolute; } .inner { width: 0; height: 0; border-style: solid; border-width: 0 200px 32px 200px; border-color: transparent transparent #ea2225 transparent; margin-left: -200px; margin-top: 5px; position: absolute; } .fix { background-color: #fff; height: 10px; width: 410px; position:

Updating Excel file with Peoplesoft data -

as pm required steer team on hours spend on projects. the hours reported in peoplesoft. there way extract hours reported in p/s hr module excel file? should programmed in excel , suggestions welcome duco if have access peoplesoft system, use delivered reporting functionality. menu path queries is:reporting tools -> query -> query manager. query manager let run query , save results excel file. however need contact department write query generates data people wanting or write query yourself. recommend contacting department write query or may have existing query use.

c++ - URLDownloadToFile QtCreator file not downloading -

my issue today involve usage of urldownloadtofile() qtcreator. use following code download: hresult hrez = urldownloadtofile(null, text(url), text("c:\\image.png"), 0, null); if (hrez != s_ok) { return false; } the code run no errors file ins't downloaded. i've been searching through many solutions issue none have been relevant not successful. have done wrong? well the documentation states: szfilename: pointer string value containing name or full path of file create download. if szfilename includes path, target directory must exist. so assume parameter needs include not path filename well. instance hresult hrez = urldownloadtofile(null, text(url), text("c:\\downl.tmp"), 0, null);

javascript - Fish Animation on barlasapaydin.com -

hi there trying yo create fish animation on barlasapaydin.com site didn't success creating animation me creating animation , please provide code , tried through html5 , css3 no sccess <div id="wrapper"> <div id="header"> <div class="loop"> </div> </div> <a href="#" class="logo"> <img src="logotype.png"/> <span class="img-anim"></span> <span class="img-anim1"></span> <span class="img-anim2"></span> <span class="img-anim3"></span> <span class="img-anim4"></span> </a> </div> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#header .loop").animate({background-position: '-2877px 0px'

mysql - SQL Foreign Key Constraint Error 1215 -

we trying make simple database facing same error , record did check other foreign key constraint questions didn't helped @ all. as know when convert our eer diagram relations map, relations take primary keys of entities connected, in example: lets our entites have 1 primary key each of them tc_no, randevu_no, hasta_no , our relationt hat tied them going take primary keys of entities. like; create table request( tc_no int not null, randevu_no int not null, hasta_no int not null, primary key(randevu_no,tc_no,hasta_no), foreign key(hasta_no) references patient(hasta_no) on delete cascade, foreign key(randevu_no) references appointment(randevu_no) on delete cascade, foreign key(tc_no) references patient(tc_no) on delete cascade ); however, getting same error. there no misspelling checked hours couldn't solved , have no idea why not working. for people need code of database: create table person( isim varchar(12) not null, soyisim varchar(12) not null, cinsi

javascript - web api authentication and ssl -

i have developed web api project has token endpoint set up. want set site calls api have created javascript function: $.ajax({ url: "http://path.to.site/token", data: { grant_type: "password", username: "user", password: "password" } }).done(function (data) { console.log(data); }).fail(function (errror) { console.log(error); }); even ssl enabled on both sites, if user view source of site able see username , password. if got access token using server side code (php, .net or whatever) still have pass access token javascript api calls , again readable. i feel missing here, can explain me is? :d what use server generate jwt when generates site. in jwt embed claims site, , pass jwt bearer token client api. api use shared secret (that site , api know about) generate jwt signature make sure if tamper proof while on client. using common jwt features such exp, iat, , jti, can secure inform

css - Automatic adjustment of form width with textarea witdh in HTML -

Image
i have problem concerning width of form. understand better, please @ following 2 images. i adjust length of form length of text area, width of text area not longer form (see screenshot 2). please show me how can that? tried set width of text area on auto (like height) width doesn't work. in following can see code: <form role="form" class="row-fluid hide comment popover"> <div class="form-group"> <label>comments on test</label> <textarea class="form-control" id="comment_text" form="comment" name="text" placeholder="there no comment yet"></textarea> </div> <div class="form-group"> <input class="btn btn-default" type='button' value='submit comment' onclick='updatecomment("@module",this.parentelement)' /> </div> thank in advance. greets. you can set max-width

.bash profile - Correct .bash_profile in OSX -

i need use tools, have problems when try use php artisan in laravel , cordova, need comment lines, because $path not working fine. noob working unix :) to more specific in question, need these lines work fine together, without need uncomment , comment depending of tool need use: export path="/applications/xampp/xamppfiles/bin:$path" export path=~/.composer/vendor/bin:$path errors have when uncommented each one: case 1: cordova can run in xcode version 4.6 or greater. case 2: mcrypt php extension required. edit: i've added complete bash profile: # next line updates path google cloud sdk. source /users/chema/google-cloud-sdk/path.bash.inc # next line enables bash completion gcloud. source /users/chema/google-cloud-sdk/completion.bash.inc #comment line make cordova works fine #export path="/applications/xampp/xamppfiles/bin:$path" export path=${path}:/users/chema/sdk-android/sdk/platform-tools:/users/chema/sd$ #comment line make php ar

Polymer and AngularJS working together with ng-view -

recently have discovered polymer project, looks nice , fun develop with. want combining angular provide little routing. have index.html page containing polymer includes, html headers, scripts , styles. want small piece of code on every page of application, namely side-menu using core-drawer-panel . approach put part right after opening <body> tag , right below menu code <ng-view></ng-view> specific pages, e.g. main.html should loaded into. if put everything, menu , page-specific code, main.html , routing works fine. doing described above - have menu on every page - has result menu , nothing else shown up. let s see angular material design on github, adapted version of polymer project angular :-) https://material.angularjs.org/#/

ruby - Best Way to initialize a instance variable in Rails -

i'm having trouble initializing instance variables in rails, need use variable in different methods, needs initialized beforehand, eg: class test < activerecord::base @test = 1 def testing @test+1 end end t = test.new t.testint i follow error: test.rb:4:in `testar': undefined method `+' nil:nilclass (nomethoderror) test.rb:9:in `<main>' is there more elegant way initialize variable without using after_initialize ?: if dont want use after_initialize , create variable on fly: attr_writer :test def testing self.test += 1 end def test @test ||= 0 end

unit testing - Forcing nunit console runner to use CLR 4.5 -

i have following simple test case: var uri = new uri("http://foo.com/bar%2fbaz"); assert.areequal("http://foo.com/bar%2fbaz", uri.absoluteuri); this test fails on .net 4 passes on .net 4.5, can test using resharper test runner provides handy clr selection menu. but if run test using nunit console runner following: nunit-console.exe /framework:4.5 "c:\data\projects\uritest\bin\debug\uritest.dll" my tests failed. have modified nunit-console.exe.config , added this: <supportedruntime version="v4.0" sku=".netframework,version=v4.5" /> and after adding this, have started output runner: runtime environment - os version: microsoft windows nt 6.2.9200.0 clr version: 4.0.30319.34209 ( net 4.5 ) processmodel: default domainusage: single execution runtime: v4.5 but still test fails. idea why happens? after taking more @ issue, here's information gathered different forums. first, should detect run

module' object has no attribute 'find_template_source satchmo-django -

after finished installing satchmo in django1.4 . got error "module' object has no attribute 'find_template_source" attributeerror @ / 'module' object has no attribute 'find_template_source' request method: request url: "link url" django version: 1.4.8 exception type: attributeerror exception value: 'module' object has no attribute 'find_template_source' exception location: /home/prabhakaran/virtual/dj1.4_satchmo/local/lib/python2.7/site-packages/django_app_plugins-0.1.0-py2.7.egg/app_plugins/templatetags/app_plugins.py in template_exists, line 162 python executable: /home/prabhakaran/virtual/dj1.4_satchmo/bin/python python version: 2.7.6 python path: ['/home/prabhakaran/softwares/satchmo/store', '/home/prabhakaran/virtual/dj1.4_satchmo/local/lib/python2.7/site-packages/django_threaded_multihost-1.4_1-py2.7.egg', '/home/prabhakaran/virtual/dj1.4_satchmo/local/lib/python2.7/site-packages/

stack - Overflow attack to call function -

i have assignment school (i not ask question give me answer assignment) we have been given following code in c: #include <stdio.h> #include <stdlib.h> int main( int argc, char **argv ) { char * stuff = 0; int len = 0; vulnerable(); return 0; } int vulnerable( void ) { char buf[100]; printf("please enter hacker name: "); fflush(stdout); gets(buf); printf("\"%s\"\n can hack this?" , buf ); } void notcalled( void ) { char *secret = "iouf jmmb, cbsb sftufo lwbs!"; int i; printf("the secret string is: "); for( = 0 ; secret[i] ; i++ ) if( secret[i] >= 'a' && secret[i] <= 'z' ) printf("%c" , secret[i] -1 ); else printf("%c" , secret[i] ); printf("\n"); } i have compiled program using command: gcc -fno-stack-protector -z execstack -o oflow oflow.c i want know if "right on track". the first thing did find function &

plone.app.multilingual: Access Translated Object's Attributes -

environment: plone 4.3.3, plone.app.multilingual 2.0a4 (checkout github), in case, 2 languages (en , zh) enabled, ie bilingual site. my custom dexterity type has field remoteurl , definition looks this: <field name="remoteurl" type="zope.schema.textline"> <title i18n:translate="">url</title> <description i18n:translate="">link resource.</description> <default>http://</default> <required>false</required> </field> my scenario this: when creating item in zh folder (zh/my_item), remoteurl field filled, displayed according the template . then, when translating item en language (en/my_item), want display value zh/my_item if remoteurl field unfilled in en/my_item. on other hand, if filled in en/my_item, value used , displayed remoteurl field. the existing language independent field not meet needs, because filled value affect both zh/en items. how access zh/my_item remo

java - Get all days between tomorrow and 60 days forward then loop through them -

i need take tomorrow, add 60 days , loop on day day. wondering appropriate way of doing this? this tried. somehow starts loop month , in january 2015 shows month 0. calendar startcalemder = calendar.getinstance(); startcalemder.settime(new date()); startcalemder.add(calendar.date, 1); calendar endcalendar = calendar.getinstance(); endcalendar.settime(new date()); endcalendar.add(calendar.date, 60); //loop on day day (; startcalemder.compareto(endcalendar) <= 0; startcalemder.add(calendar.date, 1)) { startcalemder.get(calendar.year); //shows year startcalemder.get(calendar.month); //shows month startcalemder.get(calendar.day_of_month); //shows day } your code alright. need understand crazy calendar api 0 means january , 10 means november. https://docs.oracle.com/javase/7/docs/api/constant-values.html#java.util.calendar.january

wpf - How to set a default empty binding unless the value is different from 0? -

when set binding <textblock text="{binding position}"..> ui gives 0 int defaults 0. first, how stop showing result unless position not 0 ? second, if position = 5 , ui shows result, if goes 0 again, stop showing result again in c#, int value type, meaning can never null . can use nullable<int> transform nullable, defaults null . a shortcut question mark. if define position int? position should result you're after. edit: didn't see request value disappearing after position = 0 again. a alternative use ivalueconverter proposed in comments. otherwise, use trigger, so: <style targettype="textblock" text="{binding position}"> <style.triggers> <trigger property="text" value="0"> <setter property="visibility" value="collapsed" /> </trigger> </style.triggers> </style>

unix - Capturing kill code of go process? -

i'm trying write test drive out functionality kill commands. this, need target of test (a simple go http server - https://github.com/jadekler/git-grunt-gostop/blob/master/test/fixtures/gostop_basic.go ) differentiate between having been killing -2 vs -9. there way this? seems though go's defer doesn't happen regardless of -2 vs -9, first try. subsequent research has not been enlightening. thanks suggestions! you can catch signals using os/signal package . can catch sigint code this: import ( "os" "os/signal" ) ... // signal module lose notifications if channel not ready receive, give buffer ch := make(chan os.signal, 5) go func() { sig := range ch { // interrupt signal received os.exit(0) } }() signal.notify(ch, os.sigint) unfortunately, can't same sigkill . signal(7) man page: the signals sigkill , sigstop cannot caught, blocked, or ignored.

ruby on rails - shipping address is not visible in paypal screen while using adaptive payment -

Image
i using paypal adaptive payment. want send shipping address of sender reciever. doing following things first getting approval key sender preapproval api then, using pay create api. this paramters :actiontype => "create", cancelurl: 'https://www.example.com/paypal_cancelurl', returnurl: 'https://www.example.com/paypal_successurl', :currencycode => "usd", :preapprovalkey => preapproval_key, :receiverlist => { :receiver => [{ :amount => total, :email => reciever@example.com }] } after getting paypal paykey step 2, using set payment option api . passing following information :paykey => paykey, :displayoptions => { :businessname => "example site" }, :senderoptions => { :shippingaddress => { :addresseename => sender_name :street1 => sender_street, :city => sender_city, :state => sender_state, :zip => sender_

Gitlab Merge Request created after update to version 7 has many more commits than it should have -

after updating gitlab version 7 when creating merge request, list of commits larger expected. providing list of 1000+ commits when there should 5. going through source code, unable find gitlab determining commits use merge request in order debug that. found following in compare_service.rb @ loss go here. # compare 2 branches 1 repo or between repositories # , return gitlab::compareresult object responds commits , diffs class compareservice def execute(current_user, source_project, source_branch, target_project, target_branch) # try compare branches commits list , diffs # # note: use satellite when need compare between 2 repos # because satellites slower operations on bare repo if target_project == source_project gitlab::compareresult.new( gitlab::git::compare.new( target_project.repository.raw_repository, target_branch, source_branch, ) ) else gitlab::satellite::compareaction.new(

ruby - Rails find and replace instances of attribute after rename_column -

i've looked around , haven't found elegant solution this, figured i'd ask. i in middle of refactoring couple database tables keep naming scheme continuous throughout application. process this: create migration rename bunch of columns: class renamesomeattributes < activerecord::migration def change rename_column :some_tables, :old_name, :new_name end end save record of instances of :old_name before replace them in rest of code. (optional) $ grep -r old_name app lib spec >> find-replace-history.txt find , replace string in models, views, controllers, javascripts, stylesheets, specs, rake tasks etc. $ grep -rl old_name app lib spec | xargs sed -r 's/old_name/new_name/g' however, method useful when i'm working attribute names specific table adjusting. more general attribute names (:name, :description etc), forced manually edit files avoid replacing wrong table's attribute. is there better tool should using me find every

Google Analytics tracking code doesn't track page views -

i real time page views current tracking code, pageviews currenctly 0, if visit page myself , navigate through website. can't figure out what's causing error... my script (function(i,s,o,g,r,a,m){i['googleanalyticsobject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new date();a=s.createelement(o), m=s.getelementsbytagname(o)[0];a.async=1;a.src=g;m.parentnode.insertbefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'ua-xxxxxxxx-x', 'neurogavan.se'); // neuro ga('create', 'ua-xxxxxxxx-x', 'neurogavan.se', {'name': 'roxbury'}); // roxbury ga('require', 'displayfeatures'); ga('send', 'pageview'); // send page view neuro tracker. ga('roxbury.send', 'pageview'); // send page view roxbury tracker. my website: http://neurogavan.se/ the code looks

python - socket error in chat application An error operation was attempted on something that is not a socket -

Image
i trying create simple chat application on python . have created client.py , server.py taking reference site the server runs fine while running of client code gives error as to resolve issue have reset winsock , tried reinstall tcp/ip this site how resolve issue client.py import socket, select, string, sys def prompt() : sys.stdout.write('<you> ') sys.stdout.flush() #main function if __name__ == "__main__": if(len(sys.argv) < 3) : print 'usage : python telnet.py hostname port' sys.exit() host = sys.argv[1] port = int(sys.argv[2]) s = socket.socket(socket.af_inet, socket.sock_stream) s.settimeout(2) # connect remote host try : s.connect((host, port)) except : print 'unable connect' sys.exit() print 'connected remote host. start sending messages' prompt() while 1: socket_list = [sys.stdin, s] # list sockets re

dependencies - How to Revoke in Mysql? -

how revoke user2's option while revoke user1's option? ![i have give select option , grant option user1 , user1 give select option user2. now want revoke user1's option if revoke user1's option user2 still have select option there no dependency such user2's privileges require user granted him privileges retain similar privileges. there not requirement user1 exist @ all. you have revoke privileges user2 separate task. there no automatic way of doing describe.

getting text from a textview to display in a string in android -

i trying create share button once user presses allow user share social networking site. i have textview text "chipotle" in xml , text "chipotle" appear in string intent. example, if user post onto facebook display "hey i'm going chipotle" , allow user post onto wall. i have done far this: placename = (textview) findviewbyid(r.id.place_text); placename.gettext().tostring(); string eshare = "hey i'm going to" + placename; with following i'm going android.widget.textview{123212432423....app:id/place_text) thanks in advance you have assign variable line placename.gettext().tostring(); like this placename = (textview) findviewbyid(r.id.place_text); string placenamestring = placename.gettext().tostring(); string eshare = "hey i'm going to" + placenamestring;

uitableview - Error updating a cell with data from Parse -

in parse have class called "shouts", string value called "wall" i need see how many "shouts" have in every "wall" using label inside cell of tableview in tableviewcell have: @iboutlet var newwalllabel: uilabel! // name of wall (cell working) @iboutlet var shoutcounter: uilabel! // using label want show number of objects have in "shouts" class same newwalllabel (that "wall" string in shouts class) in tableview i'm using countobjectsinbackgroundwithblock. println works, show me number of value have "testing" string in shout class in parse. need use whatever text have newwalllabel uilabel so i've been trying while connect "(count)" shoutcounter label, creating in tableview: var counter:uilabel! then var inside func load data of wall var countshout = pfquery(classname: "shouts") countshout.wherekey("wall", containsstring: "testing")

laravel - Error refreshing the OAuth2 token, message: '{ "error" : "invalid_grant" }' -

i working package analytics-laravel 4 google analytics , have follower of steps correctly. when try site id example, face error: error refreshing oauth2 token, message: '{ "error" : "invalid_grant" }' i have double checked of configurations, client id, service_account , private key error still occurs. else should try check maybe solve issue?! i didn't use package before, i'm using google-api-php-client , anyways, error occurs if don't set refresh token. you should know need have access token once. need set access type offline, provide refresh token use automatically new access token without getting new code every time access token expires. in google's console, created client id web application . make sure set redirect uri web page receive code , extract access token using code. here code example using google-api-php-client , hope help: you need run following code once, , retrieve , store access token. <?php re

c# - Entity Framework - Calling A Stored Procedure Without Mapping -

i use database-first approach using entity framework (ef). i'm investigating different ways of calling stored procedures (stored procedures not tied entities) using ef. currently, i'm using approach found here using designer (in approach, import stored procedure, create function import , use complex type mapped object). don't because relies on bloated edmx file , causes merge conflicts in source control when 2 or more people perform procedure , check in code. i found this post claims can call stored procedure , map plain old c# object (poco). my question if want map poco stored procedure in ef not using designer approach, how aliases column names? example, let's call stored procedure , particular column named "customerid" , want property mapped named "id" instead of "customerid". how can without using designer approach? something following should work: [your db context].database.sqlquery<[your poco class]>("[

c# - RavenDB load related data not working -

the following code throws exception on session.load<employee>(order.employee) , have no problem querying employee directly. static void loadrelateddata() { using (var session = mystore.opensession()) { var employeefromquery = session.query<employee>().firstordefault(); //works var order = session.include<order>(o => o.employee).load("orders/819"); //works var employeerelatedtoorder = session.load<employee>(order.employee); //exception var dynamicrelatedtoorder = session.load<dynamic>(order.employee); //works } } private static idocumentstore mystore = new documentstore() { url = "http://localhost:4444/ravendb", defaultdatabase = "hello" }.initialize(); the exception - an unhandled exception of type 'system.invalidcastexception' occurred in raven.client.lightweight.dll additional information: u

c - Freeing memory after passing value causing EXC_BAD_ACCESS -

when free normalizedword in foo after passing addelement segfault when trying strcmp key . without freeing, there's no issue, other gigantic memory leak. idea might going on here? foo(char* word) { char* normalizedword = (char*)(malloc(strlen(word) + 1); strcpy(normalizedword, word); normalize(normalizedword); int result = addelement(dict->hashtable, normalizedword); free(normalizedword); return result; } addelement(hashtable *hashtable, const char *key) { if (0 == hashtable->elements[hashindex]) { // add new element hashtable->elements[hashindex] = createelement(key); } else { // search existing or add new element element* current = hashtable->elements[hashindex]; /* error here... */ while (0 != strcmp(current->key, key)) { if (null == current->next) { current->next = createelement(key); break;

c# - ASP.NET MVC File sometimes does not upload -

have asp.net file uploader. works 95% time throw exception. the exception that. please know it. how can solve it. url: https://www.xxxx.com/upload/uploadhandler.ashx user: 44123 message: error occurred while communicating remote host. error code 0x80070001. stacktrace: @ system.web.hosting.iis7workerrequest.raisecommunicationerror(int32 result, boolean throwondisconnect) @ system.web.hosting.iis7workerrequest.readentitycoresync(byte[] buffer, int32 offset, int32 size) @ system.web.httprequest.getentirerawcontent() @ system.web.httprequest.getmultipartcontent() @ system.web.httprequest.fillinfilescollection() @ system.web.httprequest.get_files() @ you can't solve it. this happening because, external reason, connection closed and/or disconnect. you can catch show user-friendly error.

javascript - jQuery selector not working correctly -

so here html: <div class="alert alert-info alert-warning" id="rowcounter" style="display: block; bottom: -22px;"> sure want delete 103? <div class="btn-toolbar"> <a href="#" class="btn btn-sm btn-success" data-action="deleterow" data-table="contact" data-rowid="103">yes</a> <a href="#" class="btn btn-sm btn-default" data-action="cancel">no</a> </div> </div> and jquery (wrapped in script tags , document ready function): $('.alert#rowcounter a.btn').on('click',function() { console.log('yes'); if($(this).data('action') == 'cancel') { rowcounter('hide'); } if($(this).data('action') == 'deleterow') { var tbl = $(this).data('table'); var targ = $(this).data('rowid');

objective c - I am trying to create an NSArray for my labels -

i trying create nsarray labels not sure how beginner in objective c. i'm reading text file , each question in there has 4 different answers options, how can create array loop through answers , display them labels? this how set txt file: output while loop generate? x = 6; while (x > 0) { system.out.println(x + ", "); x--; } # a. no output generated. # b. 6, 5, 4, 3, 2, 1, # c. 5 , 4, 3 ,2, 1. # d. output infinite. # b. 6, 5, 4, 3, 2, 1, @ the # sign separate answers , last option correct answer. @ sign line break. any appreciated. one quick way using nsarray *array = [string componentsseparatedbystring:@"#"]; ignore first object since contain, question, , trim whitespaces , @ in last object. assuming there no # in string except separate answers

windows 8 - How can I add .lnk file to the SVN repository on the network volume? -

when i'm trying add .lnk file svn repository on network volume on windows 8 following error: commit succeeded, other errors follow: error bumping revisions post-commit (details follow): failed run wc db work queue associated 'c:\sources', work item 737 (file-commit crashlytics.lnk) can't set file 'c:\sources\crashlytics.framework\crashlytics.lnk' read-write: access denied. how can solve issue? i've used following workaround: remove commited folder. checkout again. p.s. .lnk files on crashlytics.framework unnecessary.

python - Capture value from function -

i'm having trouble while trying store output of function below, i'm trying create maths quiz asks randomized basic math questions , gives ability answer questions while checking whether correct , wondering if able me out code or provide me insight need learn in order complete it. here have far: print ("hello maths quiz, name?") name = input() random import choice,randint def rand_task1mathquiz(): a,b = randint(0,10),randint(0,10) random_operations = choice(["+","-","/","*"]) print("{0} {1} {2}".format(a,random_operations,b)) if __name__ == "__main__": x in range(10): rand_task1mathquiz() the general pattern looking return statement. when want capture return value of function, typically, you'd assign function's result variable, assign static values variables, except () on right-hand side makes function call evaluted, rather reference function object. notice h