Posts

Showing posts from April, 2015

java - How do I change the encoding of my jar file to manage characters such as "█▓▒ CRIT! ░░╚╡▌▌╞╗░░"? -

edited hey guys. my code using pircbot send irc messages twitch.tv. the messages include characters such '█▓▒ crit! ░░╚╡▌▌╞╗░░' example output code: sendmessage("#twitchraidstwitch", "/me █▓▒ crit! ░░╚╡▌▌╞╗░░"); so these characters displayed '?' in eclipse. didn't work until changed window -> preferences -> text file encoding us-ascii. (though i've learned these characters aren't ascii.) when export project jar , try run in cmd, characters '?'. how got getting work in cmd? thanks! ok got work. i used setencoding("utf-8"); score_under suggested. didn't change didn't hurt either. i launched java -dfile.encoding="utf-8" -jar jarfile.jar , did trick. i figured out utf-8 works on eclipse fails work exported jar

javascript - Code break when I'm trying to use an object methods in jquery mobile -

this class var player = function (name) { this.init(name); } $.extend(player.prototype, { name: '', goals: 0, fouls: 0, holding: 0, games: 0, wins: 0, taken: 0, init: function(name){ this.name = name; this.goals= 0; this.fouls= 0; this.holding= 0; this.games= 0; this.wins= 0; this.taken= 0; }, setgoal: function (num) { this.goals+= num; }, setfouls: function (num) { this.fouls+=num; }, setholding: function (holding) { this.holding = (this.holding * (this.games-1) + holding) / (this.games); }, setgames: function () { this.games+=1; }, setwins: function () { this.wins+=1; }, settaken: function (num) { this.taken+=num; } }); i tryed man

java - Eclipse Maven Workspace Resolution not seeing Generated Classes -

Image
i have 2 maven projects in eclipse, jar , war. war has dependency on jar, resolved through workspace resolution. the problem jar has generated classes, added jar through build-helper-maven-plugin. these classes aren't being resolved in war project. example: auto-completes class keeps saying can't found. more importantly, when running glassfish through eclipse, class not found these classes. if disable workspace resolution works fine, hope use workspace resolution. ideas? edit: folder structure. maven workspace resolved persistence project in lower image in maven dependencies folder, seeing top , bottom of folder. idk if correct, talking eclipse problems - not "see" generated classes right? to fix it, have add generated sources directory eclipse's build path , should fix problem. right click on project has generated classes->buildpath->conf buildpath in source tab - click add folder select directory build helper generates java fi

File uploads to another directory other than spcified directory in PHP code -

i have folder struct this: admin-panel -- thesis-scripts -- add_thesis.php uploads and trying upload .docx file uploads directory. here code: $targ_dir = "uploads/"; $targ_file = "../" . $targ_dir . basename($_files["thesisfile"]["name"]); $flagok = 1; $tempfolder = $_files['thesisfile']['tmp_name']; if(move_uploaded_file($tempfolder, urlencode($targ_file))){ echo $targ_file; } however, code above results file upload inside thesis-scripts folder. how can move file uploads folder? help. purposely added ../ in $targ_file because save file path in database. upload_tmp_dir need, change default temporary directory, according documentation here upload_tmp_dir string temporary directory used storing files when doing file upload. must writable whatever user php running as. if not specified php use system's default. if directory specified here not writable, php falls sy

do windows azure mobile service scripts have transient fault handling -

when access sql table via server scripts sql azure retry logic implemented somewhere following request.execute(); ? yes, underlying code try several times complete operation sql azure on 30 second window.

html - Javascript slider not displaying array? -

here's link page i'm working on: https://www.servicerr.com/partners.php whenever click on different numbers, should update prices below slider. javascript file contains prices: https://www.servicerr.com/js/set_my_price.js what can't figure out why prices won't change , why every number staying highlighted when click 1 of next. about year ago, had working , had re-create it. can't figure out i'm doing wrong time around. appreciated. here links 2 other files javascript files make work: here's html code being used: <div class="product2" style="margin-right:2%"> <div class="title">starter</div> <div class="monthly">partner discount</div> <ul> <div class="servicerr-pricing-packet starter"><span class="original"><span style="font-weight: bold; border-bottom: 0px none; color: rgb(0, 125, 199); font-size: 70px;

Using Float is not working in SQL Server 2008 -

i have sql query select exchangerate, totalamt, exchangerate * totalamt totalamtconvert, round(exchangerate * totalaramt, 0) totalamtround dbo.table my results: exchangerate 22450 totalamt 16593.67 totalamtnoround 372527891.5 totalamtround 372527891 i want totalamtround = 372527892 can me? this reason use should not use float. approximate datatype. use decimal or numeric datatypr declare @exchangerate numeric(22, 6) = 22450, @totalamt numeric(22, 6) = 16593.67, @exchangerate1 float = 22450, @totalamt1 float = 16593.67 select numeric_result = round(@exchangerate * @totalamt, 0), --correct float_result = round(@exchangerate1 * @totalamt1, 0), --incorrect converted_numeric_result= round(cast(@exchangerate1 numeric(22, 6)) * cast(@totalamt1 numeric(22, 6)), 0) --correct when select @exchangerate1 * @totalamt1 gives 37252

C++ OpenGL - Overlay example -

Image
i've opengl application (maze style) need work on possible. problem @ moment following: i've 3 subwindows on main window , working fine. aparently should using 1 subwindow , left side subwindows (smaller ones) should displayed overlay. actual app has following window display: and go this: i've searched internet , far i've found nothing subject. there anywhere can read on how solve this? thank much. you render overlays texture, , render wherever want on screen. gl*framebuffer functions. might this: // create texture render glgentextures(1, &overlay_tex); glbindtexture(gl_texture_2d, overlay_tex); gltexparameteri(gl_texture_2d, gl_texture_wrap_s, gl_repeat); gltexparameteri(gl_texture_2d, gl_texture_wrap_t, gl_repeat); gltexparameteri(gl_texture_2d, gl_texture_min_filter, gl_nearest); gltexparameteri(gl_texture_2d, gl_texture_mag_filter, gl_nearest); // null means reserve texture memory glteximage2d(gl_texture_2d, 0, gl_rgba8, width, heigh

android - Chrome Custom Tabs throwing an error when chrome is not installed : No Activity found to handle Intent -

chrome custom tabs working fine when chrome installed when chrome not installed throwing error customtabsintent.builder intentbuilder = new customtabsintent.builder(); intentbuilder.setshowtitle(true); customtabactivityhelper.opencustomtab(activityy, intentbuilder.build(), uri.parse(link), new webviewfallback()); logcat error info fatal exception: main process: opensource.itspr.recycler, pid: 13114 android.content.activitynotfoundexception: no activity found handle intent { act=android.intent.action.view dat=http://www.google.com/... pkg=com.android.chrome (has extras) } @ android.app.instrumentation.checkstartactivityresult(instrumentation.java:1889) @ android.app.instrumentation.execstartactivity(instrumentation.java:1579) @ android.app.activity.startactivityforresult(activity.java:3921) @ android.app.activity.startactivityforresult(activity.java:3881) @ android.support.v4.app.fragmentactivity.startactivityforresult(fragmentactivity.jav

cloud - PaaS provider for Grails application for production use -

i have application developed grails 2.5.1 , need paas provider deploy production use , must got these options : smtp server application needs send emails preferred have access file system not necessary mysql db able deploy php applications in it. easy deploy application's packages on good customer support some adviced jelastic , unfortunately don't have smtp server , , heroku deploying in little bit hard. any recommendations? sheriff it easy add smtp jelastic. need set smpt server is here . also, how use external smtp server in environment - is here . with reference rest of list jelastic provides: access file system ( ftp/ftps , sftp/fish , webdav , dashboard ) mysql db able deploy php applications in it easy deploy application's packages on ( direct , git/svn , bitbucket ) good customer support (you can choose hoster significant criteria here ). have nice day, jelastic support

linux - Qt 5 c++ how to include a file when the path is masked by another path in INCLUDEPATH? -

in application, i'm trying use own build of icu 54.1, on mint 17.2 (which comes icu 52.1). in application's .pri have: includepath += $${pwd}/third_party/icu/source/common \ $${pwd}/third_party/icu/source/i18n \ $${pwd}/third_party/build/icu/$${build_mode}/common libs += -l$${pwd}/third_party/build/icu/$${build_mode}/lib libs += $${pwd}/third_party/build/icu/$${build_mode}/lib/libicudata.so.54.1 libs += $${pwd}/third_party/build/icu/$${build_mode}/lib/libicui18n.so.54.1 libs += $${pwd}/third_party/build/icu/$${build_mode}/lib/libicuuc.so.54.1 in application code, when #include <unicode/regex.h> qt creator tooltip tells me using unicode/regex.h in /usr/include/x86_64-linux-gnu, mint's version, icu 52.1. want use unicode/regex.h icu 54.1 built, in $${pwd}/third_party/icu/source/i18n. is there way set preference of icu path on of mint's includes? best-practice way #include files build of icu? when u

r - LDA topicmodel, how can I see the terms in the result -

i follow post topic analysis : a gentle introduction topic modeling using r i want view terms, should in ldaout.terms , however, see numbers instead of terms. how view terms? ldaout.terms topic 1 topic 2 topic 3 topic 4 topic 5 topic 6 topic 7 topic 8 topic 9 topic 10 [1,] "38" "85" "4" "79" "29" "43" "13" "81" "70" "39" i find out problem dtm, created dtm dtm <- create_matrix(ss, language="english", removenumbers=true, stemwords=true, weighting=weighttf) problem solved

python - Using dimensionality reduction on matrix -

for supervised learning, matrix size huge result of models agree run it. read pca can reducing dimensionality large extent. below code: def run(command): output = subprocess.check_output(command, shell=true) return output f = open('/users/ya/documents/10percent/vik.txt','r') vocab_temp = f.read().split() f.close() col = len(vocab_temp) print("training column size:") print(col) #dataset = list() row = run('cat '+'/users/ya/documents/10percent/x_true.txt'+" | wc -l").split()[0] print("training row size:") print(row) matrix_tmp = np.zeros((int(row),col), dtype=np.int64) print("train matrix size:") print(matrix_tmp.size) # label_tmp.ndim must equal 1 label_tmp = np.zeros((int(row)), dtype=np.int64) f = open('/users/ya/documents/10percent/x_true.txt','r') count = 0 line in f: line_tmp = line.split() #print(line_tmp) word in line_tmp[0:]: if word not in voca

javascript - How does for loop index ascend the prototype chain? -

Image
say have object person so var person = { firstname: 'default', lastname: 'default', getfullname: function() { return this.firstname + ' ' + this.lastname; } } i make new object john , set prototype of person var john = { firstname: 'john', lastname: 'doe' } john.__proto__ = person; if console.log john , see tree structure so where see getfullname embedded under __proto__ . here comes surprise for (var prop in john) { console.log(prop) } returns even though getfullname 1 level deep, somehow, loop able find it. now, compare to var obj = {a: 1, b: {c:2, d: 3 }} (var prop in obj) {console.log(prop)} which behaves expect, c , d not automagically found loop so how in former case loop traversed deeper in tree dig embedded properties while in latter did not? the for..in loop iterate own enumerable properties, inherited enumerable properties. why seeing getfullname in loop. but in se

android - How to avoid execute some piece of code in oncreateview while clicking back button in fragment -

i developing android application , trying implement drawer layout(slider menu) in project. let me explain project, have 1 recyclerview gridview items can able see our home screen. want display drawer layout on top grid items means recyclerview. display profile photo in drawer layout(slider menu) whenever application open after can swipe , usual can able see our grid items. i did have 1 problem. able display drawer layout(slider menu) fine whenever application open after swipe if click 1 gridview item , enter page , if click back, time drawer layout(slider menu) showing should not show while clicking grid items. have given recyclerview , drawer layout(slider menu) in same xml file reason whenever user click button, recyclerview displaying drawer layout(slider menu) actually if use activity not face problem because in activity, if click button not call oncreate method call onrestart method reason oncreate not execute if click button also. in fragment oncreateview executi

android - CardView animation issue: no initial animation -

there 2 cardview s in recyclerview in framelayout . 1 cardview has android:visibility="gone" setting on it. when tapped, card flips 360 degrees, revealing 'gone' cardview . tapping again flips it, showing initial card. sounds simple now. used objectanimator class this, so: public static void flipview(view viewtoflip, int direction) { objectanimator flipanimator; if (direction == clockwise) { flipanimator = objectanimator.offloat(viewtoflip, "rotationy", 0f, 360f); flipanimator.setduration(3500); flipanimator.start(); } else { flipanimator = objectanimator.offloat(viewtoflip, "rotationy", 360f, 0f); flipanimator.setduration(3500); flipanimator.start(); } } the issue when cardview shows initially , animation does not work, in there no flip. card gets replaced 'gone' card sans animation. on subsequent taps, animation works beautifully. questions are:

neural network - python code does not generate any output -

i tried run code in http://sourceforge.net/projects/triangleinequal/files/machine%20learning/nn.py/download it run without error.. not generate output. how can output graph? please help the code not meant produce "output" text. prepares plot never shows it. add end of test_regression : plt.show() and execute test_regression uncommented

java - .getClassLoader().getResourceAsStream(path) caches result -

i load file @ servlet, use .getclassloader().getresourceasstream(path), path in web-inf/classes dir, found after changed path file content, file servlet loads same, don't change, file cached. example code: this method gets same result every time, after change test.key content private string getkey(string param){ string name = "keys/"+param+"/test.key"; inputstream in = xxxservlet.class.getclassloader().getresourceasstream(name); stringbuilder builder = new stringbuilder(); try { bufferedreader reader = new bufferedreader(new inputstreamreader(in)); string line = null; while((line = reader.readline()) != null){ builder.append(line).append("\n"); } } catch (ioexception ignoreexception) { }finally{ try { in.close(); } catch (ioexception e) { e.printstacktrace(); } } string result = builder.tostring(); return result; }

node.js - exit status 255 : Crashed in liberty java web application in IBM Bluemix -

i'm working on web application using node.js , liberty java runtime in ibm bluemix. i'm using ibm devops service edit code. after creating default website, wanted change layout of webpage. added new html files , css along js in webapp folder click here :this image of project has files i'm facing click here problem while deploying , running website in ibm bluemix.... it understand you're trying accomplish. appears you're running node.js app on liberty runtime. believe node.js , liberty apps need run on own runtimes.

Debugging solr rss DataImportHandler -

i have existing collection, want add rss importer. i've copied gleam example-dih/solr/rss code. the details below, bottom line seems run, says "fetched: 0" (and no documents). there no exceptions in tomcat log. questions: is there way turn debugging on rss importers? can see solr's actual request , response? what cause request succeed, no rows fetched? is there tutorial adding rss dih existing collection? thanks! my solrconfig.xml file contains requesthandler: <requesthandler name="/dataimport" class="org.apache.solr.handler.dataimport.dataimporthandler"> <lst name="defaults"> <str name="config">rss-data-config.xml</str> </lst> </requesthandler> and rss-data-config.xml: <dataconfig> <datasource type="urldatasource" /> <document> <entity name="slashdot" pk="link&quo

android - how to parse this json formate using Gson lib -

how parse sub array getstring("sub") using gson lib in android. <pre> { "name" : "abc"; "class" : "xyz"; "address" : {[ "add" : "1"; "sub" :["abc"]; ]} } </pre> first of should reduce json correct form: { "name" : "abc", "class" : "xyz", "address" : [ {"add" : "1", "sub" :["abc"]} ] } now, create objects following structure: class foo{ string name; string class; address[] address; } class address{ string add; string[] sub; } and on step can parse json object, calling line: foo foo = new gson().fromjson(json, foo.class);

c++ - how to change cstring to unicode -

i working in vc++ 6. , have cstring content. how change content unicode ? exmaple, have defined cstring strname; strname have content in it(may chinese character in it). and defined: unicode* chinese_character; how transfer content of strname chinese_character ? note working in vc++ 6. thanks. after googling find useful function mbstowcs() used convert multibyte string wide-character string. below example this. { wchar_t buf[255]; mbstowcs(buf,(const char*)name,name.getlength()+1); byte bytes[255]; size_t length = wcslen(buf); (size_t = 0; < length; i++) { bytes[i*2] = buf[i] >> 8; bytes[i*2+1] = buf[i] & 0xff; } }

icalendar - iCal (ics) package for Python -

is there kind of ical (ics) package python more "official" others? i need generate .ics calendars easiest way possible. this one mature , actively developed. here's github .

xslt - WiX - Copy compiled web.config based on environment to website root -

as part of wix installation, copying transformed/compiled web.config files install directory. names of compiled web.config in format web.{env}.config. in install ui created custom dialog parse env , populate combobox user can select environment deploy to. combobox sets property env. i need understand how use property copy installed config files website root. update: @rob_mensching - solution works, however, on compilation wix forces me have guid created each such component. there way avoid it? thing going generate piece of code running xslt on wxs file gets generated using heat; , there no way generate guid using xslt (or can i?) this how code looks now: <componentgroup id='web.config' directory='configlocation'> <component id='copywebconfigfordev1' guid='{f207c26a-5d9c-4f19-96a3-d818bb226efc}' > <condition>env="dev1"</condition> <copyfile id='copydev1config' fileid='fil9c4cfe42035f1a

Mybatis collection with multiple columns -

i have table has 3 foreign keys items. these corresponding objects want in list property. have following collection mapping <collection property="items" column="{item1id, item2id, item3id}"> <association property="examplenesteditem" column="{id, ###itemid###}" select="com.example.mapper.getitem" /> </collection> i need current value @ ###itemid###. how can reference columns "item1id", "item2id" , "item3id" parameter? i ended easy solution. in case know there 3 elements in list. added setter each element in model class this public void setelement1(element element) { elements.add(element); } ... and added association each element <association property="element1" column="element1id" select="com.example.mapper.getitemwithid"/> ... it sure not scale many elements, case fits!

python - How to use a labelled column in sqlalchemy filter? -

i want use labelled column in sqlalchemy filter. eg: db.session.query( partmaster.name, partmaster.description, parttracker.actual_length, func.sum(parttracker.quantity).label('quantity') ).join(parttracker).group_by( parttracker.part_master_id,parttracker.actual_length ).all() i need result quantity > 0 . please advice in sql if want filter rows result, need use having instructions. so in case: db.session.query( partmaster.name, partmaster.description, parttracker.actual_length, func.sum(parttracker.quantity).label('quantity') ).join(parttracker).group_by( parttracker.part_master_id,parttracker.actual_length ).having( func.sum(parttracker.quantity) > 0 ) example doc

objective c - Score system in Cocos2d project -

i have game user collects different types of objects , label has value of 0 @ start. every time user collects object (by touching it) should make score = current score + 1; have tried following code crashes when click on object. this code score label puts 0 on screen: score = 0; scorelabel1 = [cclabelttf labelwithstring:@"0" fontname:@"times new roman" fontsize:33]; scorelabel1.position = ccp(240, 160); [self addchild:scorelabel1 z:1]; and void function call every time touch object: - (void) addscore { score = score + 1; [scorelabel1 setstring:[nsstring stringwithformat:@"%@", score]]; } and actual part put code touching object: -(void) cctouchesbegan:(nsset *)touches withevent:(uievent *)event { [self cctouchesmoved:touches withevent:event]; uitouch *touch = [touches anyobject]; cgpoint location = [touch locationinview:[touch view]]; location = [[ccdirector shareddirector] converttogl:location]; (apple in self.applearray) {

Stop setInterval call in JavaScript -

i using setinterval(fname, 10000); call function every 10 seconds in javascript. possible stop calling on event? i want user able stop repeated refresh of data. setinterval() returns interval id, can pass clearinterval() : var refreshintervalid = setinterval(fname, 10000); /* later */ clearinterval(refreshintervalid); see docs setinterval() , clearinterval() .

jsf - p:commandButton breaks after prettyfaces integration -

i have xhtml-form, should submitted after clicking p:commanbutton . button looks this: <p:commandbutton value="#{msg['formsubmit']}" ajax="false" action="#{quote.submit}" icon="ui-icon-check" /> after integrating prettyfaces button doesn't work anymore. method on bean named quote doesn't invoked. had html-output, couldn't see differences between before- , after prettyfaces-html. tested same code when removing specific pretty-faces-mapping. works fine ... i use prettyfaces url-mapping: <url-mapping id="quote"> <pattern value="/quote" /> <view-id value="/sendquote.jsf" /> </url-mapping> i use: primefaces 5.2 jsf 2.2 (mojarra) prettyfaces-jsf2-3.3.3 tomcat 8.0 ... tried rewrite 3.00 -> same result any suggestions? in advance

google chrome - My extension's "Local Extension Settings" Logfile gets too big -

i wrote chrome extension view later: click a user reported, there log file gets way big (his around 3.8gb) located @ c:\users\<your_username>\appdata\local\google\chrome\user data\default\local extension settings\hnolaplfoobcmgfmjphkmbjolinelpkb . i checked @ machine , big (~300mb). not know causing this. use chrome.storage heavily in extension (all url's saved there) not know how can big, limit 512 entries knowledge. anyone got clues on this? thanks! it looks favicons saved urls via http://www.google.com/s2/favicons?domain_url= service, convert them base64, , store in local storage. might cause problem. instead, may try not save them, load http://www.google.com/s2/favicons every time user opens popup.

windows - Compiler error for std::string in c++ builder XE3 project -

i working on service application in c++ builder xe3. getting compiler error std::string if add line: string = string("abcd") + "xyz"; error output follows: [bcc32 error] string(141): e2285 not find match 'move<_ty>(string)' full parser context string(140): decision instantiate: string std::string + <char,char_traits<char>,allocator<char> >(string &&,const char *) --- resetting parser context instantiation... svcmain.cpp(21): #include c:\program files\embarcadero\rad studio\10.0\include\boost_1_39\boost\tr1\tr1\string string(20): #include c:\program files\embarcadero\rad studio\10.0\include\../include/dinkumware/string string(7): namespace std string(140): parsing: string std::string + <char,char_traits<char>,allocator<char> >(string &&,const char *) i tried add #include <utility> above #include <string> still getting same error. instead, if split line 2 follows, compiles

c++ - How to write client and server with TLS encryption in Qt? -

i relatively new qt , have no experience in network programming. trying write minimal tcp-client-server connection tls encryption in qt using qsslsocket class. far established connection between server , client both running on localhost without encryption. tls encryption found example on github: https://github.com/guitek/qt-sslserver , followed given instructions (including openssl installation). nevertheless can not establish connection between client , server (even if set timeout -1). error messages server , client depicted below. can me ? if has complete code examples in qt client , server exchange data via tcp using encryption ssl encryption highly appreciate. working qtcreator running qt 5.5.0 msvc2013 64 bit. launch qt creator. on welcome screen hit "examples" button. @ search box write "ssl". see several working qt examples ssl clients , servers. place start. read this link.

css - how to replace a layout of html web page from a table to using divs -

Image
i've had page layout made via html table in home page. the lay out fine , though reading tables not way go (seo , maybe not that) so need use divs, layout follows (i in rtl lang /style /direction) my question is try , simplify how or give example lay out that and in more detailed explained : i think "my life" simple, when had understand structure of table so, illustration purpose take markup: <table> <tr> <td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td> </tr> </table> here don't need think analyze 2 2 table but when comes divs no results laying them plan know how make simple table me . 2 trying achieve layout via divs (no table involved ) , make work layout cross browser, meaning same @ least 3 main browsers ie8&9 / ff / chrome (only preference) thanks in advance tried hard make template want.i hope it.see layout divis

php - Reddit OAuth2 returning `invalid_grant` from server in production, despite working in local? -

let me preface restating error not occur in either local or online beta environment, in production; despite 3 servers sharing same following environment variables: reddit_username=username reddit_password=pwd reddit_id=id reddit_secret=secret when try request reddit access token in production using method: /** * @internal * * request reddit token * * if client not have current valid oauth2 token, fetch 1 here. set cookie. */ private function requestreddittoken() { $response = $this->client->post(reddit::access_token_url, array( 'query' => [ [ 'client_id' => $this->clientid, 'response_type' => 'code', 'state' => bin2hex(openssl_random_pseudo_bytes(10)), 'redirect_uri' => 'http://localhost/reddit/test.php', 'duration' => 'permanent', 'scope' =>

python - Meterpreter Handler/listener -

i'm cybersecurity students, i'm not cracker, scriptkiddy or this, i'm working on python meterpreter's listener, found normal tcp reverse handler, working cmd reverse tpc (metasploit), no working meterpreter reverse tpc (metasploit)... know why? thanks. #!/usr/bin/python # import python modules socket import * host = '' # '' means bind interfaces port = 4444 # port # create our socket handler s = socket(af_inet, sock_stream) # set when cancel out can reuse port s.setsockopt(sol_socket, so_reuseaddr, 1) # bind interface s.bind((host, port)) # print accepting connections print "listening on 0.0.0.0:%s" % str(port) # listen 10 connection s.listen(10) # accept connections conn, addr = s.accept() # print connected ipaddress print 'connected by', addr # receive initial connection data = conn.recv(1024) # start loop while 1: # enter shell command command = raw_input("enter shell command or q

bash - Shell script assign variable value to another new variable -

i need small correction below code. trying assign variable value variable, it's not working. please me. below script. #!/bin/sh choice=1 val1="test" if [ "$choice" == 1 ]; echo "insode" echo $choice purpose=$val1 echo "*" echo $purpose fi please me, i'm new shell scripting. need display purpose value test. you assign value val1 : val1="test" but later assign $val1 purpose : purpose=$val1 you have fix case variable names match (fix lowercase l uppercase l ).

MySQL Count totals by year and month and Calcul Cumulative count -

i need optimize sql request. i have table looks this: id,resgier_date,action 1,'2011-01-01 04:28:21','signup' 2,'2011-01-05 04:28:21','signup' 3,'2011-02-02 04:28:21','signup' how select , group these output is: year,month,total,cumulative_sum 2011,1,2,2 2011,2,1,3 i like, 1 request, add, 1 column cumulative of count(id). i try request : select year(register_date), count( * ), @running_total := @running_total + count( * ) cumulative_sum mytable t join (select @running_total := 0) r group year(register_date) limit 0 , 30 with no success thank(s help try select year, month, total, @rt := @rt + total cumulative_sum ( select year(register_date) year, month(register_date) month, count(*) total mytable group year(register_date), month(register_date) limit 0, 30 ) n, (select @rt := 0) r output |

email - PHPMailer hosting site using 123-reg -

basically i'm hosting site on 123-reg , have contact form on site want people send me emails live.co.uk email address, using basic php mail() found emails going junk folder rather go inbox told use phpmailer looking phpmailer code asks smtp i'm lost i'm not sure should putting host username , password want website send emails given email address , advice on should putting , why great thank you you don't need use smtp - can use local mail server , call ismail() instead of issmtp() - though don't need since it's default. in examples folder provided phpmailer, @ 1 called mail.phps .

oracle11g - Oracle regular expression using hyphen in pattern -

why query returning value 4 (i expected 0)? select regexp_instr ('123abc','[a-z]') dual; i think [] should indicate character list, , a-z includes upper letters? this affected session's nls_sort setting , , result of 4 if have case-insensitive sorting enabled: alter session set nls_sort=binary; select regexp_instr ('123abc','[a-z]') dual; regexp_instr('123abc','[a-z]') ------------------------------ 0 alter session set nls_sort=binary_ci; select regexp_instr ('123abc','[a-z]') dual; regexp_instr('123abc','[a-z]') ------------------------------ 4 you can read more in documentation ; , may find this answer useful too.

website - Android 4.4 and Above - WebView Cannot call determinedVisibility() - never saw a connection for the pid -

when try loadurl("convert2mp3.net") , nothing happens , logcat (in eclipse) says: "w/cr.bindingmanager(31239): cannot call determinedvisibility() - never saw connection pid" in forums, people suggests use setdatabaseenabled(true); not working. this problem occurs on android 4.4 , above.

database - mysql table design, divide or all in one table? -

i have table house create table `house` `idhouse` int(11) not null auto_increment, `type` mediumint(2) default null, `address` varchar(5) default null, `county` varchar(5) ... now, have ads functionality. want bring house ads method 1 (directly add columns adds) create table `house` `idhouse` int(11) not null auto_increment, `type` mediumint(2) default null, `address` varchar(5) default null, `county` varchar(5) ... `ad_type` mediumint(2) default null, `ad_urgency` int(11) default null, `ad_status` int(11) default null, method 2 (normalization, split table ads) create table `house` `idhouse` int(11) not null auto_increment, `type` mediumint(2) default null, `address` varchar(5) default null, `county` varchar(5) ... create table `ads` `idads` int(11) not null auto_increment, `idhouse` int(11) not null auto_increment, `ad_type` mediumint(2) default null, `ad_urgency` int(11) default null, `ad_

Force maven update -

i imported working project on other computer started download dependencies. apparently in meantime internet connection crashed. get: build errors comics; org.apache.maven.lifecycle.lifecycleexecutionexception: failed execute goal on project comicstest: not resolve dependencies project comicstest:comicstest:war:0.0.1-snapshot: following artifacts not resolved: org.springframework:spring-context:jar:3.0.5.release, org.hibernate:hibernate-entitymanager:jar:3.6.0.final, org.hibernate:hibernate-core:jar:3.6.0.final, org.hibernate:hibernate-commons-annotations:jar:3.2.0.final, org.aspectj:aspectjweaver:jar:1.6.8, commons-lang:commons-lang:jar:2.5, mysql:mysql-connector-java:jar:5.1.13: failure transfer org.springframework:spring-context:jar:3.0.5.release http://repo1.maven.org/maven2 cached in local repository, resolution not reattempted until update interval of central has elapsed or updates forced. original error: not transfer artifact org.springfra

PHP errors in a new MAMP -

i download absolutely new, last version of mamp 3.5. i go phpinfo , says php version 7.0.0 , configuration file ( php.ini ) path is: /applications/mamp/bin/php/php7.0.0/conf . i go php.ini in path , change errors on: display_errors = on . check that: error_reporting = e_all . i stop servers , start servers. reload page in browser. check phpinfo , display_errors on. i not see errors. i have checked solutions in web, name few: mamp config help, display php errors why mamp doesn't display errors? how display errors on mamp? i tried , not see php errors. else can do? preface php code this. force error display. ini_set('display_errors', 'on'); error_reporting(e_all); also check .ini files in following locations: applications/mamp/bin/php/(php version)/conf/php.ini applications/mamp/conf/php/(php version)/conf/php.ini they should both set for: display_errors = on edit: should clarify this, may point of confusion:

authentication - laravel 4 logout after loginning directly? -

i try login email , password auth::attempt success login when redirect link after login logout , on localhost things when upload project on host problem occured login function public function login(){ $validator=validator::make(input::all(),array( 'email' => 'email|required', 'password' => 'required' )); if($validator->fails()){ $messages = $validator->messages(); $msg=''; foreach ($messages->all() $message) { $msg .= "<li>".$message."</li><br />"; } return $msg; } else{ $email = input::get('email'); $password = input::get('password'); $user=auth::attempt(array(

pointers - C - pthread segmentation fault 11 -

i'm creating thread , passing pointer it. when cast pointer should (int*) have segmentation fault. int *ptr = (int *)ptrtotal2; here code : void *firstcalc(void *ptrtotal2){ int vala = 1; int valb = 2; int *ptr = (int *)ptrtotal2; *ptr = vala + valb; printf("value of vala = %d\nvalue of valb = %d\n", vala, valb); printf("value of subtotal *ptrtotal1 = %d\n", *ptr); pthread_exit(null); } int main(int argc, char **argv) { pthread_t thread1; int *ptrtotal2 = 0; int iret1; iret1 = pthread_create(&thread1, null, firstcalc, (void*) ptrtotal2); if(iret1){ fprintf(stderr,"error - pthread_create() return code: %d\n",iret1); exit(exit_failure); } pthread_join( thread1, null); exit(exit_success); } dereferencing ptr in function firstcalc , when original pointer set 0, cause undefined behavior, in case segmentation fault. int *ptr = (int *)ptrtotal2; *ptr = vala + valb; ... int *ptrtotal2 = 0;

input - Change a Text with Javascript -

i want chance text javascript use following code: <!doctype html public "-//w3c//dtd html 4.01 transitional//en"> <html><head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>test</title> <script type="text/javascript"> var neu = document.getelementbyid("thema")[0].value; function aendern () { document.all.meinabsatz.innerhtml = neu; } </script> </head><body> <p id="meinabsatz">text</p> <input id="thema" type="text" value="test theme" /> <a href="javascript:aendern()">chance theme</a> </body> </html> if click on "chance theme" "text" chance "undefined" method getelementbyid() returns single element, not set of elements. there no need in applying [0] it. should put neu initialization inside aendern() func

html - Expand <li> so it fits the width of <ul> -

before post duplicate, isn't - other threads provide instructions on how make horizontal <li> fit width of <ul> - question how make vertical <li> fit width of <ul> . below code: css .ul { background: #fff; padding: 12px !important; font-size: 0; width: 125px; } .li { margin-bottom: 16px !important; } .li { font-weight: 300 !important; font-size: 22px !important; } html <ul> <li> <a href="#">hats</a> </li> currently, can click li end of text, want option select throughout complete width of ul . to expand comment... you wanted find way <li> element fit width of it's <ul> element. <li> element already is full widht of it's parent element (except default padding, can overriden). this due fact <li> default block element. , block elements take full width of parent. problem <a> element, default inline element, doesn

c# - How can I save button which was dynamically created -

the following code dynamically creates button @ run time in windows forms c#. after closing / opening program button disappears (not saved). think button properties saved in designer.cs (if correct) not know how save there. knows how can save button has been dynamically created? thank private void button1_click(object sender, eventargs e) { // create button object button dynamicbutton = new button(); // set button properties dynamicbutton.height = 40; dynamicbutton.width = 300; dynamicbutton.backcolor = color.red; dynamicbutton.forecolor = color.blue; dynamicbutton.location = new point(20, 150); dynamicbutton.text = "i dynamic button"; dynamicbutton.name = "dynamicbutton"; dynamicbutton.font = new font("georgia", 16); dynamicbutton.click += new eventhandler(dynamicbutton_click); controls.add(dynamicbutton); } if create butt

not able to convert JSON string to javascript object -

var jsonobj='[{"rmanumber":null,"orderreferencenumber":"referene45","orderstatus":"pending","daterequested":null,"dateapproved":null,"segateaddress":null,"billingaddress":null,"shippingaddress":null,"returnforcredit":{"requested":null,"received":null,"shipped":35,"credited":45,"invoiceamount":null},"returnforexchange":{"requested":null,"received":null,"shipped":35,"credited":45,"invoiceamount":null},"totals":null}]' var parsedjson = eval('(\'+jsonobj+\')'); var result=parsedjson.result; var count=parsedjson.count; alert('result:'+result+' count:'+count); in alert giving undefined :undefined 1st thing : var parsedjson = eval('(\'+jsonobj+\')'); should var parsed

how to find tail of a file using c code -

i wrote code find tail, but, has 1 exception, when trying print whole lines tail, not print starting character. e.g. if file having 14 lines, , value of n entered 14, not print starting character. please modify code: #include <stdio.h> #include <stdlib.h> int main(int argc,char *argv[]) { file *in, *out; int count = 0,lines; long int pos; char s[100]; char ch,c; if(argc<2) { printf("arguments passed should 2"); } else if(argc>2) { printf("too many argumnets passed"); } in = fopen("anj.txt", "r"); out = fopen("output.txt", "w"); if(in==null || out==null) { printf("unable open"); exit(0); } else { int n=atoi(argv[1]); if(n>=1) { fseek(in, 0, seek_end); pos = ftell(in); while (pos) { fseek(in, --pos, s

javascript - Read a file using HTTP in Node.JS -

in dev-environment prefer read data file instead actual api because of performance reason. i tried this: var path = process.env.node_env === 'production' ? '/pathtoexternalapi...' : process.env.pwd + '/assets/mockdata.json'; http.get(path, function (resfromapi, err) { var body = ''; resfromapi.on('data', function (chunk) { //console.log(chunk); body += chunk; }); resfromapi.on('end', function () { //console.log(resfromapi.statuscode + ' path:' + path); if (resfromapi.statuscode === 200) { cb(json.parse(body)); } else { cb(null, 'statuscode: ' + resfromapi.statuscode); } }); }) i 404 when try run against file. i've checked path correct. cant use http.get() when fetch data file? how do instead? no, can not directly use http.get(file_path) . have static web server serving files via http, seems nonsense. i proceed that: if(process.env.node_env ===

java - Error converting result HttpPost android -

i've been working on app pulls json string server. access json need post key , secret. else error saying key and/or secret missing. my jsonfunctions.java package com.spxc.ssa.streaming.task; import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstream; import java.io.inputstreamreader; import java.util.arraylist; import java.util.hashmap; import java.util.list; import org.apache.http.httpentity; import org.apache.http.httpresponse; import org.apache.http.namevaluepair; import org.apache.http.client.clientprotocolexception; import org.apache.http.client.httpclient; import org.apache.http.client.entity.urlencodedformentity; import org.apache.http.client.methods.httpget; import org.apache.http.client.methods.httppost; import org.apache.http.entity.stringentity; import org.apache.http.impl.client.defaulthttpclient; import org.apache.http.message.basicnamevaluepair; import org.json.jsonarray; import org.json.jsonexception; import org.json.jsonobject;