Posts

Showing posts from February, 2011

html - Apply a particular style to an element only if that element is overflowing -

is there way apply particular style element conditionally on overflowing? e.g. if have say: <div> text long, no extremely long; goes on , on , on , on. might it's bit duracell(r) bunny, without batteries, , floppy ears. </div> and div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } // todo: there way apply rule if text overflowing? div { background-color: red; } is there way using pure css have background-color: red rule apply if text overflowing? note: can see way of doing using javascript; want know if there pure css way it.

java - getContentType method returning always 'application/force-download' -

i have url file can download. looks this: http://<server>/recruitment-mantis/plugin.php?page=bugsynchronizer/getfile&fileid=139&filehash=3e7a52a242f90c23539a17f6db094d86 how content type of file? have admin in case simple: url url = new url(stringurl); urlconnection urlconnection = url.openconnection(); urlconnection.connect(); string urlcontent = urlconnection.getcontenttype(); returning me application/force-download content type in every file (no matter jpg or pdf file). want cause want set extension of downloaded file (which can various). how 'get around' of application/force-download content type? in advance help. check urlconnection.getheaderfield("content-disposition") filename. header used attachments in multipart content, doesn't hurt check. if header not present, can save url temporary file, , use probecontenttype meaningful mime type: path tempfile = files.createtempfile(null, null); try (inputs...

Can we call a python method from java? -

this question has answer here: calling python in java? 9 answers i know jython allows call java method java's classfile if written python, reverse possible ??? i have many algorithms written in python, work pretty python , jython lack proper gui. planing bring gui java , keep python library intact. not able write gui jython or python , cannot write algorithm python. solution found merge java's gui , python's library. possible. can call python's library java. yes, can done . done creating pythoninterpreter object , calling python class using . consider following example : java : import org.python.core.pyinstance; import org.python.util.pythoninterpreter; public class interpreterexample { pythoninterpreter interpreter = null; public interpreterexample() { pythoninterpreter.initialize(system.getproper...

iphone - How to attach multiple files in single mail in iOS -

i want send multiple attachment files in single mail in ios programatically. have tried following far: // give file array nsstring *str_mail = [readingemfreading objectatindex:0]; // here can encode file nsdata *mydata = [str_mail datausingencoding:nsutf8stringencoding] //here can attach file extance of .csv [controller addattachmentdata:mydata mimetype:@".cvs" filename:retriveemail] //here can set body mail [controller setmessagebody:@"file" ishtml:no]; //here code sent mail if (controller) [self presentviewcontroller:controller animated:yes completion:nil]; by using code, can send 1 attachment. want send multiple files however. how can achieve this? you add many time addattachmentdata , add muliple file try code :- add line nsstring *str_mail = [readingemfreading objectatindex:0]; // here can encoded file nsdata *mydata = [str_mail datausingencoding:nsutf8stringencoding] nsdata *mydata1 = [str_mail datausingencoding:nsutf8stringen...

python - SQLAlchemy not producing proper SQL statement for multi column UniqueConstraints -

below 2 different attempts have made in trying achieve multi-column unique constraint in sqlalchemy, both of seems have failed since proper sql statement not being produced. the attempts: from sqlalchemy import column, integer, string, text, foreignkey, datetime, create_engine, uniqueconstraint, boolean sqlalchemy.orm import relationship, backref, sessionmaker sqlalchemy.ext.declarative import declarative_base sqlalchemy.interfaces import poollistener import sqlalchemy class foreignkeyslistener(poollistener): def connect(self, dbapi_con, con_record): db_cursor = dbapi_con.execute('pragma foreign_keys=on') engine = create_engine(r"sqlite:///" + r"d:\\foo.db", listeners=[foreignkeyslistener()], echo = true) session = sessionmaker(bind = engine) ses = session() base = declarative_base() print sqlalchemy.__version__ class foo(base): __tablename__ = "foo" id = column(integer, primary_key=true) du...

How to speed up array intersection in Java? -

arrays below sorted without duplicates (contain unique positive integers) of small size (less 5000) , intersection (see below) called billion of times micro-optimization matter. article nicely describes how speed below code in c language. int = 0, j = 0, c = 0, la = a.length, lb = b.length; intersection = new int[math.min(la, lb)]; while (i < la && j < lb) { if (a[i] < b[j]) i++; else if (a[i] > b[j]) j++; else { intersection[c] = a[i]; i++; j++; c++; } } int[] intersectionzip = new int[c]; system.arraycopy(intersection, 0, intersectionzip, 0, c); in java guess impossible call low-level instructions. mention "it possible improve approach using branchless implementation". how 1 it? using switch ? or maybe substitute a[i] < b[j] , a[i] > b[j] or a[i] == b[i] comparisons binary operations on integer operands? binary search approach (with complexity o(la log(lb)) ) not case because la not << lb . inte...

algorithm - METIS serial graph partitioner -

metis graph partitioning algorithm used partitioning large graph. have graph forest. know how metis partitions in case ? well, indeed, metis can partition large graphs doesn't mean can not manage smaller graphs or different types of graphs. forest special type of graph without cycles, can have disconnected parts... as other type of graph, metis going perform 3 level partitioning algorithm: coarsening (in case, have forest graph, may finish because type of graph going have small number of edges or connections) initial partitioning uncoarsening + fine-grained balancing. so basically, going work type of graph. and personal experience, did find out metis didn't give me optimal results when working disconnected graphs (and forest disconnected graph), implemented own logic finding groups of vertices connected , used metis partition group (which connected)... i recommend reading metis metis library documentation .

java - difference between bytebuffer.flip() and bytebuffer.rewind() -

i aware flip() set current buffer position 0 , set limit previous buffer position whereas rewind() set current buffer position 0. in following code, either use rewind() or flip() same result. byte b = 127; bb.put(b); bb.rewind();//or flip(); system.out.println(bb.get()); bb.rewind();// or flip(); system.out.println(bb.get()); could provide me real example difference of these 2 methods matters? in advance. edit: found solution in this link, it's explained , detailed thorough understanding of buffer , channel classes' use. they're not equivalent @ all. a bytebuffer ready read() (or put() ). flip() makes ready write() (or get() ). rewind() , compact() , clear() make ready read()/put() again after write() (or get() ).

android - How to set label for app, but empty for all activities? -

short , simple question: i use actionbarsherlock library, , wish have app's label set string, yet activities have empty label unless specified otherwise. i know can go on each activity , set label "" , there better solution? using styles ? i've tried putting : <item name="android:label"></item> in there, didn't anything. edit: fact is, reason, setting label of activities "" , change label of app on android versions (tested on galaxy s mini, android 2.3) , name "" too. how come? bug? this bug on either android or launcher i've tested on. it seems setting label activities "" (or @ least main one) sets name of app "" , label of application tag default value of of activities. you can remove whole title bar putting <item name="android:windownotitle">true</item> in app theme. don't think should have title bar without title (unless on devices runnin...

jquery - How do I get data from the YouTube api on a page loaded by ajax? -

i'm using following code me view count specific youtube video , place in div id: ytviews: var video_id='grcglk6izz0'; $.getjson('http://gdata.youtube.com/feeds/api/videos/'+video_id+'?v=2&alt=jsonc',function(data){ document.getelementbyid('ytviews').innerhtml = (data.data.viewcount); }); example here's problem: the div placing view count in resides on page loaded via ajax. when visit page when loaded ajax view count doesn't show. here's ajax code: $(function () { var b = "", = $("#main-content"); $("#page-wrap"); $(document).delegate(".dyn a", "click", function () { window.location.hash = $(this).attr("href"); return !1 }); $(window).bind("hashchange", function () { string.prototype.totitlecase = function (b) { var = this; 1 !== b && (a = a.tolowercase()); ...

maven - JSF i18n.property internationalization -

my facelet not able properties of property file, , can't figure out why. code: facelet: <th id="leaderlabel" class="label"><h:outputtext value="#{msgs.fuehrer}" /></th> faces-config: <faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"> <application> <locale-config> <default-locale>de</default-locale> <supported-locale>en</supported-locale> </locale-config> <resource-bundle> <base-name>messages</base-name> <var>msgs</var> </resource-bundle> </application> </faces-config> properties i've placed in maven project's src/mai...

javascript - AngularJS - how to animate ng-include that is dynamically compiled and added -

i have following angularjs (v1.1.4) code , trying fade-in (animate) ng-include when added dom. doing wrong? also, if can suggest better way of passing add/set/remove commands directive rather watching 'action' property, appreciated. plunker here: http://plnkr.co/edit/rcgpi0n8fgwj6o01mp3b?p=preview index.html <!doctype html> <html ng-app="plunker" > <head> <meta charset="utf-8"> <title>angularjs plunker</title> <link rel="stylesheet" href="styles.css" /> <script>document.write('<base href="' + document.location + '" />');</script> <script src="http://code.angularjs.org/1.1.4/angular.js"></script> <script src="app.js"></script> </head> <body ng-controller="mainctrl"> <button ng-click="loadpartial('partial1.html')">click load partial 1</butt...

c# - using .net dll as com in php failed -

i have .net dll want use in php application have tested dll on .net app , worked my c# class: namespace cryptocs { [guid("15d16831-d6be-43c4-ab4f-f0baa35987db")] [classinterface(classinterfacetype.none)] [progid("cryptocs")] [comvisible(true)] public class crypto : icryptocs { public crypto() { } public bool login(string username, string password) { // code } } [guid("5bdbb53a-571a-4ec7-b37e-a4d2a6a54deb")] [interfacetype(cominterfacetype.interfaceisidispatch)] [comvisible(true)] public interface icryptocs { [dispid(1)] bool login(string username, string password); } } my usage code is: $crypto = new com('cryptocs.crypto'); this page give error: failed create com object i tried register dll using gacutil.exe result was: assembly added cache but e...

ASP.NET MVC Routing configuration giving Http 302 Object moved to -

i think might having bit of trouble mvc routing. note, i'm using asp.net mvc 4 razor views. i have routes registered follows: routes.maproute( "person", "person/show/{uniqueid}", new { controller = "person", action = "show", uniqueid = "" } ); routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new {controller = "home", action = "index", id = urlparameter.optional} ); my personcontroller implemented follows: [handleerror] public class personcontroller{ public actionresult show(string uniqueid) { //get data database var persondata = getpersondatafromdatabase(uniqueid); return view("personview", new personviewmodel(persondata)); } } this supposed display personview.cshtml has layout of _layoutcontent.cshtml in turn has layout of _...

php - Need to create dynamic thumbnail grid. -

i new in web development, need create website portfolio purposes in need show thumbnail , little description of project underneath , content should dynamically displayed. have basic knowledege of php, wordpress, javascript, jquery, python, , html/css doing learning purpose. i want guys please tell me way how can it, guide me rest of handle. some similar examples are http://themes.themepunch.com/?theme=megafoliopro_jq http://codecanyon.net/item/dzs-scroller-gallery-cool-jquery-media-gallery/full_screen_preview/457913?ref=ibrandstudio i new forum , expect answer question thanks lot mates. download cms made simple , either album or gallery module. 1 out of many ways job done.

c# - RPC Server Is Unavailable error and Directory does not exist -

background i have written utility watches files in directory, , copies them defined target locations on remote machines. there feature allows stopping defined services in order allow copying target. in our work environment, these remote machines typically vms (we use vmware workstation) , machines part of vm sub-domain, , configured use nat networking (share host machine's ip address). when "remote" it's referring vm running on host. problem for utility, i'm trying copy files using unc path target directory, , using machine name list of services using servicecontroller.getservices(string machinename) method. so if had vm named server-1 , might trying copy file \\server-1\c$\destinationfolder . of time works, see excetion because target directory can't found. when happens, see error when trying services on remote machine - "the rpc server unavailable." when vm restarted, works fine... while. i'm having hard time trying nail down...

java - calling within ActionListener -

i'm trying plug code gui @ moment can't find way call text in actionlistener out breaking code know there things in findandreplace() need work on work in gui... @ moment i'm trying account actionlistener. import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.util.arraylist; import java.util.arrays; import java.util.collections; import javax.swing.*; public class hangmanpanel extends jpanel { static boolean found; private static final long serialversionuid = -5793357804828609325l; public static string answerkey() { //get random array element string array[] = new string[10]; array[0] = "hamlet"; array[1] = "mysts of avalon"; array[2] = "the iliad"; array[3] = "tales edger allan poe"; array[4] = "the children of hurin"; array[5] = "the red badge of courage"; array[6] = "of mice , men"...

sql - What is wrong with my queries? -

all code correct queries (which @ bottom) don't seem run. checked on w3schools.com more information, seems there's nothing wrong code. can take , explain? --drop tables-- drop table job; drop table employee; drop table purchase; drop table soccerball; drop table client; --create tables-- create table client ( clientid int not null, clientname varchar(20) not null, street varchar(20) not null, city varchar(20) not null, zipcode varchar(5) not null, phone varchar(15) null, emailaddr varchar(50) null, primary key(clientid) ); create table soccerball ( ballid int not null, ballsize number(1) not null, color varchar(20) not null, material varchar(20) not null, primary key(ballid) ); create table purchase ( purchaseid int not null, clientid int not null, ballid int not null, purchasedate date not null, primary key (purchaseid), foreign key (clien...

Passing pointer to a function in C++ -

i wrote following piece of code #include <iostream> using namespace std; void temp (int * x) { x=new int [2]; x[0]=1; x[1]=2; } int main() { int *ptr; temp(ptr); cout<<ptr[0]<<endl; cout<<ptr[1]<<endl; return 0; } running gives seg fault, memory allocation happens inside temp function local function? memory gets deallocated while returning temp ? know, solve problem, need pass pointer pointer ptr , still, why thing not work? to alter in function in c, need pass pointer it. in case, want alter pointer, need pointer pointer: void temp (int** x) then in function use *x have x (you need (*x)[n] , *x[n] means else) then call temp with: temp(&ptr); this should solve in c, , work in c++. in c++, pass reference pointer: void temp(int*&x) which allow syntax have used unchanged.

c++ - SSE FPU parallel -

i wondering if possible use sse in parallel x87. consider following pseudo code, 1: sse_insn 2: x87_insn would pipeline execute 1 , 2 in parallel assuming can executed in parallel? in modern (and older) processors, x87 , sse instructions use same execution units, it's unlikely benefit sort of code. there may special cases can trick processor running example x87 divide in parallel sse add, or that, if doing big loop of similar operations, there no benefit.

Sqlite database practice with android not working -

i have made simple demo application of sqlite databse in android .inthat activity contains edittext , button , textxview, have created handler class , implemented java code mainactivity,but not working..i have made below link : http://stdioe.blogspot.in/2012/03/how-to-connect-sqlite-database-in.html but shows error in myactivity.java file in line "private db names;"....please me...what is? my code below: **main.xml** <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".mainactivity" > <edittext android:id="@+id/edittext1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignpa...

How to analyse complexity of the given optimized bubble sort? -

this pseudo code of optimized bubble sort algorithm. have tried analyze time complexity, not sure cost of line 4 (if a[i-1] > a[i]). answer (n-1)+(n-2)+........+1 ? cost of lines 5 8? 1.for j = a.length 2 2. swapped = false 3. = 2 j 4. if a[i-1] > a[i] 5. temp = a[i] 6. a[i-1] = a[i] 7. a[i-1] = temp 8. swapped = true 9. if(!swapped) 10. break the cost of lines 5 8 single iteration o(1). the cost of loop @ lines 3-8 o(j-1). the cost of whole sort in worst case o((n-1) + (n-2) + ... + 2) = o(n^2) (but of course in best case, when array sorted, cost o(n-1)). by way, implementation of optimized bubble sort contains error: if @ line 9 should inside outer loop, outside inner.

shell - Batch script to log in SSH server on Windows -

Image
i'm trying make batch script log in ssh server , execute few commands. start command is: plink -ssh user@99.99.999.99 then need enter user name , password image: if have 'user name' , 'password' in 2 variables, how use them when asks me for? [edit] last try this: (echo username echo mypassword) | plink -ssh user@99.99.999.99 output: user name:username mypassword password: the batch didn't "pressed" enter after inputing username. try plink -ssh -l $user -pw $passwd after setting environment variables set user=name set passwd=secret see http://the.earth.li/~sgtatham/putty/0.58/htmldoc/chapter7.html

backbone.js - Requirejs - using singleton object, unable to get the returning template -

i starting app (i new requirejs) requirejs singleton model of app... passing array of templates utilities js, , assigning templates appropriate views... i use : app.js,singleton.js(to return object), index.js implement index page template, utilities assigning templates appropriate views... but in index.js, while console this.template... getting result "function (n){return e.call(this,n,w)} " - understand approach wrong.. can once give me correct way me.. or highlight me wrong pelase..? thanks in advance.. here js files: app.js:- requirejs.config({ baseurl: 'js', paths: { "jquery" : 'lib/jquery-1.9.1.min', "underscore": "lib/underscore-min", "backbone" : "lib/backbone-min", "singleton" : "utils/singleton", "model" : "models/model", "index" : "views/index", ...

java - JPanel Inside Of A JPanel -

Image
i trying jpanel appear inside of jpanel. currently, jpanel in external jframe , loads other jframe. want jpanel inside other jpanel program not open 2 different windows. here picture: the small jpanel text logs want inside of main game frame. i've tried adding panel panel, panel.add(othepanel) . i've tried adding jframe, frame.add(otherpanel) . overwrites else , gives black background. how can add panel, resize, , move it? edits: that want chatbox be. class code: left out top of class. public static jpanel panel; public static jtextarea textarea = new jtextarea(5, 30); public static jtextfield userinputfield = new jtextfield(30); public static void write(string message) { chatbox.textarea.append("[game]: " + message + "\n"); chatbox.textarea.setcaretposition(chatbox.textarea.getdocument() .getlength()); chatbox.userinputfield.settext(""); } public chatbox() { panel = new jpanel(); panel...

sql server - C# SqlCommand, XmlReader and output parameter -

i have problem receiving value of output parameter when execute stored procedure using sqlcommand. don't have problem output parameter when execute stored procedure not c# code, sql server management studio. here fragment of c# code: rest = -1; xmldocument res = new xmldocument(); res.loadxml("<result><errcode>0</errcode></result>"); using (sqlcommand sqlcmd = params.sqlcn.createcommand()) { sqlcmd.commandtype = commandtype.storedprocedure; sqlcmd.commandtext = "dbo.wss_doproductadd_sp"; sqlcmd.parameters.clear(); sqlcmd.parameters.add(new sqlparameter("@quantity", ilosc)); sqlcmd.parameters.add(new sqlparameter("@addtolog", addtolog)); sqlcmd.parameters.addwithvalue("@rest", rest).direction = parameterdirection.output; xmlreader xr = sqlcmd.executexmlreader(); xmlnode newnode = res.readnode(xr); while (newnode != null) { res.docu...

html - Android simple mp3 playback -

i'm building android app using dreamweaver , want have audio. i made index.html , put script in head: <script type="text/javascript"> function init() { var button = document.getelementbyid("a"); if (button.addeventlistener) { button.addeventlistener("click", function () { mp.create(getapplicationcontext(), r.raw.hound).start(); }, false); } } </script> i put hound.mp3 in /res/raw/ and put button on page: <button id="a" value="click">play</button> then exported .apk , installed on phone, music doesn't play when push button. missing something? thanks comments. switched java/xml because i'm finding out eclipse better way develop app. sound problem did fix, this: mainactivity.java: final mediaplayer mp = mediaplayer.create(this, r.raw.something); button play_button = (button)this.findviewbyid(r.id.play_button); play_butto...

c++ - DLL project on Windows: Unresolved External Symbol -

i'm creating dll project visual studio 2012 intent of calling functions delphi project. i've turned off c++ name mangling wrapping functions in extern "c" { /* ... */ } avoid c name decoration, i'm using def file. here's snippet of code describing how have things laid out: // myfile.h #ifdef myproject_exports #define myproject_api __declspec(dllexport) #else #define myproject_api __declspec(dllimport) #endif extern "c" { extern myproject_api void __stdcall do_something(); } the .cpp file equivalently structured. matches fine. i added .def file project folder containing following content: library myproject exports do_something=_do_something@0 when build project, works okay. when add linker option /defs:myproject.def i start getting errors regarding unresolved external symbols. has had kind of issue before? i'm not new either c++ or c first time building dll on windows, i'm unix developer. hypothesis i'm either...

java - RandomAccessFile vs FileChannel.open(path); -

what kind of filechannel object filechannel.open(path) method return? is still random access allowed if following? randomaccessfile ra = new randomaccessfile("randomindeed","rw"); filechannel fc1 = ra.getchannel(); what's difference between fc1 , following instance fc : filechannel fc = filechannel.open(path); basically know differences between 2 objects above-created, hence fc1 , fc thanks in advance. the filechannel instance got randomaccessfile instance carries random access behaviour of object it's been created, in case fc1 synced ra object. can see it's described in javadoc changing channel's position, whether explicitly or reading or writing bytes, change file position of originating object, , vice versa. changing file's length via file channel change length seen via originating object, , vice versa. changing file's content writing bytes change content seen originating object, , vice v...

mojolicious - Start stop reset timer in perl -

is there start/stop timer in perl. had tried anyevent 1 time or recurring timer. once set, can reset timeout interval. i have requirement have reset timer if event occurs within timer timeout interval. there perl module job? thanks in advance. update this question prompted quite bit of discussion on #mojo irc channel . end result that, barring unforseen problems, upcoming mojolicious 4.0 release include new reactor method again can restart timers. turns out new method (inspired partially question) provides massive performance increase when used internally mojolicious in case (high load high concurrency). once 4.0 released, try updated example version of second example below: #!/usr/bin/env perl use mojo::base -strict; use mojo::ioloop; $loop = mojo::ioloop->singleton; $now = 1; $loop->recurring( 1 => sub { print $now++ . "\n" } ); $timer = $loop->timer( 3 => \&boom ); $loop->timer( 2 => sub { print "event resets. no ...

android - getting notification when contactslist changed -

i'm working on program needs notification contactslist. know contentobserver. issue need observer work when app isn't running in front or background. any suggestions appreciated, create service, , have contentobserver run in service. in fact, that's general answer "i need x when not running"- in service.

mysql - PHP COI Rate Calc foreach, for and possible while loop? -

i'm trying achieve below process using php i'm stumped, able provide hand? get table contains years database loop through each row (year) using foreach loop use loop divide year months (12) calculation on each month can verified on month 12 of each year if verification unsuccessful +/- number , re-run loop current year else carry on next year many thanks

python - django haystack - how to use with current view having some context -

i have view puts context , renders template context. want view display things if no search query there, , show searhed things, if searched. class mycurrentview(view): def get(self, request): data = { 'users': user.objects.all() } return render_to_response("mytemp.html", .. urls.py: url(r'^search/$', mycurrentview.as_view()) now, integrating searchview this: class mycurrentview(searchview): (if u observe, subclassed searchview). template = 'mytemp.html' def get(self, request): data = { 'users': user.objects.all() } return render_to_response... def get_context_data(self, ...): print "....this should print" #but not printing. so, unable add data return data urls.py: url(r'^search/$', mycurrentview.as_view()) # as_view() gave me error, did mycurrentview() , may thats y, get_context_data not calling. will provide more inform...

Using a counter inside a java.util.Timer in Android Activity causes app to crash -

i'd accomplish think simple, turning out hassle. i have loading screen picture, , i'd fade in , out application loading. decided accomplish changing it's opacity relative sine value of counter. code follows: imageview loadingraven; //loading raven @ start of app timer timer; //timer we're gonna have use int elapsed = 0; //elapsed time far /* * following in oncreate() method after contentview has been set */ loadingraven = (imageview)findviewbyid(r.id.imageview1); //fade raven in , out timertask task = new timertask() { public void run() { elapsed++; //this line causes app fail loadingraven.setalpha((float)(math.sin(elapsed)+1)/2); } }; timer = new timer(); timer.scheduleatfixedrate(task, 0, 50); what problem that's causing program fail? correctly using timer , timertask? or there perhaps better way update opacity of image eases in , out smoothly? thanks timertask runs on di...

jquery - populate blocks of html code dependant on select option value -

i have select box user can select how many people want select register. example if 4 selected 4 people registration areas appear below in form: jquery: var person = '<div class="reg-person"><span class="person">person 1</span><div class="field"><label for="name">name</label><input type="text" id="name" name="name" /></div><div class="field"><label for="company">company</label><input type="text" id="company" name="company" /></div><div class="field"><label for="email">email address</label><input type="text" id="email" name="email" /></div><div class="field"><label for="contact">contact number</label><input type="text" id="contact" name="...

python - how to apply a specific regex to a specific line -

i trying apply specific regex on specific line, specified starting key: right have content of file inside python variable my_config file content --------------------------------------------- [paths] path_jamjs: c:/users/[changeusername]/appdata/roaming/npm/node_modules/jamjs/bin/jam.js path_php: c:/[changeusername]/php/php.exe values replace --------------------------------------------- "path_jamjs": { "changeusername": "te" }, "path_php": { "changeusername": "tes" }, with open ("my.ini", "r") myfile: my_config = myfile.read() how can apply regex replace on entire file content in my_config replace value @ specific corresponding line, without having loop line line, can regex? given path: path_php key: changeusername value: te change path_jamjs: c:/users/[changeusername]/appdata/roaming/npm/node_modules/jamjs/bin/jam.js path_php: c:/[changeusername]/php/php.exe to path_jamjs: c:/u...

matlab - Error: "Index exceeds matrix dimensions" -

the following code works when run on own: range = multi_sptime(100,end); binary_input = binary_input2(1:range); ssignal = signal(1:range); signal = ssignal;% input current clear input2 clear binary_input2 dbstop if error however, when add for loop: neurons=[1,2,4,6,8,10,15,20,25,30,35,40,50,100,200]; ncell=neurons ... i error below: ??? index exceeds matrix dimensions. error in int_idc20 (line 8) ssignal = signal(1:range); how fix , what's going on? first, think wanted loop on # of elements in neurons , correct for line with: for ncell=1:numel(neurons) and depending on want use ncell or neurons(ncell) in loop. second, range scalar looks multi_sptime row # 100 last element, , apparently number spits larger # of elements signal . try size(signal) see have.

python - Matplotlib: Multiple legends for contour plot for multiple contour variables -

Image
i need make multiple contours plots of several variables on same page. can matlab (see below matlab code). cannot matplotlib show multiple legends. appreciated. python code: import numpy np matplotlib import cm cm matplotlib import pyplot plt delta = 0.25 x = np.arange(-3.0, 3.0, delta) y = np.arange(-2.0, 2.0, delta) x, y = np.meshgrid(x, y) z1 = x*np.exp(-x**2-y**2) z2 = y*np.exp(-x**2-y**2) plt.figure() cs = plt.contour(x, y, z1, colors='k') plt.clabel(cs, inline=1, fontsize=10) cs = plt.contour(x, y, z2, colors='r') plt.clabel(cs, inline=1, fontsize=10) plt.legend(['case 1', 'case 2']) plt.show() matlab code: [x,y] = meshgrid(-2:.2:2,-2:.2:3); z1 = x.*exp(-x.^2-y.^2); z2 = y.*exp(-x.^2-y.^2); [c,h] = contour(x,y,z1, 'color', 'k'); set(h,'showtext','on','textstep',get(h,'levelstep')*2); hold on [c,h] = contour(x,y,z2, 'color', 'r'); set(h,'showtext','on',...

How to programmatically determine if an Active Directory trust is transitive in OpenLDAP? -

when using openldap, can trustattributes, trusttype, , trustdirection attributes ad server. however, isn't clear documentation how determine (in cases) when trust transitive. can shed light on (or @ least pointer)? note not using c# or .net calls. need see how test bits/values in attributes figure out. thanks. looks ldap attribute trustattribute in ldap object objectclass=trusteddomain has trust relationship. link http://msdn.microsoft.com/en-us/library/cc223779 details each bit means. the following link may useful http://gallery.technet.microsoft.com/scriptcenter/get-active-directory-2a9e15d2

java - Drawing with transparent texture, then opaque color -

i initialize opengl make transparent textures transparent: glenable(gl_blend); glblendfunc(gl_src_alpha, gl_one_minus_src_alpha); i draw texture this: glpushmatrix(); //translate //neutralize colors //bind texture //vertex points glpopmatrix(); but when try draw quad afterwards, won't show up: glpushmatrix(); { gltranslatef(x, y, 0); glcolor3f(1f, 0f, 0f); glbegin(gl_quads); { glvertex2f(0, 0); glvertex2f(10, 0); glvertex2f(10, 10); glvertex2f(0, 10); } glend(); } glpopmatrix(); if remove initialization above, quad appears, texture no longer transparent. what doing wrong here? edit: should call gldisable(gl_blend); whenever want draw not texture? you need disable blending before drawing quad. edit: can post more code? problem may somewhere else, example if have not disabled texture before drawing quads.

android - Stop when WebView is at the end -

i want able scroll webview until has reached end of webview. code below continues scroll down automatically when webview page has reached it's end. want make sure each page scrolls down until end of webview. webview.loadurl("file:///android_asset/"+position+".html"); webview.getsettings().setbuiltinzoomcontrols(true); webview.setpicturelistener(new picturelistener() { public void onnewpicture(webview view, picture picture) { int webbot = webview.getbottom(); webview.scrollby(0, 1); } }); try this, (basically using onpagefinished() instead of onnewpicture()) wv.setwebviewclient(new webviewclient() { @override public void onpagefinished(webview view, string url) { // todo auto-generated method stub super.onpagefinished(view, url); log.i(tag,"onpagefinished invok...

activemq - Camel route "to" specific websocket endpoint -

i have camel routes mina sockets , jetty websockets. able broadcast message clients connected websocket how send message specific endpoint. how maintain list of connected clients client id reference can route specific client. possible? able mention dynamic client in uri? or maybe thinking wrong , need create topics on active mq , have clients subscribe it. mean create topic every websocket client? , route message right topic. am atleast on right track here, examples can point out? google not helpful. the approach take depends on how sensitive client information is. downside of single topic selectors can subscribe topic without selector , see information - not want do. a better scheme use message distribution mechanism (set of camel routes) act intermediary between websocket clients , system producing messages. mechanism responsible distributing messages single destination client-specitic destinations. have worked on couple of banking web front-ends used similar schem...

android - How do I use get a ViewPager to let go of it's fragments when switching orientation? -

my application has layout differs based on orientation , device size. on larger devices composed of 2 views visible @ same time. on smaller devices layout viewpager lets user switch between 2 panes. typical pattern. the problem viewpager appears stick around, , keeps fragments. however, same fragment instance not kept textrenderfragment. instead, appears class created anew every time. since fragments kept inside viewpager, end having 2 sets of content views. causes problems restoring state because 2 sets of views don't share bundle. given such common pattern, expected find discussion how properly, have been unable. either have viewpager let go of fragments, or find way use same content fragment instances in both viewpager , static layout, depending on orientation. the construction looks this: @override public view oncreateview(final layoutinflater inflater, final viewgroup container, final bundle saved_instance_state) { if (saved_instance_state != null) { ...