Posts

Showing posts from January, 2015

objective c - Setting the background image of iPhone from an app -

i wondering if possible set iphone's background image app. have image uiimageview. when phone locked theres "wallpaper background image." there way make button can set wallpaper of phone uiimageview? in background view (you might have drag iboutlet it) like: imageview.bounds = view.bounds; imageview.hidden = yes; [view addsubview:imageview]; then when button pressed (possibly ibaction) turn background on , off. if (imageview.hidden){ imageview.hidden = no; }else{ imageview.hidden = yes; }

sql - Finding the hash value of a row in postgresql -

is there way hash code of row in postgresql? i need export data if there changes in data after last export, last exported data rows can stored in table, when again need export data can hash values of data , export rows has different hash value last export. is possible achieve using postgresql? thank you cast row text , use md5 make hash: select md5(cast((f.*)as text)) foo f;

how to search in wordpress from the database mysql -

i having website www.xyz.com in wordpress,i want implement search option in home page should in manner when user search state or thorough pin code should result, kindly let me know how same , codding . i using coding is: find yoga class in city: search, , want backend code can call function database, , implemented from sounds of things, want enable search of yoga classes based on zip-code or state. can bit tricky, actually, can done. custom post type first of all, you'll want create custom post type called "yoga class" classes. separate category of posts special capabilities. each class can have "description" field, "location" field, "time" field, "instructor biography" field, etc. depends on information want provide each class. here's great tutorial on creating , working custom post types: custom post types in wordpress . custom taxonomy to enable searching , sorting, you'll need categori...

c# - How do I do a nullable type constriant? -

let have following desire, simplify iconvertible's allow me call them using generic type parameter. plan creating generic converter , storing them on static property of static generic class. here code generate delegates:: static class iconvertiblehelper<t> t : struct, iconvertible { public static readonly converter<iconvertible, t> converter; public static readonly converter<iconvertible, t?> nullableconverter; static iconvertiblehelper() { type type = typeof(t).isenum ? enum.getunderlyingtype(typeof(t)) : typeof(t); converter = delegate.createdelegate(typeof(converter<iconvertible, t>), typeof(convert).getmethod("to" + type.name,new type[]{typeof(object)})) converter<iconvertible, t>; nullableconverter = obj => obj == null ? default(t?) : (t?)converter(obj); } } as aside, there small side effect of adding supports enum's inherit iconvertible , apparently conversion underylingtype enu...

Initialize Mercurial Repository with hg4idea in Intellij Idea -

i have created project wish push remote repository. when right-click project in project view , "commit directory," says there no changes. ?? i see nothing under version control->mercurial. i want avoid having run "hg init." not big deal, nice know. thanks! "hg init" 1 time task create repository, pales insignificance on various other activities repository. it idea create repository manually. once done, mercurial recognize repo , allow "add files", commit etc. of can via hg4idea.

Sending an Email to Multiple Recipients - Cc: and Bcc: in php -

this program running how send multiple cc , bcc. for($i = 0; $i < count($snteadd); $i++) { $subjt = $subject; $mess = $message; $toinfo .= $snteadd[$i]; $headers = "mime-version: 1.0 \r\n"; $headers .= "content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "from: <$fromemailid>\r\n"; $headers .= "reply-to: <$fromemailid>\r\n"; $hedders .= "cc : <$sendcc>\r\n" ; $headers .= "bcc : <$sendbcc>\r\n"; $headers .= "x-mailer: php 4.x"; $sendbcc = $snteadd[$i] .","; $sendbcc .= $sendcc . ","; $sendbcc .= $sendbcc; if($jvl != $i) { $toinfo .= ", "; } if($snteadd[$i] != "") { $result = mail($sendbcc, $subjt, $mess, $headers); if(!$result) { $subjdis = "auto response message sending...

c - GtkEntry text change signal -

how can connect signal callback kind of change in gtkentry's buffer, including character added, deleted, text pasted or cut? i've looked in docs gtkwidget, gtkentry , gtkentrybuffer without finding this. note: if question badly worded, think of html dom's change event, except it's fired greedily after every single keypress or event causes change, , not checked on unfocus. there changed signal (of gtkeditable interface): the ::changed signal emitted @ end of single user-visible operation on contents of gtkeditable. e.g., paste operation replaces contents of selection cause 1 signal emission (even though implemented first deleting selection, inserting new content, , may cause multiple ::notify::text signals emitted). (i found checking implemented interfaces section.) this indicates can connect notify signal of text property (specifically, notify::text ). there preedit-changed signal: if input method used, typed text not commi...

bash - How to run 'cd' in shell script and stay there after script finishes? -

i used 'change directory' in shell script (bash) #!/bin/bash alias mycd='cd some_place' mycd pwd pwd prints some_place correctly, after script finished current working directory doesn't change. is possible change path script? you need source file as: . myfile.sh or source myfile.sh without sourcing changes happen in sub-shell , not in parent shell invoking script. when source file lines in file executed if typed @ command line.

How are the android apps like talking carl and talking tom cat developed? -

i'd write app talking carl / talking tom cat wondering how developed? are animated on fly using 3d? general actions dont seem be, series of movies being played? if case, how movement of mouth animation done? i can't give authoritative answer, seems composed of pre-rendered 3d images. mouth animation done swapping images. notice cat in same position when talks.

c# - How can I use single query to insert multiple records from Dataset into SQL Server 2005? -

i have dataset in ado.net containing multiple records user side. need insert rows in single query database, in order avoid multiple queries maybe bulk copy answer. example in code project below show how using datatable, should able change example around use dataset. below small part of code covers conenction , exection in sql server (taken codeproject ). the key part notice bulkcopy.writetoserver( sourcetable ); sourcetable part of dataset pass it //first create connection string destination database string connectionstring; connectionstring = <em>yourconnectionstring</em>and initial catalog=testsmodatabase"; //open connection destination database; using (sqlconnection connection = new sqlconnection(connectionstring)) { connection.open(); //open bulkcopy connection. using (sqlbulkcopy bulkcopy = new sqlbulkcopy(connection)) { //set destination table name //to table created. bulkcopy.destinationtablename = "d...

sql server - Adding a new primary key to existing table -

i have table following details table name employee , columns empid (pk smallint not null) empname (varchar 256 not null) org (fk smallint not null) function (fk smallint not null) eff_date (datetime null) audit_id (varchar null) now have add coulmn table add_uid , make primary key i using query failing. alter table cvadmin.employee add add_uid varchar(32) null, constraint pk_employee primary key [non]clustered (add_uid) go table ' employee ' has primary key defined on it. edit the idea here new column should unique if fails can throw _key_violation code manipulation done to add unique constraint (which additional primary key) this: alter table employee add constraint uc_uid unique (add_uid)

Entity Framework 4.0 . Entity Creation -

we have 2 entities identical columns entity name different. can create 2 entity using first entity instance ? we tried doing .addobject("entity2 name",entityoneinstance) failing. please suggest whether possible or other approach. thanks in advance since types of entities different, add operation fall sure. you need mapper or (explicit/implicit) conversion operator between entity types think. to make clear, conversation solution, suppose have entity1 , entity2 , both have properties, property , property_1 , property_2 , property_3 . assume have default code generation strategy (not poco or sth). can add partial entity2 , entity1 classes implicit conversion operatior, example: public partial class entity2 { public static implicit operator entity2(entity1 entity1) { return new entity2() { property = entity1.property, property_1 = entity1.property_1, property_2 = entity1.property_2, ...

sql - Combine NamedQuery and Criteria in Hibernate -

i use hibernate in storefinder application. proximity search in sql use haversine formula. because bit messy sql created named sql query in .hbm.xml file this. select location.*, ( 3959 * acos( cos( radians(7.4481481) ) * cos( radians( x(location.coordinates) ) ) * cos( radians( y(location.coordinates) ) - radians(46.9479986) ) + sin( radians(7.4481481) ) * sin( radians( x(location.coordinates) ) ) ) ) distance location location.coordinates not null having distance < :radius order distance asc limit :max but have user defined filter (opening hours, assortments, etc.). use hibernate criteria programatically add filters. now have working namedquery giving me locations around point , working criteria query giving me locations according filter. my question is: best way in hibernate combine 2 beasts? (i.e. need locations around point satisfying filter.) there example way use namedquery subquery in criteria search? ...

Accessing private members of an outer class in an inner class: JRuby -

i not able access instance variable of outer class in inner class. simple swing app creating using jruby: class mainapp def initialize ... @textarea = swing::jtextarea.new @button = swing::jbutton.new @button.addactionlistener(buttonlistener.new) ... end class buttonlistener def actionperformed(e) puts @textarea.gettext #cant end end end the workaround can think of this: ... @button.addactionlistener(buttonlistener.new(@textarea)) ... class buttonlistener def initialize(control) @swingcontrol = control end end and use @swingcontrol ins place of @textarea in 'actionperformed' method. i guess it's not possible directly access outer class members inner class without resorting hacks. because @textarea in buttonlistener class different @textarea in mainapp. (i'm new ruby, wrong this. so, feel free correct me)

javascript - Ajax calls to the server from canvas tag? -

i have rails server has page canvas tag containing images , user interface. objects inside canvas have on mouse click events assigned. wonder if it's possible execute ajax calls on clicking item processing data inside ruby on rails server , comeback canvas changing objects there inside? removing or changing state etc? once canvas initialized looks can't access objects inside anymore. i'm not quite profi in html5 :( any advice appreciated, thanks canvas image created programmatically, therefore if want specific regions of canvas clickable suggestion position html element ovetop of canvas on higher zindex. example bind click event div tag , when response server update canvas.

Lua runs out of memory -

i've written complicated lua script uses lua sockets library. reads list of files disk, sorts them date , sends them http process. number of files on disk around 65k.the memory usage in taskmanager doesn't exceed 200mb. after quite while script returns: lua: not enough memory i print out current gc count @ points , never goes above 110mb local freemem = collectgarbage('count'); print("gc count : " .. freemem/1024 .. " mb"); this on 32 bit windows machine. what's best way diagnose this? all memory goes through single lua_alloc function. takes form of: typedef void* (*lua_alloc) (void* ud, void* ptr, size_t oszie, size_t nsize); all allocations, reallocations , frees go through this. documentation can found @ this web page . can write own track memory operations. example, void* myalloc (void* ud, void* ptr, size_t osize, size_t nsize) { (void)ud; (void)osize; // not used if (nsize == 0) { fre...

javascript - canvas library for drawing images -

html5 canvas provides lots of flexibility draw images using javascript. need generate javascript code based on inputs user (say 10 balls of blue color, 5 squares of green color , of size ...). there library provides appropriate javascript api(s) easier generate canvas along javascript code requirements listed above? with fabric.js it's quite trivial draw simple shapes (circles, rectangles, etc.) on canvas. supports image importing , manipulation. displaying rectangle, example easy as: var canvas = new fabric.canvas('id_of_canvas_element'); var rect = new fabric.rect({ top: 100, left: 100, width: 60, height: 70, fill: 'red' }); canvas.add(rect); take @ demos .

erlang - Forcing erl -make to recompile files when macros are changed -

i tried similar how make 2 different source directories in makefile output 1 bin directory? , have these files (relative project root): emakefile: % emakefile % -*- mode: erlang -*- {["src/*", "src/*/*", "src/*/*/*"], [{i, "include"}, {outdir, "ebin"}, debug_info]}. test/emakefile: % emakefile % -*- mode: erlang -*- {["../src/*", "../src/*/*", "../src/*/*/*"], [{i, "../include"}, {outdir, "../ebin"}, debug_info, {d, 'test'}]}. makefile: epath=-pa ebin all: before_compile erl -make all_test: before_compile cd test erl -make cd .. before_compile: mk_ebin copy_sqlite create_db copy_config copy_dot_app test: all_test erl -noshell $(epath) \ -s tests run \ -s init stop rm -f ct.db clean: rm -fv ebin/* ... dependencies of before_compile the problem running make test doesn't recompile modules compiled make . seems erl -m...

Castle Windsor Registration of Interface and Abstract Implementations -

i trying work out how auto register implementations of generic abstract class or interface. here classes: public abstract class abstractvalidator<t> : ivalidator<t> { public void validate(t) { ... } } public class customervalidator:abstractvalidator<customer> { ... } i trying following: _container = new windsorcontainer(); _container.register( alltypes.fromassemblycontaining<validationpatterns>() .basedon<ivalidator>() .withservice.base() })); ivalidator<customer> val = _container.resolve<ivalidator<customer>>(); any tips appreciated. cheers you're close. should basedon(typeof(ivalidator<>)) generic open type. cheers.

Django : Inline editing of related model using inlineformset -

i'm still stuck inline tree-like-eiditing of related models on same page. i've got 3 models, a, b , c. class class b fb = foreignkey(a) class c fc = foreignkey(b) in admin.py i'm doing like admina inlines = [inlineb] adminb inlines = [inlinec] i want when edit/add model a, should able add modelb inline, , add model b's related model c entries. trying out inlineformsets, can't find out how use them purpose. moreover, found this old discussion on same problem . again, since i'm new django, don't know how make work. its bit odd answering own question, hey nobody else stepped up. , bernd pointing me in right direction. solution required making intermediary model. class bc in case. class a(models.model): = models.integerfield() class b(models.model): fb = models.foreignkey(a) ...

android - Programmatically determine if application is the MarketPlace version -

i have application that's offered in , outside of marketplace. is there way of determining within code application came from? i've got few indirect methods ... 1) infer whether have "allow installation of non-market applications" ticked ... http://developer.android.com/reference/android/provider/settings.html#action_manage_applications_settings 2) or make separate builds , make explicit in code. if packagemanager.getinstallerpackagename() returns com.google.android.feedback application, installed android market.

SugarCRM 5.5.2 Rest api -- login failure -

i need able use api sugarcrm exchange information several other applications. found api docs, , articles sample code. end result of code send command: http://localhost/sugarcrm/service/v2/rest.php?method=login&input_type=json&response_type=json&rest_data= {%22user_name%22:%22rest%22,%22password%22:%2265e8800b5c6800aad896f888b2a62afc%22,%22version%22:%22.01%22} which produces error {"name":"invalid login","number":10,"description":"login attempt failed please check username , password"}null i have googled error , found several others issue, no solution. for me, needed use along lines of: method=login&input_type=json&response_type=json&rest_data=$rest_data the rest data is: { user_auth => { user_name => $username, password => $pw, version => "1.2" }, application => "foo" } (url encoded)

Can I use streaming structures in ATL? -

hi i'm developing com component in atl project. want use std::ostringstream logging trace log4cxx. unfortunately seems atl doesn't support std::ostringstream , derivatives. of have idea how can use streaming classes in atl project or alternative way? thanks. actually found mistake. missing header file. #include "stdafx.h" #include <sstream> #include "util.h" #include <comutil.h> std::ostringstream pvarobject_t2string(variant const *pvarobject) { std::ostringstream str; str<<"test"; str<<"licence id: "<< pvarobject[ 0 ].bstrval; return str; }

forms - PHP: Retaining drop down fields in new page -

i have 1 page displays form various dropdowns being populated dynamically. snippit <td valign="top"> <select name="status"> <option></option> <?php foreach($statuslst $status){ echo '<option value=' . $status[0] . '>' . $status[1] . '</option>'; } ?> </select> </td> i have 2nd page displays form results form. first form posting 2nd , 2nd posting itself. i want items chosen in first form selected when posted second form. can steer me in right direction here? thanks, jonesy taken form type, on second page: <?php foreach($statuslst $status){ $var = ''; if($_get['status'] == $status['0']){$var = ' selected=...

Multi Tenancy and User Definable Forms -

we designing our new product, include multi-tenancy. written in asp.net , c#, , may hosted on windows azure or other cloud hosting solution. we’ve been looking @ mvc , other technologies and, honest, we’re getting bogged down in various acronyms (mvc, ef, wcf etc. etc.). a particular requirement of our application causing headache – users able add fields database, or create whole new module. as result, each tenant have database different structure every other tenant using system. envisage every tenant have own database, rather sharing database. (adding fields etc. system accomplished using web interface). all , good, problem comes when creating data model mvc. modifying data model programmatically add field table seems impossible, according link: create edm during runtime? this major headache us. if don’t use mvc, think we’d still want create data model (perhaps used linq sql). we’re considering having table loads of fields in it, , instead of adding fields datab...

apache - Redirect Status Code 302 between Tomcat and IIS 7.0 is not properly handled by the isapi redirector -

we installed web application under tomcat 6 connected on isapi redirector interface (see http://tomcat.apache.org/connectors-doc/webserver_howto/iis.html ) iis 7 server. connector works in every case, except pages in web application return status 302, new location redirect for. the browser gets 302 , requests new location, iis web server not forward request tomcat server , returns 404 error instead, though uri worker map looks correct me. the corresponding uri worker rule is: /webclientservlet/*=worker1 and location url of new location looks following: http://localhost/webclientservlet/sbs/cmd:editcontent2/workflow:false/articlesearch:false/confirmed:false/objectid:131294/---/fpse/db:test/objectid:131294/copy+of+0001-intranet+home-main-ip+%28de%29 i solve problem. http status code 404.11, means (under iis 7) double escaped sequences not allowed. there new feature introduced in iis 7 called double escaped url filtering. default security filter, denies load url con...

variable assignment - C++ unrestricted union workaround -

#include <stdio.h> struct b { int x,y; }; struct : public b { // whines "copy assignment operator not allowed in union" //a& operator =(const a& a) { printf("a=a should exact same thing a=b\n"); } a& operator =(const b& b) { printf("a = b\n"); } }; union u { a; b b; }; int main(int argc, const char* argv[]) { u u1, u2; u1.a = u2.b; // can , calls operator = u1.a = (b)u2.a; // works u1.a = u2.a; // calls default assignment operator >:@ } is there workaround able last line u1.a = u2.a exact same syntax, have call operator = (don't care if it's =(b&) or =(a&)) instead of copying data? or unrestricted unions (not supported in visual studio 2010) option? c++ not allow data member type has full fledged constructor/destructor and/or copy constructor, or non-trivial copy assignment operator. this means structure a can have default copy assignment operator (ge...

c# 4.0 - Overloading magic methods with IronPython -

i'm attempting define power operator ** in c# class (we'll call class foo). i've overridden __pow__() , gets me desired behavior operations of type foo ** int . unfortunately, need define int ** foo , , neither using dynamic values nor overloading __pow__() gives me desired behavior; receive error unsupported operand type(s) **: 'int' , 'foo' . have overridden c#-recognized operators using operator keyword; both foo / int , int / foo functioning successfully. there way __pow__() ? thank in advance.

Javascript vs HTML (Which takes more time to load) -

what better off having lengthier javascript or lengthier html. few things- 1. don't care seo ratings. 2. care speed of site. 3. care functionality of web site. basically question core coders- whats better - <div> blah blah blah blah </div> or document.getelementbyid("blah").innerhtml = "blah blah blah blah" ? knowledge welcome :). thank you. having browser render plain html faster having load javascript, wait dom ready, , use javascript manipulate dom. even if ignore fact browser has more work when manipulating dom via javascript, think going take longer download: 30 characters: <div>blah blah blah blah</div> or 50+ characters (too lazy count): <script> document.getelementbyid("blah").innerhtml = "blah blah blah blah"; </script> so going javascript route you're both downloading more content server , asking browser more work render page.

Help with Java Multithreading -

alright, sort of dual-purpose question. main thing hope take away more knowledge of multithreading. complete newbie when comes multithreading, , first actual attempt in multiple threads. other thing hope take away piece of homework turning more complicated franken-project fun , learning. in first part of question going detail thinking , methodology threads have been working on in homework assignment. if doing bad practice, needs fixed, whatever, please let me know can learn. again, know practically nothing multithreading. first off, taking computer science course which, nice it, has homework uses techniques , data structures i've learned , not challenging. attempt not entirely bored out of skull, trying take simple project (creating linked list , sorted linked list) , turn multi-threaded franken-program. method adding new elements in separate thread , gets input queue (not entirely necessary un-ordered list, more useful proper ordering), , ordered list want separate thread pa...

architecture - WCF / WCF Data Services / WCF RIA Services -

not add post regarding different wcf stacks, want make sure i'm heading in right direction before waste more development time... my scenario - our company has number of web apps access same series of databases. apps developed independently, there's ton of business logic , data access repetition. on top of that, have (possibly unreasonable) goal of making project client-independent - consolidate our current business logic , data access interface can accessed web app, silverlight, mobile app, etc. enter wcf - strikes me perfect option accomplish both. unfortunately, after reading existing "guidance" exists on various wcf flavors, keep coming more confused anything. here conclusions i've come far - please feel free correct me: straight wcf - flexible , comprehensive option, starts scratch; require significant time front configure , test; technically mature option hooks accomplish of goals wcf data services - fastest way of getting rest service online; exce...

data binding - WPF Databinding TextBox to integer property in another object -

i have think simple databinding question (i'm still new wpf). have class (simplified question) public class configurationdata { public int baudrate { get; set; } } in mainwindow.xaml.cs have private member variable: private configurationdata m_data; and method void dostuff() { // bunch of stuff (read serial port?) may result in calling... m_data.baudrate = 300; // or other value depending on logic } in mainwindow gui, i'd have textbox displays m_data.baudrate , allows 2 way binding. user should able enter value in textbox, , textbox should display new values we're caused "dostuff()" method. i've seen tons of examples on binding property of control on mainwindow, , binding datacollection, no examples of binding property of object. think example simple get, nagging annoyance i'm binding integer, not string, , if possible, user able enter integers. btw considered using numeric up/down, decided against there did not seem lot of su...

java - capture video from a built-in camera programatically -

i wandering how capture video built-in camera of netbook, under linux, ubuntu. programming language not issue (but prefer java or old school c) thanks in advance answers, gian in linux canonical way of talking webcams via v4l . here library called libfg simple high level c api on top of v4l .

C# Appending Linq Queries of Same Type -

i have 2 linq queries run on 2 different tables, car , truck. these queries select id, name, , company. var car = c in db.cars select new {id = c.id, name = c.name, company = c.company}; var truck = t in db.trucks select new {id = t.id, name = t.name, company = t.company}; how append truck data car data using linq resultant query contains both car , truck data? if resulting types equivalent, can use enumerable.concat combine them. however, wouldn't recommend doing anonymous types - instead i'd recommend making custom class hold 3 (or more) properties. it's possible, given code above, type may same post-compilation, it's impossible tell sure without more information. personally, either use shared interface (ie: have car , truck implement icompanyinfo properties in interface), , return car cast interface, or make custom class, , return both queries, use concat join them.

logic programming - yap prolog read predicate -

i experimenting prolog, reading "programming in prolog using iso standard, fith edition". have installed yap (yet prolog) on ubuntu 10.10 maverick rc system, installed using synaptic. running prolog within emacs23 using prolog-mode. the following code (from chapter 5 of book) not give results in book: /* file history_base.pl */ use_module(library(lists)) /* use member/2 */ event(1505,['euclid',translated,into,'latin']). event(1510,['reuchlin-pfefferkorn',controversy]). event(1523,['christian','ii',flies,from,'denmark']). mywhen(x,y):-event(y,z),member(x,z). % restoring file /usr/lib/yap/startup yap version yap-5.1.3 < reading above file yap> ?- mywhen("denmark",d). no not book gives! adding file above line (from book): hello1(event):- read(date), ev...

Quicksort (JAVA) -

lets have array of size n randomly generated elements , want use quicksort sort array. large enough n (say 1,000,000), in order speed quicksort, make sense stop recursing when array gets small enough, , use insertion sort instead. in such implementation, base case quicksort value base > 1 . optimal base value choose , why? think time complexity of quicksort (average , worst case) , time complexity of other sort might better small n.

error in asp.net page? is not valid Virtual path? -

i developed 1 application in asp.net , working fine in locally. when upload in online giving error this. ~/user/news/completenews.aspx?newsid=-<span-style="font-weight:-bol.html' not valid virtual path. my code in indiex page if (e.commandname == "hollywood") { session["videopath"] = "~/index.aspx"; session["pagetitle"] = "back home page "; string hollywoodnews = e.commandargument.tostring(); response.redirect("~/user/news/completenews.aspx?newsid=" + hollywoodnews.tostring().replace("","-")+ ""); } can u me please. this .aspx code <asp:datalist id="datalist2" runat="server"> <itemtemplate> <table cellpadding="0" cellspacing="0" align="left" valign="top"> <tr> <td></td...

scripting - Insert text between two marker lines in bash -

i have lines stored in text file called bashrc_snippet . insert them .bashrc . since change contents of text file able re-insert them in .bashrc-file. want use marker lines: # user things histsize=1000 #start alias ls='ls --color=tty' ... more lines #end i bash script (possibly using sed or awk). algoritm should be: if marker lines missing add them @ end of file (and lines of text) if marker lines present, replace contents between them new lines of text don't understand requirement, here's guess #!/bin/bash rcfile="$1" snippet="$2" var=$(<"$snippet") if grep -q "start" "$rcfile" ;then awk -v v="$var" '/start/ { print $0 print v f=1 }f &&!/end/{next}/end/{f=0}!f' "$rcfile" >t && mv t "$rcfile" else echo "#start" >> "$rcfile" echo "$var" >> "$rcfile" echo ...

javascript - Rewriting the JS String Constructor: Am I Way Off? -

i'm on way through object oriented javascript, , can't feel i've missed boat on given exercise. i'm looking here pointers on how can improve code or understanding of constructors. here the challenge : imagine string() constructor didn't exist. create constructor function mystring() acts string() closely possible. you're not allowed use built-in string methods or properties, , remember string() doesn't exist. can use code test constructor: -- var s = new mystring('hello'); s.length(); s[0]; s.tostring(); s.valueof(); s.charat(1); s.charat('2'); s.charat('e'); s.concat(' world!'); s.slice(1,3); s.slice(0,-1); s.split('e); s.split('l'); s.reverse(); and here response, fails on 1 or 2 accounts, i'm more interested in actual structure of it. off-base? there somewhere can view actual string constructor implemented browsers compare? function mystring(string){ ...

c# - Logging custom classes through WebService using NLog -

problem follows: on log event want send custom object (lets logmessage wraps in way logging event) web service. work appenders in log4net, or there kind of thing in nlog btw? or how do nlog way? note: i'm using webservice target wrapper (if helps in way). [edit] have added links rather telling look. nlog has logreceiverservice , logreceiverservicetarget (these might have been added nlog 2.0 went beta recently). can tell, 1 way use service use nlog logging in app. configure send logging messages logreceivertarget. configure logreceivertarget point logreceiverservice. logreceivertarget create "nlogevents" log messages , forward them logreceiverservice. logreceiverservice convert "nlogevents" logevents , log them via nlog. in other words, logging via nlog in app , logreceiverservice logging via nlog. i posting iphone harder me add links relevant nlog topics. go nlog website , documentation on logreceiverservice. in forum . there has been traf...

asp.net - HttpContext.Current.User.Identity.Name not right when simultaneous login from 2 machines -

i've got asp.net webserver iis 7. my authentication code (forms authentication) follows on login page: var isauthenticated = membership.validateuser(usernametextbox.text, passwordtextbox.text); if (isauthenticated) { formsauthentication.redirectfromloginpage(usernametextbox.text, true); } else { var customvalidator = new customvalidator(); customvalidator.isvalid = false; customvalidator.errormessage = getlocalresourceobject("loginfailed.errormessage").tostring(); customvalidator.validationgroup = "allvalidators"; page.validators.add(customvalidator); } and on page display username: if (httpcontext.current.user.identity != null && !string.isnullorempty(httpcontext.current.user.identity.name)) { string authenticatedusername = httpcontext.curre...

Hudson: "missing the Extended Read permission" -

i log hudson admin left hand column remain same normal non-admin user. have tried - delete account , create new 1 admin rights. delete cookies tried on different browsers type in link configuration page, throw "missing extendedread permission" error. none of above work, have suggestion on issue? just put far. please fill baps if there any. you use extended read permission plugin configured user in hudson. use "hudson's own user database" or else? the plugin description says adds column "matrix-based security" or "project-based matrix authorization strategy" authorization stream. use 1 of these two? now getting confused missing admin. use "project-based matrix authorization strategy". when configured global administration permission. have full control on hudson , jobs running on hudson. to able you, please describe setup pertains authorization settings in detail. have other plugins installed might inte...

php - PHPExcel Export for Larger Files fails -

i using phpexcel library generate excel data based on mysql datbase. mysql query results in 1,34,000 rows. , excel supports 65,536 rows on 1 worksheet. made logic foreach($result $value) { $val = array_values($value); if($rowscounter < 65000) { $objphpexcel->addrow($val,$rowscounter); } else { $active_sheet++; $objphpexcel->createsheet(); $objphpexcel->setactivesheetindex($active_sheet); $rowscounter = 1; } $rowscounter++; } // deliver header header("content-type: $mtype; charset=" . $objphpexcel->sencoding); header("content-type:application/octet-stream"); header("content-disposition: inline; filename=\"" . $filename . ".$ext\""); // save excel 2003 file $objwriter = iofactory::createwriter($objphpexcel,$objphpexcel->sfileformat); //echo "peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " mb";exi...

java - what's the best way to apply a mask to an EditText on Android? -

what's best way mask edittext on android? edittext behave decimal number input here . there easy way this? you have programmatically set inputfilter on edittext setfilters . from documentation: inputfilters can attached editables constrain changes can made them. you can change users input, example adding decimal point want if correctly.

linux - Question about zombie processess and threads -

i had these questions in mind since reading new topics on processes , threads. glad if me out. 1) happens if thread marked uncancelable, , process killed inside of critical section? 2) have main thread program known operating system? mean operating system give first thread of program beneficial rights or something? 3) when kill process , threads not joind, become zombies? first, don't kill or cancel threads, ask them kill themselves. if kill thread outside never know side effects - variables, state of synchronization primitives, etc.- leave behind. if find necessary 1 thread terminate have problematic thread check switch, catch signal, whatever, , clean state before exiting itself. 1) if uncancelable mean detached, same joined thread. don't know mess leaving behind if blindly killing it. 2) application level viewpoint primary thing if main thread exits() or returns() going take down other threads it. if main thread terminates pthread_exit() remaining ...

How to join four tables with MySQL -

i have omc_projects, omc_logs,omc_specs , omc_files. all of omc_logs,omc_specs , omc_files table has field called project_id. create table if not exists `omc_projects` ( `id` int(10) not null auto_increment, ... primary key (`id`) ) ... ; create table if not exists `omc_files` ( `id` int(11) not null auto_increment, `project_id` int(11) not null, ... primary key (`id`) ) ... ; create table if not exists `omc_logs` ( `id` int(10) not null auto_increment, `project_id` int(10) not null, ... primary key (`id`) ) ... ; create table if not exists `omc_specs` ( `id` int(10) not null auto_increment, `project_id` int(10) not null, ... ... primary key (`id`) ) ... ; now making delete function in model check if there files, specs or logs this. function checkproject($id){ // if there data in 1 of table, returns true $query = 'select omc_projects.id, omc_specs.id, omc_logs.id, omc_files.id omc_projects join omc_specs on omc_specs.projec...

How to send parameter in query string on ajax call in asp.net mvc -

i want send selected page value on querystring while navigating through paging. the url generated paging this: link/index?page=2 link/index?page=3 but on url shows link/index , performs ajax call. if disable javascript , navigate through paging gets postback , has url like link/index?page=2 which perfect. want type of url in ajax call well. how can this? issue if navigate through pages when javascript enable shows link/index , when user goes page no 2 3 4 , press button goes press page instead of page 3 page 2. here code generates page links: <%= ajax.pager( new ajaxoptions { updatetargetid = "divgrid", loadingelementid = "divloading" }, viewdata.model.pagesize, viewdata.model.pagenumber, viewdata.model.totalitemcount, new { controller = "linkmanagement", action = "index" } )%> this isn't issue pager, that's how ajax works. becaus...

MSBuild ItemGroup Include/Exclude pattern issue -

problem: itemgroups array isn't correctly build based on value passed in exclude attribute. if run scrip creates sample file tries create array called thefiles based on include/exclude attributes, problem when exclude other hardcoded or simple property gets wrong. the target dynamicexcludelist's incorrectly selects these files: .\afolder\test.cs;.\afolder\test.txt the target hardcodedexcludelist's correctly selects these files: .\afolder\test.txt any appreciated, driving me nuts. (note msbuild v4) <project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" defaulttargets="run"> <target name="run" > <calltarget targets="createsamplefiles" /> <calltarget targets="dynamicexcludelist" /> <calltarget targets="hardcodedexcludelist" /> </target> <target name="createsamplefiles" > <maked...

iphone - Apple Push Notification Service with PHP Script -

i'm trying send push notifications ton iphone (apns). read post , try implement it. certificates (normaly). now have php script : $device = '4f30e047 c8c05db9 3fa87e7d ca5325f7 738cb2c0 0b4a02d4 d4329a42 a7128173'; // iphone devicetoken $payload['aps'] = array('alert' => 'this alert text', 'badge' => 1, 'sound' => 'default'); $payload['server'] = array('serverid' => $serverid, 'name' => $name); $output = json_encode($payload); $apnscert = 'apple_push_notification_production.pem'; $streamcontext = stream_context_create(); stream_context_set_option($streamcontext, 'ssl', 'local_cert', $apnscert); $apns = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $error, $errorstring, 2, stream_client_connect, $streamcontext); $apnsmessage = chr(0) . chr(0) . chr(32) . pack('h*', str_replace(' ', '', $device)) . chr(...

android - How do I add a custom view to ViewFlipper -

i have viewflipper defined contains 3 views... <?xml version="1.0" encoding="utf-8"?> <viewflipper xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/flipper" android:layout_width="fill_parent" android:layout_height="fill_parent"> <include android:id="@+id/first" layout="@layout/first_view" /> <include android:id="@+id/second" layout="@layout/second_view" /> <include android:id="@+id/third" layout="@layout/third_view" /> </viewflipper> i have custom view defined within activity... private class compassview extends view { @override protected void ondraw(canvas canvas) { ... } } some how, need these linked 'third_view' defined in xml layout file needs compassview, or have compassview added it. what can drop 'third_view' layout , add in compassview manually.. view...

objective c - Error messages when using OpenGL ES template -

i made new opengl es application, , without modifying anything, ran program. runs, see these error messages: detected attempt call symbol in system libraries not present on iphone: open$unix2003 called function _zn4llvm12memorybuffer7getfileepkcpssx in image libllvmcontainer.dylib. detected attempt call symbol in system libraries not present on iphone: fstat$inode64 called function _zn4llvm12memorybuffer7getfileepkcpssx in image libllvmcontainer.dylib. detected attempt call symbol in system libraries not present on iphone: mmap$unix2003 called function _zn4llvm3sys4path14mapinfilepageseiy in image libllvmcontainer.dylib. detected attempt call symbol in system libraries not present on iphone: close$unix2003 called function _zn4llvm12memorybuffer7getfileepkcpssx in image libllvmcontainer.dylib. detected attempt call symbol in system libraries not present on iphone: pthread_mutexattr_destroy$unix2003 called function _zn4llvm3sys5mutexc2eb in image libllvmcontainer.dylib. the progr...

.net - c# Granting "Log On As Service" permission to a windows user -

how grant user logonasservice right service? i need manually, in services.msc app can go service, change password (setting same there before), click apply , message: the account .\postgres has been granted log on service right. how do code, because otherwise have give permission hand each time run application , not possibility @steve static void main() { // irrelevant stuff grantlogonasserviceright("postgres"); // irrelevant stuff } private static void grantlogonasserviceright(string username) { using (lsawrapper lsa = new lsawrapper()) { lsa.addprivileges(username, "seservicelogonright"); } } and lsa lib guy willy. see granting user rights in c# . you have invoke lsa apis via p/invoke, , url has reference wrapper class you. code end simple: private static void grantlogonasserviceright(string username) { using (lsawrapper lsa = new lsawrap...