Posts

Showing posts from 2011

ios - How to lock orientation just for one view controller? -

can set portrait orientation , lock orientation in 1 controller? i did try: override func supportedinterfaceorientations() -> int { return int(uiinterfaceorientationmask.portrait.rawvalue) } override func shouldautorotate() -> bool{ return false } but doesn't me. must add else? this code should work: override func supportedinterfaceorientations() -> int { return int(uiinterfaceorientationmask.portrait.rawvalue) } override func shouldautorotate() -> bool{ return false } override func preferredinterfaceorientationforpresentation() -> uiinterfaceorientation { return uiinterfaceorientation.portrait } if working you, suppose controller in controller( uinavigationcontroller , uitabbarcontroller , uisplitviewcontroller ). in case need use code in parent controller. if navigation controller contain more 1 view controller, , need disable orientation of them, need inherit uinavigationcontroller

python - Check if user is asked for a password during ssh -

i want know if there's way in python can detect if user asked password when connecting sftp using ssh, able ignore connecting? thanks. i not aware such thing possible python; anyway wouldn't recommend involving checking password interactive prompts if try filter subprocess pipes (in case calling sftp popen). if goal prevent password authentication may call sftp passwordauthentication=no , preferredauthentications=publickey this: sftp -o passwordauthentication=no -o preferredauthentications=publickey host in way should fail if password required.

C# Interface, Unity, and Optional Parameter -

hopefully can shed light on one. have interface optional parameter. use unity. if try change optional parameter in method implementation, works directly, unity object uses interface's default - not implemented method's default. setup: public interface itestoptional { string happymethod(string input, bool amhappy = false); } public class testingoptional : itestoptional { public string happymethod(string input, bool amhappy = true) { if (amhappy) return input + " happy!"; return input + " not happy!"; } } add unity: container.registertype<itestoptional, testingoptional>(); and test: //direct call var testdirect = new testingoptional(); string happydirect = testdirect.happymethod("cow", true); //expecting happy - happy string saddirect = testdirect.happymethod("cow", false); //expecting not happy - not happy string defaultdirect = testdirect.happymethod("cow

json - PHP array to an Array of Objects -

how convert array array of objects php ? input [1, 2, 3] output [ {id:1}, {id:2}, {id:3} ] if defined object before, guess i'd loop class previouslydefinedobject{ public $id; } $myarray = array(1,2,3); $newarray = array(); foreach($myarray $id){ $obj = new previouslydefinedobject(); $obj->id = $id; array_push($newarray, $obj); } print_r($newarray); that way, $newarray contains every object in array

ESB Mediation by Example -

i'm trying understand esb mediation is, (concrete examples), , hitting mental wall. according wikipedia, data mediation redirects data transformation article, mention of mediation vague , mysterious: when data mapping indirect via mediating data model, process called data mediation . so ask: mediation (in context of esbs) , concrete examples of mediation in action? to me, term mediation used in general sense in case , refers functions of esb enable mediate between multiple ( often heterogenous ) systems , exposed services. esb middleware, technical backbone helps integration , used when building soa enterprise. if @ functions column, next mediation in table, give context. says - adapters, protocol transformation, service mapping . i'll bit each of terms in table , hope understand context. adapters in heterogeneous environment you'll have great diversity of systems, built , bought in different eras, maintained separate teams, owned different

javascript - Do DOM tree elements with ids become global variables? -

working on idea simple htmlelement wrapper stumbled upon following internet explorer , chrome : for given htmlelement id in dom tree, possible retrieve div using id variable name. div like <div id="example">some text</div> in internet explorer 8 , chrome can do: alert(example.innerhtml); //=> 'some text' or alert(window['example'].innerhtml); //=> 'some text' so, mean every element in dom tree converted variable in global namespace? , mean 1 can use replacement getelementbyid method in these browsers? what supposed happen ‘named elements’ added apparent properties of document object. bad idea, allows element names clash real properties of document . ie made situation worse adding named elements properties of window object. doubly bad in have avoid naming elements after member of either document or window object (or other library code in project) might want use. it means these elements visible glob

jquery - Nestable tree does not work in a modal ui- bootstrap using the < script> < / script> -

i try display tree in modal nestable ui- bootstrap , select - + not pop , not work when injected between ui modal -bootstrap ( jquery.nestable.js ) how can solve problem ! <script type="text/ng-template" id="mymodalcontent.html"> <div class="dd" id="nestable"> <ol class="dd-list"> <li class="dd-item" class="dd-item" data-id="1"> <div class="dd-handle">entretien</div> <ol class="dd-list"> <li class="dd-item" data-id="1"> <div class="dd-handle" ng-click="setselectedsegment(valsegment)">lessives</div> </li> <li class="dd-item" data-id="1"> <div class="dd-handle" ng-click="

sql - Invalid character Exception when adding multiple parameters to NativeQuery -

i use jdbc , want create nativequery 2 parameters, 1 of them string , other 1 int . when try this: import javax.persistence.entitymanager; ... private final entitymanager entitymanager; .... string columnname = "examplename"; int columnnumber = 5; entitymanager.createnativequery("select c.table_name, c.tcl_number col_name c c.table_name " + "like ?1 , c.tcl_number ?2;") .setparameter(1, columnname) .setparameter(2, columnnumber) .getsingleresult(); i java.sql.sqlsyntaxerrorexception: ora-00911: invalid character exception. sql: create table col_name ( table_name varchar2(50 byte), table_number number(10,0) ); do have consider special when want set int parameter? as found out problem in query comes ?1 , ?2 . compiled like: select c.table_name, c.tcl_number col_name c c.table_name 'val1'1 , c.tcl_number 'val2'2 whi

ruby - TCP tunneling through Linux tap device -

i've created tap0 device (ip 10.0.0.101), , using zeromq's pgm pub/sub (e.g. pgm://192.168.100.2;234.5.6.7:5555) transport ethernet frames tap zmq subscribers , vice versa. idea create virtual network using pgm. have 2 tap hosts on network: 10.0.0.101, 10.0.0.11. have physical ethernet adapters @ 192.168.106.126, 192.168.106.55. 'the problem ping works, http , ssh protocols not. wireshark shows successful tcp startup sequence, start see duplicate acks, retransmissions, , curl , ssh hang while , error out. a snippet wireshark below, followed of (hopefully) relevant ruby source code. using rb_tuntap , ffi-rzmq gems. no. time source destination protocol length info 7 11:41:45.464867000 10.0.0.11 10.0.0.101 tcp 74 51659 > 3000 [syn] seq=0 win=14600 len=0 mss=1460 sack_perm=1 tsval=1953042 tsecr=0 ws=64 frame 7: 74 bytes on wire (592 bits), 74 bytes captured (592 bits) on interface

MySQL Subquery related to LEFT JOINS -

Image
i given task of extracting customer information database , stuck on last part! hope explanation sufficient describe problem , attempts. goal: return 1 row per customer phone number the problem: each customer may have many phone numbers attempts: subquery: getting "subquery returning more 1 row" error. makes sense me cannot insert statement per customer select customer.name, address.street, address.city, address.state, address.zip, customer.contact, email.address, customer.ctype, (select telephone.number customer left join customertelephone on customer.customerid = customertelephone.customerid left join telephone on customertelephone.telephoneid = telephone.telephoneid telephone.type = "main") mainphone `customer` left join customeraddress on customer.customerid = customeraddress.customerid left join address on customeraddress.addressid = address.addressid left join customeremail on customer.customerid = customeremail.customerid left

r - Generating a histogram and density plot from binned data -

i've binned data , have dataframe consists of 2 columns, 1 specifies bin range , specifies frequency this:- > head(data) binrange frequency 1 (0,0.025] 88 2 (0.025,0.05] 72 3 (0.05,0.075] 92 4 (0.075,0.1] 38 5 (0.1,0.125] 20 6 (0.125,0.15] 16 i want plot histogram , density plot using can't seem find way of doing without having generate new bins etc. using solution here tried following:- p <- ggplot(data, aes(x= binrange, y=frequency)) + geom_histogram(stat="identity") but crashes. know of how deal this? thank you the problem ggplot doesnt understand data way input it, need reshape (i not regex-master, surely there better ways is): df <- read.table(header = true, text = " binrange frequency 1 (0,0.025] 88 2 (0.025,0.05] 72 3 (0.05,0.075] 92 4 (0.075,0.1] 38 5 (0.1,0.125] 20 6 (0.125,0.15] 16") library(string

python - Scapy layer for MPEG2-TS, with conditionalField for adaptation -

i try create mpeg2-ts layer scapy. i need "add" , parse additional fields based on adaptation field. here code: _adapt_type = { 0x0 : 'reserved', 0x1 : 'payload only', 0x2 : 'adaptation only', 0x3 : 'adaptation , payload', } class mpeg2_ts(packet): name = "mpeg2-ts" fields_desc=[ byteenumfield('sync_byte', 0x47, _sync_type), bitfield('trans_err',0x0, 1), # transport error indicator (tei) if set 1 decoder ignore packet bitfield('start_ind',0x0, 1), bitfield('trans_pri',0x0, 1), xbitfield('pid', 0xa, 13), bitenumfield('trans_scramb', 0x0, 2, _scramble_type), bitenumfield('adapt_ctrl', 0x0, 2, _adapt_type), bitfield('cont_count', 0x0, 4), ] i need parse additional data if adapt_ctrl set to: 0x1 : 'payload only', 0x2 : 'a

php - How can I split list of website -

i have list of site : $list_website = "http://www.stackoverflow.com;http://www.yahoo.com http://www.facebook.com http://www.youtube.com www.google.com"; i want this array("http://www.stackoverflow.com", "http://www.yahoo.com", "http://www.facebook.com", "http://www.youtube.com", "www.google.com"); i tired : $txt1 = explode(';\n ',$list_website); but doesn't wotk. thanks advance ! you can use preg_split $list_website = preg_split("/[\n ;]+/", trim($list_website));

ajax - File download in Angular and JWT -

tl;dr how download/save file using angular , jwt authentication without leaving token trail in browser? my angular/node app secured on https , uses jwt authentication. jwt stored in sessionstorage , passed in authorization header field ajax requests server. i need functionality in app download file it's automatically saved browser (or popup displayed save etc.). it should work ideally in browser can run angular. i have looked @ following: ajax requests . doesn't work because of inherent security measures preventing browser saving file locally. pass jwt in cookie - cookies want avoid using, hence reason using sessionstorage. pass jwt in query string means logged in server logs, , more importantly can seen in browser history. iframe contains form posts data . can't set header method. any other options? the iframe method close. need set server accept jwt body of post rather query string. it's not elegant solution having use iframe

java - Servlet returns text and not HTML -

$(document).ready(function() { $.get('navigation', function(responsetext) { $('#navi').text(responsetext); }); }); i calling servlet named 'navigation' in order result in div id 'navi'. servlet works fine. code in div shown text , not rendered html-code. edit: public void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { response.setcontenttype("text/html"); response.setcharacterencoding("utf-8"); printwriter out = response.getwriter(); dao = new webshopdao(); kategorien = dao.gibkategorien(); out.println("<ul>"); (katalog k1 : kategorien) { integer oberkat = k1.getoberkategorienr(); if (oberkat == 0) { out.println("<li class='has-sub'><a>" + k1.getkname() + "</a>\n");

matlab - Alternatives to `clear(function_name)` to remove function from RAM? -

as stated in matlab's faq , 1.3.3.1. why, when edit function file in matlab, change not seen matlab until cleared or matlab restarted? when write m-file in matlab, can either write script or function. difference script read disk , parsed line line each time called. function loaded ram execution. because loaded ram, when edit function, change not loaded ram until call new function made. to matlab recognize edited function, type clear functions clear functions, or clear <function name> clear function out of ram. this major pain when i'm developing function & editing repeatedly (i use external editor of time). thinking of putting in final line, @ least during debug, like clear(myfunc) but i'm concerned unwanted side effects. know if there any? further, i'd rather have way configure matlab doesn't automatically store called functions in ram once top-level function (i.e. 1 called console) terminates. possible? e

javascript - How do I gracefully load a specific localization file dynamically in AngularJS? -

currently, have system has language codes such en, de, jp , on. need provide localisation 8 languages, works if manually add in script file here: <script src='/js/locale/angular-locale_de.js'></script> . but need able load dynamically in header. tried using jquery hack using ("head").append() on chrome throws error says async request deprecated. you don't have invent wheel, there's module -angular dynamic localization- , it's pretty straight forward: https://github.com/lgalfaso/angular-dynamic-locale and if looking translation, there u go http://angular-translate.github.io/

python - Using a separate function for colormap other than x,y,z for a 3D surface -

Image
i'm generating 3d shape (x1,y1,z1) using code below. separate function, a5 , has been used colormap. of i'm getting blue surface. range of values in z1 higher of a5 - reason behind code generating blue surface? take limit of z1 facecolor? if how should use plot_surface purpose? surf = ax.plot_surface(x1,y1,z1,rstride=1, cstride=1, linewidth=0, facecolors=plt.cm.jet(a5),antialiased=false) m = cm.scalarmappable(cmap=cm.jet) q=[-col,col] m.set_array(q) plt.colorbar(m) import numpy np import matplotlib import matplotlib.pyplot plt mpl_toolkits.mplot3d import axes3d # generating data x, y = np.meshgrid(np.linspace(-1,1,101), np.linspace(-1,1,101)) z = x+y # z plane r = np.sqrt(x*x+y*y) w = 2*np.cos(5*r)**2-np.sin(6*x) # w funny trig func # initializing colormap machinery norm = matplotlib.colors.normalize(vmin=np.min(w),vmax=np.max(w)) c_m = matplotlib.cm.spectral s_m = matplotlib.cm.scalarmappable(cmap=c_m, norm=norm) s_m.set_array([]) # figure , 3d subplot fig

opencv - How to access a file by its path within a shared library plugin with a Unity Android App -

i have written native shared library (.so) in android studio uses opencv cascade classifiers. classifiers have load method requires path file , must called before can used. i can call load method correctly in android studio first placing required files in res/raw directory of project. create file resource in android app uses shared library: inputstream = context.getresources().openrawresource(r.raw.lbpcascade_frontalface); file rsrcdir = context.getdir("rsrc", context.mode_private); file rsrc = new file(rsrcdir, "lbpcascade_frontalface.xml"); fileoutputstream os = new fileoutputstream(rsrc); byte[] buffer = new byte[4096]; int bytesread; while ((bytesread = is.read(buffer)) != -1) { os.write(buffer, 0, bytesread); } is.close(); os.close(); return rsrc; in shared library (c++) can access file following path: /data/data/com.company.product/app_rsrc/lbpcascade_frontalface.xml and works charm. but

javascript - Save info in a form before Post -

i creating registration form uses javascript calculate amount , uses method="post" redirect user paypal complete transaction. piece i'm missing way capture information before sending them off pay. ideally emailing copy of information or saving text file on server. i'm kind of n00b here, while realize it's possible post own php script , have redirect them paypal, i'm not sure i'd able figure out pieces in workflow. there simpler way it? well can save form values database , send paypal need html give appropriate php code.

physics - Summing scalars and vectors [MATLAB] -

first off; i'm not taught in programming, tend learn need learn in order want when programming, have moderate experience python, html/css c , matlab. i've enrolled in physics-simulation course use matlab compute trajectory of 500 particles under influence of 5 force-fields of different magnitude. so thing; need write following i=1...500 particles f_i = m*g - sum{(f_k/r_k^2)*exp((||vec(x)_i - vec(p)_k||^2)/2*r_k^2)(vec(x)_i - vec(p)_k)} i hope not cluttered and here code far; clear close echo off %simulation parameters------------------------------------------- h = 0.01; %time-step h (s) t_0 = 0; %initial time (s) t_f = 3; %final time (s) m = 1; %particle mass (kg) l = 5; %charateristic length (m) nt = t_f/h; %number of time steps g = [0,-9.81]; f = [32 40 28 16 20]; %the force f_k (n) r = [0.3*l 0.2*l 0.4*l 0.5*l 0.3*l]; %the radii r_k p = [-0.2*l 0.8

javascript - Moment-Timezone: Retrieve DST start and end times -

does moment-timezone support (or has been able implement) retrieving start/end times daylight savings time given zone? i'm not looking determine if given date/time in zone within dst, rather actual transition times zone. this doesn't seem supported, thought maybe had been able accomplish this.

math - How to divide two numbers without using division operator? -

i have heard can use bitwise operator divide 2 numbers without use of division operator. how done? answer can in language except assembly language , don't support bitwise operator. maybe help: http://www.stoimen.com/blog/2012/01/05/php-performance-bitwise-division/ basically, instead of dividing, shift bits right

vaadin7 - How to add new Columns to table in Vaadin and how to place a link in vaadin table -

i new vaadin, have created table , can able populate data in through beanitemcontainer, bellow code this. public component getmaincontent(viewchangelistener.viewchangeevent event) { list<executionplanvo> executionplanvos = executionplandelegate.getexecutionplans(getsearchvo()); table table = new table(); beanitemcontainer<executionplanvo> container = new beanitemcontainer<executionplanvo>(executionplanvo.class, executionplanvos); container.addbean(new executionplanvo()); table.setcontainerdatasource(container); table.setvisiblecolumns( new object[] {"billofladingno" , "containerno" , "housebill" , "carrier" , "customer" , "origin" , "pol" , "transshipment" , "pod" , "destination" , "start" , "completion" , "status"}); table.setcolumnheaders

java - How to let user download a pdf file right after he visits a jsp page? -

simple question, i've got pdf generated on page load, subsequently want let user download file. is there way it? show download dialog after pdf created? i've tried this: <%response.setheader("content-disposition", "attachment; filename=\""+filename+"\"");%> but define, file want user download? because code above leads user downloading corrupted empty pdf file. i suggest servlet instead of jsp. have more control on code , less fragile (if handle response content in jsp , have single space or line feed between scriptlets, can written output stream corrupting file content). so have @ fileservlet example , adapt needs.

Java: Sum series logical error- final sum printing for all variables -

i tried write program should printing iterative sums. but current code instead printing final sum each iteration, , can't figure why : package sumseries; public class sumseries { public static void main(string[] args) { system.out.println("i" + "\t\t"+ "m(i)"); system.out.println("==================="); int x=0; for(int i=1;i<=20;i++){ system.out.println( + "\t\t" + series(x) ); } } public static double series(int i){ double sum=0; for(i=0;i<=20;i++){ sum += ((double) i)/(i+1); } return sum; } } what wrong here , how can fix ? in method : public static double series(int i){//the parameter variable double sum=0; for(i=0;i<=20;i++){ // again initialising 0; sum += ((double) i)/(i+1); } return sum; } i have written comments adjoining lines. same sum whatever might pass parameter method.

wordpress - 301 Redirect only Posts not Pages -

i looking redirect posts , not pages , custom post types old domain new domain. posts instance http://www.example.com/post1 should go http://example1.com/post1 http://www.example.com/post1 should go http://example1.com/post1 the pages i.e. http://www.example.com/page1 should still functional i can find alot of answers on moving blog sub directory along moving links not moving posts , not pages edit there on 1000 posts looking dynamic way of doing this thank help the hack end using add ob_start single.php first line before get_header() add following code in functions.php change example.com site domain name add_action('wp_head','redirectme'); function redirectme() { if ('post' === get_post_type()){ wp_redirect( 'http://example.com' . $_server['request_uri'] , 301 ); exit; } }

post - Jekyll Front Matter custom fields in _posts .md (markdown) not available in liquid tag -

i aware can add , use html page custom front matter fields using {{ page.myfield }} directive not work posts (i.e. when iterating site.posts in loop. my problem, have done ... i created new post in _posts .md extension containing new custom front matter fields (it published , refixed correctly date) - seems correct i loop posts using {% post in site.posts %} - works when attempt use these using liquid tag {{ post.mynewfield }} not available show in post.content text not useable field. surely cannot correct. assume in markdown in front matter section should accessible, seems in jekyll front matter instruction http://jekyllrb.com/docs/frontmatter/#custom-variables please help. cause of issue utf-8-dom encoding when should have been utf-8 encoding .md files

sockets - c# Bitmap is already locked screenshots -

im trying make program takes screen shots , compare them. this sample of code compare method: [dllimport("msvcrt.dll", callingconvention = callingconvention.cdecl)] static extern int memcmp(intptr b1, intptr b2, uintptr count); public bool comparememcmp(bitmap b1, bitmap b2) { if ((b1 == null) != (b2== null)) return false; // if (b1.size != b2.size) return false; var bd1 = b1.lockbits(new rectangle(new point(0, 0), b1.size), imagelockmode.readonly, pixelformat.format32bppargb); var bd2 = b2.lockbits(new rectangle(new point(0, 0), b2.size), imagelockmode.readonly, pixelformat.format32bppargb); intptr bd1scan0 = bd1.scan0; intptr bd2scan0 = bd2.scan0; int stride = bd1.stride; int len = stride * b1.height; return memcmp(bd1scan0, bd2scan0, (uintptr)(len)) == 0; } thisis main code: private void mainform_load(object sender, eventargs e)

java - How to append a class-path entry to the Manifest? -

my gradle build creates manifest files including *.jar files contained in lib/ . i'd add lib directory classpath, lib/log4j.properties grabbed @ runtime myapp . how can append 'class-path' below? jar { manifest { attributes 'implementation-title': 'myapp', 'implementation-version': version, 'class-path': configurations.runtime.files.collect { it.name }.join(' lib/'), 'main-class': 'ca.company.product.myapp.application', 'built-by': system.getproperty('user.name'), 'built-jdk': system.getproperty('java.version') } } i've looked in gradle doc, not dug yet gravy. i've overlooked questions on or gradle forum. i found out variables can concatenated in regular java. following build.gradle worked me: jar { manifest { attributes 'implementation-title': 'myapp', 'implementation-version': versi

sql - How to select MAX value in field based on another field -

i have query (oracle query returning results linked server sql table) returns results this: - personid | encounterno | location ---------+-------------+----------- 123456 | 1 | london 123456 | 2 | manchester 123456 | 3 | glasgow 246810 | 1 | liverpool 246810 | 2 | newcastle 357911 | 1 | edinburgh 357911 | 2 | aberdeen 357911 | 3 | dublin i select max value each personid output be: - personid | encounterno | location ---------+-------------+------------- 123456 | 3 | glasgow 246810 | 2 | newcastle 357911 | 3 | dublin select t.* table t inner join ( select t.personid, max(t.encounterno) table t group t.personid ) j on t1.personid = j.personid , t.encounterno = j.encounterno

mod rewrite - .htaccess add an extra word to add all my URLs -

i need add word right after domain name website urls. lets url http://www.example.com/somecategory/someproduct.html , should http://www.example.com/logado/somecategory/someproduct.html . is possible .htaccess file ? if should add .htaccess file ? you can use code in document_root/.htaccess file: rewriteengine on rewritebase / # prefix each url /logado/ if not present rewritecond %{the_request} !\s/+logado/ [nc] rewriterule ^ logado%{request_uri} [r=302,l,ne] # internally remove /logado/ urls rewriterule ^logado/(.*)$ $1 [l,nc]

c# - Calculating how many of a specific number is in a csv file -

i have csv file has 100,000 iq values in it. iq's range 34-165, there going lot of numbers same. trying write code tell me how many of numbers same. example: there 11 people iq of 49 , 120 people iq of 62. figured easiest use list, i'm beginner , still learning. wondering block of code able calculate that? your problem breaks neatly 2 pieces: reading in csv, , processing results. it easier people of stack overflow if provided little more information csv, or example of code have tried far, can still make attempt have. for reading in csv, start here: https://docs.python.org/2/library/csv.html if csv list of numbers separated commas (120, 62, 37...) simple operation. if has more information (if, example, each line "name, age, gender, iq, country of birth...") require little more work, still doable. i'll start assumption file simple list of numbers, separated commas. so: import csv open('yourfile.csv', 'r') csvfile: reader

java - How to insert multiple index at a time on a solr update using json -

i have refer different related web page getting how can post multiple index solr in single request. have gone through solr link http://wiki.apache.org/solr/updatejson#example link explain feature not clearly. also have found create json this: { "add": {"doc": {"id" : "testdoc1", "title" : "test1"} }, "add": {"doc": {"id" : "testdoc2", "title" : "another test"} } } can solve issue. in case last index updated/inserted index. project java project. please me on this. the json module support using regular json array notation (from 3.2 , forward). if you're adding documents, there no need "add" key either: [ { "id" : "mytestdocument", "title" : "this test" }, { "id" : "mytestdocument2", "title" : "this antoher test" } ]

c# - ASP.NET saving text to database in correct format -

Image
i have asp.net 4.5 text box 5 rows. when save below data table not take in consideration there line breaks. example: hello name mike! how you? please can help? when saving data table of course save below , displayed again if populate website value. hello name mike!how you?please can help? but want displayed line breaks way written in first place. the thing is, not want make use of custom form item because user able copy , paste html website in , not want that. any idea how can done without using plugin such below user able copy , paste data into? to populate text box database try; textbox1.text = sometext.replace("\r\n", environment.newline) for label label1.text = sometext.replace("\r\n", <br />) alternatively save data database sometext = textbox1.text.replace("\r\n", "<br />") although approach may not appropriate if database used elsewhere.

html - PDF Download on website -

so got annoying problem on website. there pdf files people need download, , works , other times don't. peace of code i'm using. <a href="http://www.playersoftomorrow.be/pdf/wedstrijdschemau6.pdf" download="wedstrijdschemau6.pdf">wedstrijdschema u6</a> the map in pdf, filename wedstrijdschemau6.pdf. can watch on http://playersoftomorrow.be/pdffilesopsite.html . question why sometime work , other time not? fault of code, webhost... if you're watching on website, let me know if download links works you..

Python: send file to a server without third-party libraries? -

i have python client behind nat , python server public ip address. job send pcap file (the size of few mb) client server, dictionary data. is there easy way of doing without resorting third-party libraries (e.g. twisted, tornado)? if not, what's easiest alternative? i thought send pcap file through http easier read on server side, , perhaps same dictionary first pickling it. solution? (i have complete control on server, can install whatever) is ftp usable solution you? https://docs.python.org/2/library/ftplib.html http://effbot.org/librarybook/ftplib.htm

Live Stream Video Not Playing On Some Android Versions, HTML5 Video Not Found -

i working on website provides live streams.... using cdnsun services....i have used jwplayer, using flowplayer html5... have setup code through cdnsun section(how to).... live streams , other video files playing on pcs, maximum number of browsers, ios,galaxy s4 etc problem not playing on android versions 3-4... my view code: <meta name="description" content="euro az channel live @ euroaz.tv"> <link rel="stylesheet"href= "http://releases.flowplayer.org/5.5.2/skin/minimalist.css"> <style> #mediaplayer { width: 100%; height: 100%; } </style> <div id="mediaplayer"></div> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery /1.8.2/jquery.min.js"></script> <script type="text/javascript" src="h

google cloud storage - Moving multiple files with gsutil -

let's i've got following files in google cloud storage bucket: file_a1.csv file_b2.csv file_c3.csv now want move subset of these files, lets file_a1.csv , file_b2.csv . that: gsutil mv gs://bucket/file_a1.csv gs://bucket/file_a11.csv gsutil mv gs://bucket/file_b2.csv gs://bucket/file_b22.csv this approach requires 2 call of more or less same command , moves each file separately. know, if move complete directory can add -m option in order accelerate process. however, unfortunately want move subset of files , keep rest untouched in bucket. when moving 100 files way need execute 100 commands or , becomes quite time consuming. there way combine each of 100 files 1 command addtionally -m option? gsutil not support create number of shell scripts, each performing portion of moves, , run them concurrently. note gsutil mv based on syntax of unix mv command , doesn't support feature you're asking for.

javascript - How to pass a variable in jAlert from a php file -

i having bad time trying implement translating files site of mine. deal translate whole site php contains name of language used (ex. en.php, es.php, pt.php...) , set variables files called user click diferente language names webpage. no problem until then. these languages variables defined in these php file this... on pt.php: define('texto_69','gostaria de se identificar?'); on en.php: define('texto_69','would identify yourself?'); and on every php language file... the main problem having not have acess these variables in index.php file when editing script part, take look: if($('input[name="agree"]').is(':checked')) { //alert('checkbox checked!!'); return true; } else { jalert('para efetuar o cadastro voc&ecirc; deve estar de acordo com os termos de uso e politica de privacidade','aviso'); return false; } return true; i want replace st

classification - Which MaxEnt accuracy to report? -

Image
in nltk, maxent classifier reports multiple accuracy metrics, shown in screenshot below. first set accuracy per iteration. second, printed @ bottom of screenshot, reported calling nltk.classify.accuracy(maxent, test_set) , maxent variable has been initialized. of these accuracies reportable, i.e. in results show training model's accuracy? what's difference between them?

dataframe - R how to retrieve data from data.frame with multiple conditions -

i wondering how perform basic data manipulation in r. want following. i have data table following pattern : v1 v2 v3 abc x 24 abc y 30 efg x 4 efg y 28 hij p 40 hij y 41 pkl x 32 now want retrieve values/pairs of v1 doesn't have corresponding value not x on v2. in above dataset subset hij p 40 hij y 41 since neither of pair of hij have v2 value of x. i retrieve values of v1 don't repeat twice. in above example pkl x 32 you mentioned data.table , here's 2 possible approaches both requests library(data.table) for 1. setdt(df)[, .sd[all(v2 != "x")], = v1] # v1 v2 v3 # 1: hij p 40 # 2: hij y 41 for 2. df[, .sd[.n == 1l], = v1] # v1 v2 v3 # 1: pkl x 32 or (a bit more optimized version) indx <- df[, .(indx = .i[.n == 1l]), = v1]$indx df[indx] # v1 v2 v3 # 1: pkl x 32

R: Assigning vectors from a list of vectors as a value of the column in a data frame from a list of data frames -

i have 2 lists of equal length: 1 list of data frames, list of vectors, such length of each vector coincides number of rows in respective data frame of first list. want assign vectors second list value of first column in each data frame. easier explain code bellow: for (i in seq_along(data)){ data[[c(i, 1)]] = links[[i]] } , data list of data frames, , links list of vectors. while code works fine, , speedwise there no particular need avoid for loops, wonder whether there other way perform same action without for ? since data and links have same lengths, , replacing one-for-one, map() and/or mapply() choice. using data other answer, data <- list(data.frame(a = 1:3, b = 4:6), data.frame(a = 10:14, b = 15:19)) links <- list(7:9, 20:24) you can do map("[<-", data, 1, value = links) # [[1]] # b # 1 7 4 # 2 8 5 # 3 9 6 # # [[2]] # b # 1 20 15 # 2 21 16 # 3 22 17 # 4 23 18 # 5 24 19 although r gods know how sa

How to get programmatically the highest version for a Maven artifact from my local repository? -

in many posts saw aether project helps in working artifact repositories. retrieve highest version specified groupid , artifactid only. in aether wiki present case org.apache.maven:maven-profile:2.2.1 artifact specify version: dependency dependency = new dependency( new defaultartifact("org.apache.maven:maven-profile:2.2.1"), "compile" ); but need version, highest version artifact. how this? if can read pom.xml file, can bare xml parsing. public static string getversionof(file pomfile) throws parserconfigurationexception, ioexception, saxexception { string version = ""; documentbuilderfactory dbfactory = documentbuilderfactory.newinstance(); documentbuilder dbuilder = dbfactory.newdocumentbuilder(); document doc = dbuilder.parse(pomfile); nodelist nodelist = doc.getelementsbytagname("project"); for(int = 0; < nodelist.getlength(); i++) { element node = (element

.net - c# application running matlab error using cd too many input arguments -

i looking run matlab function c# application. my code below, edited link matlab example previous question on here. code not working. the error message happens on matlab.feval line. although code looks same example. an unhandled exception of type 'system.runtime.interopservices.comexception' occurred in mscorlib.dll. additional information: error using cd many input arguements code static void main(string[] args) { // create matlab instance mlapp.mlapp matlab = new mlapp.mlapp(); matlab.visible = 1; // change directory function located matlab.execute(@"cd g:\shared\folder\matlab\non linear"); // define output object result = null; // call matlab function upload_data //matlab.feval("upload_data", 0, out result); matlab.feval("upload_data_test", 1, out result, "dms", "dsfd", 0); //[success] = upload_data_test(data_base, st

database - Android setReadAccess for Parse ADMIN error -

i use parse database. have access simple users , admin user. each user see his/her own data admin user see of users' data. i create parseuser, , if current user equal it, should known admin user. following error: java.lang.illegalargumentexception: cannot setreadaccess user null id i think mistakes if function (never become true) , this: acl.setreadaccess(admin,true); could suggest something? parseuser admin = new parseuser(); admin.setusername("admin3"); admin.setpassword("a"); // create post. anywallpost post = new anywallpost(); // set location current user's location post.setlocation(geopoint); post.settext(text); post.setuser(parseuser.getcurrentuser()); parseacl acl = new parseacl(); // give read accesses if (parseuser.getcurrentuser() == admin) { acl.setreadaccess(parseuser.getcurrentuser(), true); } else { acl.setreadaccess(parseuser.getcurrentuser(),true); acl.setreadaccess(admin,true)

Android ble app crash if bluetooth is turned off in android lollipop -

hello try scan bluetooth ble device android lollipop. working fine if turned off bluetotooth run app crash , give pop enable bluetooth.ideally should give pop enable bluetooth if turned off. this method, should enable bluetooth: private void enablebluetooth() { if(bluetoothadapter == null) { //bluetoothstate.settext("bluetooth not supported"); } else if(!bluetoothadapter.isenabled()) { //bluetoothadapter.enable(); intent enablebtintent = new intent(bluetoothadapter.action_request_enable); activity.startactivityforresult(enablebtintent, request_enable_bt); } } code start scan public void handlescanstart(view view) { founddevices.clear(); btarrayadapter.clear(); ble.startblescan(); scanbutton.setenabled(false); stopscanbutton.setenabled(true); } enable start scan public void startblescan() { if(getscanning()) { return; } enablebluetooth();

Is it possible to sort a csv file in python by data? -

is possible sort csv file in python average, alphabetical order etc. right have simple print row code , wondering if it's possible sort data. (name, class , score) it's task can't display code here, answers appreciated. if looking sorting of csv file based on columns, here quick solution: import csv import operator # sort based on 3 column, iteration starts @ 0 (0) r=csv.reader(open("1.csv"), delimiter=",") print("sorted based on 3rd column") print(sorted(r, key=operator.itemgetter(2), reverse=true)) # sort based on 2 column, iteration starts @ 0 (0) r=csv.reader(open("1.csv"), delimiter=",") print("\nsorted based on 2nd column") print(sorted(r, key=operator.itemgetter(1), reverse=true)) suppose csv mentioned below $> cat 1.csv 1,a,32,hello 2,x,33,xello 3,h,23,belo 4,z,3,elo then when run above code: $> python ./sort.py sorted based on 3rd column [['2', 'x', '33&#