Posts

Showing posts from June, 2013

c# - Active Directory - Find a computer in a group -

i trying simple ad query see if computer in group. following code seems intuitive enough not work. ldapstring distinguised name group computer referenced netbiosname memberof. public bool iscomputerinadgroup(string ldapstring, string netbiosname) { using (directoryentry entry = new directoryentry(string.format(@"ldap://{0}", ldapstring))) using (directorysearcher computersearch = new directorysearcher(entry)) { computersearch.filter = string.format("(&(objectcategory=computer)(cn={0}))", netbiosname); searchresult match = computersearch.findone(); if (match != null) { return true; } } return false; } can please explain why incorrect , correct/fastest way to perform search is. thanks p your basic assumption wrong - computer (or user) cannot in group implying "containment" inside group; user or computer inside ou. a user or computer can member of number of gr

php - Getting error * JFolder::create: Path not in open_basedir paths * Warning! Failed to move file -

when want installed zip file of new component or module.i getting below error * jfolder::create: infinite loop detected * warning! failed move file. how can resolved this. this due move joomla working 1 server or local pc web server. follow steps below fix it. goto hosting panel >> file manager >> select domain/sub-domain , open configuration.php file. find var $log_path, contain directory path of old server. replace whole line code var $log_path = './logs'; find var $tmp_path, have directory path of old server. replace whole line code var $tmp_path = './tmp';

asp.net - Ignoring specific query string parameters in custom sitemapprovider -

i’ve written own staticsitemapprovider builds dynamic site map. problem have pages have additional parameters in query string need ignore. public overrides function findsitemapnode(byval rawurl string) sitemapnode dim startpos integer = 0 dim endpos integer = 0 if rawurl.contains("pagetype=") startpos = rawurl.indexof("pagetype=") endpos = rawurl.indexof("&", startpos) + 1 if endpos >= startpos 'not last param rawurl = rawurl.remove(startpos, endpos - startpos) else 'must last param rawurl = rawurl.remove(startpos) end if end if return mybase.findsitemapnode(rawurl) end function i've overridden findsitemapnode function takes in httpcontect object. simple find url of request , run though same function above. however sitemappath (which bound site map) returns nothing on every page. in end turned out simple

java - how can i have a list of icons in my android app; -

can 1 suggest how can have list of icons browser icon,email icon , contacts icon upon clicking on should lead android browser,email , contacts apps respectively...right have done it, upon clicking buttons. want icons(with image , text) instead of buttons. i think need use this: <linearlayout android:orientation="vertical"> <imageview android:src="@drawable/icon" android:onclick="launchapp" /> <textview android:text="@string/icon_name" android:onclick="launchapp" /> </linearlayout> and in code should have corresponding method: public void launchapp(view view) { // }

Convert time string in XSLT -

how convert time string like 20101115083000 +0200 to 2010-11-15 08:30:00 +0200 using xslt? we use templates: <xsl:template name="format-date-time"> <xsl:param name="date" select="'%y-%m-%dt%h:%m:%s%z'"/> <xsl:value-of select="substring($date, 9, 2)"/> <xsl:text>/</xsl:text> <xsl:value-of select="substring($date, 6, 2)"/> <xsl:text>/</xsl:text> <xsl:value-of select="substring($date, 1, 4)"/> <xsl:text> </xsl:text> <xsl:value-of select="substring($date, 12, 2)"/> <xsl:text>:</xsl:text> <xsl:value-of select="substring($date, 15, 2)"/> <xsl:text>:</xsl:text> <xsl:value-of select="substring($date, 18, 2)"/> </xsl:template> we call these templates this: <xsl:call-template name="format-date-time"&g

tsql - Are the 'inserted' and 'deleted' tables guaranteed to return their records in the same order in an AFTER UPDATE trigger? -

if have after update trigger, will select * inserted and select * deleted give me records in same order? i.e. lets able index result sets, del[5] , ins[5] give me matching entries, if 1 value of compound primary key has changed (which reason why inner join won't work). i don't believe there any guarantee on ordering of rows within inserted , deleted - there no ordering guarantee selecting table, without specifying order by. i decided see if produce script demonstrate lack of ordering. on machine (sql 2008 dev), can repeatably run following script. outputs 2 rows inserted , deleted. note don't touch id column, , if supposition correct (that ordered in way), same ids should appear in same order. not case here. first, outputs: id d1 v1 ----------- ----------------------- ---------------------------------------------------------------------------------------------------- 32 2010-03-01 00:00:00.000 text 60

asp.net - Inheriting 2 classes in C# - how to handle this -

i need inherit 2 classes ( 3rd party classes). (class1) - system.web.ui.mobilecontrols.mobileusercontrol (class2) - portalmodulebase i have usercontrol... inherit "portalmodulebase" class, time need inherit "system.web.ui.mobilecontrols.mobileusercontrol" in usercontrol (.ascx). i read in this article multiple inheritance interface same results when goolge think doesn't solve problem.... i read, it's not possible in c#... but how workaround this? thanks, it's vs2008 -asp.net have @ this article . describes way, uncomfortable use.

java - gwt dynamic adding textbox -

@uihandler("adddynamictextboxbutton") void addmoretextbox(clickevent event) { textboxplaceholder.add(new textbox(),"textboxplace"); } when adddynamictextboxbutton button clicked, method executed , new textbox created. how have button, when click, values each of "textbox()" ? or necessary put name "new textbox("name")" can values? best practice way this? if textboxplaceholder , extend of complexpanel , example flowpanel iterate on children of flowpanel : for (widget w: textboxplaceholder) { if (w instanceof textbox) { // value: ((textbox)w).getvalue(); } }

How to transfer set of text from file to file using two identifiers using PHP? -

this code below can migrate 2 variables 1 file other. <?php $file = 'somefile.txt'; // open file existing content $current = fopen($file,'a'); // append new person file $firstname .= "aiden\n"; $secondname .= "dawn\n"; $currentcontent = file_get_contents($file); // write contents file $filefound = 'people.txt'; $newfile = fopen($filefound,'a'); //if $current , $nextcurrent found in somefile.txt transfer content people.txt if (strpos($currentcontent,$firstname) !== 0) { if (strpos($currentcontent,$secondname) !== 0) { fwrite($newfile, $currentcontent."\n"); } // endif }// endif ?> the next problem is, how able migrate texts identifier 1 identifiers two? guess i'll have use substr or strrpos string here. please :) i'm having hard time understanding problem looks you're trying include between 'aiden' , 'dawn' file , write result new file. give shot one $firstident

regex - How to php regular expression get the final part of the url? -

hi, if there have many url address. http://www.aaa.com/dd/cc/ee http://www.bbb.com/ff/gg http://www.ccc.com/hh/jj/kk/ll how use php regular expression final part of url? ee , gg , ll it might easier use basename() instead of regex: basename('http://www.ccc.com/hh/jj/kk/ll', '/');

In Android, How to stream live video from Live Stream? -

any suggestion live stream android. in app need stream live video live stream.. there api or example it? if so, please provide it. i need this... http://www.livestream.com/aplive?utm_source=website-home&utm_medium=promo-header&utm_campaign=aplive thanks, jana. there's information api here http://www.livestream.com/platform/developer it's flash development. you may able make work android.

android - Customize ListView ContextMenu colors -

i need change colors and/or style of contextmenu when long press item of listview. i've looked everywhere answer , cannot find related contextmenu customization. is possible? thanks! contextmenu can not customized. way make behaves similar. try example .

How to develop .Net services when not logged in as administrator -

is there easy way develop services in .net when i'm not running administrator? there couple problems encountered. first of when debugging, can't press f5 visual studio, says services must first installed , run services administrator tool. problem without administrator rights, can't create or control services. using windows server 2008 ad manage our users. there specific set of rights can give users can add/remove/start/stop services? if want developers accessing services created themselves? also, once service running, what's best way debug it. assuming service started, , running, visual studio attach running process, there better way debugging can begin entry point of service? one thing tend when working services create console app run code during development. means have have service thin layer on code work, can call code console app, that's not bad idea anyway. i know doesn't answer question, might helpful!

Jquery array filtering - grep()? -

how can sort array 1 shown below jquery's own functions? assume grep() 1 should looking at? thanks! the array: array ( array( 'id' => 0, 'name' => 'myname', 'weight' => 100 ); array( 'id' => 1, 'name' => 'myname2', 'weight' => 150, ); ); edit: it's php array clarify things - im not sure how write proper javascript (json?) array? first, i'm going assume you're talking javascript array looks this: var myarray = [ { id: 0, name: 'myname', weight: 100 }, { id: 1, name: 'myname2', weight: 150 } ] you can call native javascript function sort() on array. in case, you'll need provide function callback. needs defined syntax function (a, b) . a , b elements in array. need return -1 if a should higher ranked b in a

winapi - How to hide a window in Windows 7, just like desktop managers do -

when install virtual desktop manager on windows 7, , switch different virtual desktop, current windows disappear, disappearing start menu. i want hide of particular application's windows, not of them, in similar manner. how can hide window this? in particular, need hide virtualbox seamless mode window, i'm not sure minimizing window work. does, however, disappear when using virtual desktop managers. the same window cannot appear on multiple desktops. if need application window appear on multiple desktops need create separate window each desktop. desktop window appears on depends on thread creates window. can change desktop thread assignment using setthreaddesktop function.

sql - Insert output IDs into another table -

i have status table, , table containing additional data. object ids pk in status table, need insert additional data table each new row. i need insert new row statustable each new listing, containing constants. declare @temp table(listingid int) insert statustable(status, date) output inserted.listingid @temp select 1, getdate() anotherimportedtable this gets me enough new listing ids use. i need insert actual listing data table, , map each row 1 of listingids - insert listingextradata(listingid, data) select t.listingid, a.data @temp t, anotherimportedtable now doesn't work, because otherdatatable , ids in @temp unrelated... far many rows inserted. how can insert each row anotherimportedtable listingextradata along unique newly created listingid ? possibly trigger more sql @ point output in first block of sql? edit : input far, here's tables like: anotherimportedtable : data statustable : listingid (pk), status, date listingextradata : data

animation - matrix.translate vs matrix.translate3d webkit ipad -

the following code part of webkit transition ipad app: #canvas { -webkit-transition-property: -webkit-transform;; -webkit-transition-duration: 1s; -webkit-transition-timing-function: ease-out; position:absolute; z-index:1; } ... var containertrsfrm = window.getcomputedstyle(currentcanvas).webkittransform; var matrix = new webkitcssmatrix(containertrsfrm); matrix = matrix.scale(1.5, 1.5); currentcanvas.style.webkittransform = matrix.translate(100, 100); but if change matrix.translate(x,y) matrix.translate3d(x,y,z) stops working. now, wanna make change because read in several places supported hardware acceleration , flickering occurs when executing code above, go away. can help? i spent few hours on flicker problem @ end of animations in webkit transforms / ipad /ios / webwiew. what found object being transformed placed on top of other objects in window during transform , @ end of transform, objects ha

windows - How does NetTcpBinding(read WindowsStreamSecurityBindingElement) encrypt/sign messages? -

i wanted understand mechanism of message encryption , signing used nettcpbinding when 'windows' credentials being used transport security. if ad uses ntlm instead of kerberos? messages still signed , encrypted?if so, how? thanks in advance, akshat the short answer that, yes, ntlm authentication messages still signed , encrypted if have set transport security protectionlevel encryptandsign (the default). here's outline of how works: selecting transport security configures windowsstreamsecuritybindingelement in channel stack. inserts stream upgrade provider (see below) in nettcpbinding, message exchange between client , service happens within .net message framing protocol , provides both message framing , mechanism client , service negotiate stream upgrades, principal use of establish transport security. if there stream upgrade provider configured in channel stack, invoked during preamble stage of framing protocol when client opens channel. the upgrad

Is it possible in Java read files placed in a Jar that it's placed in a Ear too? -

i wondering if possible find content in xml file placed in jar thath placed in ear too. me find properties of java beans. up ear can iterate through documents , see what's inside, if jar can't iterate documents inside that. someone can give me advice? from ear file should able extract jar file. can use winzip , 7 zip , etc explore jar file contents gui. or can run jar tf command extract content of jar file in command line. if don't have of these tools , using windows, can rename jar file .zip , windows should able explore (most of cases works). edits - not sure if wanted using java. in case looking jarfile . found example of here exploring jar contents programatically.

excel - VBA VLOOKUP Convert to Values Gives #N/A -

i'm having trouble vlookup in vba. here's example of code i'm using: sub macro15() ' ' macro15 macro dim lr long lr = cells(rows.count, "a").end(xlup).row range("b1:b" & lr).formular1c1 = _ "=vlookup(rc[-1],'https://internal_sharepoint_address /[vendor_information.xlsx]sheet1'!r3c3:r150c18,4,false)" range("c1:c" & lr).formular1c1 = _ "=vlookup(rc[-2],'https://internal_sharepoint_address /[vendor_information.xlsx]sheet1'!r3c3:r150c18,5,false)" range("b1:c" & lr) .value = .value end end sub the problem values in columns b & c (the vlookup formulas) return value of #n/a. however, if stop code before converting formula values (the "with range("b1:c" & lr)" line), vlookup formula returns correct values. also strange - if clear contents of columns b & c , re-run above code, values return fine. if try add second cycle vba, however, no

Display Page Load Time in Rails 3 -

how can display page load time in view, similar how log file shows "completed 200 ok in 19ms (views: 16.8ms | models: 0.497ms)" you might want use seconds better: class applicationcontroller < actioncontroller::base before_filter :set_start_time def set_start_time @start_time = time.now.to_f end end view code: page rendered in <%= sprintf('%.3f', (time.now.to_f - @start_time) ) %> seconds

How to make mercurial notify work for other people's push when they don't trust the repo's owner? -

i have team repo setup in our lan, , it's group writable can freely push. (note: repo purely experimentation don't want limit/check on push.) now want use notify extension send email whenever push happens. works fine own push, not work others unless trust user, otherwise hg push doesn't read repo's hgrc , no notification. i don't want force blindly trust me (because use hook/extension steal bank accounts--evil grin). there alternative? (they describing problem others helps solving yourself. happened again.) the trivial solution add relevant notify config items other team members's user hgrc.

c++ - Using Qt's QGraphicsScene/QGraphicsView for 2D games -

has of guys ever tried writing 2d game in c++ using qt's qgraphicsscene/qgraphicsview classes purpose of rendering , collision detection? perform if there many moving/animated objects on scene? there caveats? in general, can point me games written using qt's graphics facilities? thanks in advance. i tried use them rendering. don't perform well, besides qt not adapt game: they're pretty heavy library doing lots of stuff. event handling not lightweight. if it's simple game should ok; api easy use , can set use opengl or software rendering flag. if want write real game should opt else, thought games.

Java client-server application example -

please advice can see source code example of simple client-server application (code both)? maybe this had in mind.

xcode - iPhone - Wheel tracking finger jumps to same starting position? -

i trying implement selection wheel in iphone application. have got wheel track users finger reason when user touches screen wheel jumps same section of wheel tracks finger each time. how wheel rotates user dragging point? -(void) touchesmoved:(nsset *)touches withevent:(uievent *)event { nsset *alltouches = [event alltouches]; int tinput = [alltouches count]-1; uitouch *touch =[[alltouches allobjects] objectatindex:tinput]; cgpoint location = [touch locationinview:self.view]; float theangle = atan2( location.y-imagex.center.y, location.x-imagex.center.x ); cgaffinetransform cgarotate = cgaffinetransformmakerotation(theangle); imagex.transform = cgarotate; } any suggestion? right - makes perfect sense - indeed code does. what need add initial value started drag relative rotation -- or track last rotation. a elaborate way shown below - should point across. @interface untitledviewcontroller : uiviewcontroller { cgpoint firstloc; uilabel * fred

wcf ria services - Silverlight 4 toolkit DataForm including blank items when browsing through collection -

i have simple dataform created reads address information. address information stored across multiple tables: address, city, province, country. simplify question, refer address , city. i'm accessing data through wcf ria services context. query in service is: public iqueryable<address> getaddresses() { return ad in objectcontext.addresses .include("city") // .include("city.province") // .include("city.province.country") ad.addressid == 10 select ad; } to debugging, i've limited result set 1 address (where ad.addressid ==10). in service metadata city table included: [include] public city city { get; set; } my dataform's read template looks like: <dataformtoolkit:dataform.readonlytemplate> <datatemplate> <grid> <grid.rowdefinitions> &l

gcc - x86 assembly to get register as int? -

the portable way of accessing bits in fp representation write union, writes memory. @ least, that's glibc does. code below looks wildly overcomplicated, slow. i'm wondering whether there x86 instruction copy 64 accessible bits of fp register integer register bits can manipulated? wouldn't portable, idea have inline function, , each port has implement standard clean (and fast) routine. in case i'm looking @ isnan, implemented as: #define extract_words(ix0,ix1,d) \ { \ ieee_double_shape_type ew_u; \ ew_u.value = (d); \ (ix0) = ew_u.parts.msw; \ (ix1) = ew_u.parts.lsw; \ } while (0) int __isnan(double x) { int32_t hx,lx; extract_words(hx,lx,x); hx &= 0x7fffffff; hx |= (u_int32_t)(lx|(-lx))>>31; hx = 0x7ff00000 - hx; return (int)(((u_int32_t)hx)>>31); } there no x86 instruction copy fp register i

megamenu - jQuery: menus appear/disappear on click -

i've been looking on web , can't find solution. new jquery well. my case: i have nav bar, each link in activates/triggers megamenu (each link has own megamenu). what need: i need way have each link activate own megamenu, megamenu should close when: the user clicks on item in nav bar. the user clicks on same item in nav bar. the user clicks on 'close button' (x) graphic inside megamenu (not shown in html simplicity sake). html: <div id="top-nav"> <ul> <li><span>products &amp; services</span> <ul> <li><div class="megamenu">content here...</div></li> </ul> </li> <li><span>support &amp; training</span> <ul> <li> <div class="megamenu">content here...</div></li> </ul> </li> <li><span>communities</span> <ul> <li>

java - Array variable input help [close] -

first of all, have create array of length n, input variables fill array, @ array location k, have push arrays location k , 1 , put value of x array location k. if k = n, put x in n+1. first of all, having problem making ints k , x work. reason code sets n first input , sets k , x same n when n set. secondly, having trouble extending array n+1. know don't give me answer need direction on go. import java.util.scanner; public class hw2 { public static void main(string[] args) { scanner scan = new scanner(system.in); int n = scan.nextint(); int k = scan.nextint(); int x = scan.nextint(); int[] = new int[n]; for(int = 0; i<n; i++) { a[i] = scan.nextint(); } n++; final int length = a.length - 1; for(int j=length; j>k; j--) { a[j] = a[j-1]; } a[k] = x; for(int h = 0; h < n; h++) { system.out.println("location " + h + " " + a[h]); } } } sample input n k

c# - What is the best wayto add single element to an IEnumerable collection? -

i'm surprised see there not appear method add single element ienumerable collection. how can add single element ienumerable collection? you can't add elements ienumerable it's supposed read only. best bet either like: return new list<foo>(enumerable){ new foo() }; or return enumerable.concat(new [] { new foo() });

python - Why is save not working in Django? -

i'm using manage.py shell , run this: >>>d=document.objects.get(pk=1) >>>d.scores {1:0,2:0,3:0} >>>d.scores[1]=5 >>>d.scores {1:5,2:0,3:0} >>>d.save() but viewing d in database reveals hasn't been updated. doing wrong?? checked out what's here , d document instance. if helps, model.py looks this: from django.db import models class document(models.model): filename=models.charfield(max_length=200) fileurl=models.charfield(max_length=200) scores={1:0,2:0,3:0} your 'scores' class variable isn't instance of of django's *field classes. imagine 'scores' field isn't on table in db, since field classes defines of that, , gets saved db, among other things.

python - Range with step of type float -

this question has answer here: how use decimal range() step value? 26 answers the documentation says range must behave implementation (for positive step ): def range(start, stop, step): x = start while true: if x >= stop: return yield x x += step it says arguments must integers. why that? isn't definition valid if step float? in case, esp. needing range function accepts float type step argument. there in python or need implement own? more specific: how translate c code directly python in nice way (i.e. not doing via while -loop manually): for(float x = 0; x < 10; x += 0.5f) { /* ... */ } you use numpy.arange . edit: docs prefer numpy.linspace . thanks @droogans noticing =)

sql - For NUMBER columns in Oracle, does specifying a length help performance? -

is there true difference in performance between number, number(3) , number(10)? doesn't rdbms use 32 bits store value regardless, , limit length of data when looked @ string? a colleague debated was, example, more efficient use number(10) vs number/number(11), thinking n number of bytes rather length of data in characters. i'd agree limit column size if number of rows guaranteed not exceed 10^n or so, particular database limit number of rows literally "as many possible", e.g. 2^32 or ~4 billion, though we'd never reach amount. coming "lowest maximum" situation seems pointless , waste of time , thought using number without specifying length simpler , incur no penalties. correct? technically, don't define length, precision , scale. the same numeric value (eg 100, 4.3) takes same internal value irrespective of precision , scale defining column. the maximum value column can hold determined both precision , scale. can store value 100 i

regex - Regular Expression to search overlapping pattern -

this simplified version of problem: i'm trying extract letters surrounded non-word characters regex doesn't work when non-characters overlap. here's code: var text = "z#a#b#s"; var regex = new regex(@"\w(?<letter>\w)\w"); foreach (var m in regex.matches(text).cast<match>()) { console.writeline("match = {0}", m.value); console.writeline("letter = {0}", m.groups["letter"].value); console.writeline("-------------------"); } i expected match both , b instead matches a. here's output: match = #a# letter = ------------------- this work text "z#a##b#s" (there's no overlap between 2 matches). how can extract both , b text "z#a#b#s"? thanks use behind , ahead var text = "z#a#b#s"; var regex = new regex(@"(?<=\w)\w(?=\w)"); foreach (match m in regex.matches(text)) { console.wri

sql - How many stored procedure calls per transaction? -

i guess it's bit rude ask question, should make effort (more googling) figure out myself, maybe 1 knows answer off top of head. how many stored procedure calls made per transaction (ms sql 2005/2008)? say, created stored procedure triggers on inserts , within java application, commit once insert statements sent. stored procedure trigger @ every insert or after commit? or depends on how set stored procedure? cheers, max the trigger fire once each insert statement. so, stored procedure run each time trigger runs. number of executions not related when transaction committed.

actionscript 3 - Flash file download not working in browser -

i trying download mp3 file in web application using filereference object. works fine in flash environment not work inside browser environment. problem. appreciated. in advance. this security error. 2 things can listen security error events , secondly install debug version of flash player. either 1 give enough info identify issue.

c# - Linq to XML : Problem with colon in the xml tags -

here's code retrieve value in content tag: var returnverse = item in xmltreeverse.descendants("rss").elements("channel").elements("item") select new versemodel { verse = item.element("content").value, url = "" }; here's xml file: <?xml version="1.0" ?> <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/"> <channel> <title>text</title>

c++ - How to Run Only One Instance of Application -

i have application uses socket connection send , receive data application. while creating socket uses port 4998 . that problem lie. once start application socket starts using port 4998. if want execute application again socket binding error. so want limit application instance one. means if application running , 1 tries run application again clicking exe or shortcut icon shouldn't run program, instead should bring existing application top. you may used named mutex. code sample article : winapi winmain( hinstance, hinstance, lpstr, int) { try { // try open mutex. handle hmutex = openmutex( mutex_all_access, 0, "myapp1.0"); if (!hmutex) // mutex doesn’t exist. // first instance create // mutex. hmutex = createmutex(0, 0, "myapp1.0"); else // mutex exists // second instance return. return 0; application->initialize(); application->createform( __cla

javascript - hide html page source -

is there way hide asp.net page view source? if mean, can hide asp.net code : it's not visible in view source. if mean can hide html : can discourage casual peeking creating html on fly via javascript or ajax, developer able see doing, using simple tools firebug , fiddler. edited add: i wasn't thinking of obfuscation (though discourages casual peeking), thinking of using javascript pull down html. doing view source show bunch of <script> tags. but appears question has been revised go in different direction anyway, can keep people downloading images , , answer simple no . making money small numbers of images not viable business model. (if have thousands of images, that's story.) edited add: the conventional way of making catalog of photographs [a] show low-resolution previews, [b] put watermark on each image ( here's example ), or both.

mysql - Datatype for URL -

i read max length of url can 2,000 characters. have therefore table varchar(2000) column type store urls. column can not indexing first 1000 characters shown below. recommended datatype url? mysql> create table myweb(id int not null auto_increment, url varchar(2000), primary key (id)); query ok, 0 rows affected (0.03 sec) mysql> alter table myweb add key (url); query ok, 1 row affected, 1 warning (0.04 sec) records: 1 duplicates: 0 warnings: 0 mysql> show create table myweb\g *************************** 1. row *************************** table: myweb create table: create table `myweb` ( `id` int(11) not null auto_increment, `url` varchar(2000) default null, primary key (`id`), key `url` (`url`(1000)) ) engine=myisam auto_increment=2 default charset=latin1 1 row in set (0.00 sec) your question leaves lot imagination. for 1 thing must assume index's purpose serve primary key avoid duplicates. won't developing application ever says us

c++ - function pointer with known arguments -

i have lot of legacy code uses function pointer argument of form double (*f)(double) . have requirement need call function class function definition uses member variables. do solve issue? example, void legacy_function(double (*f)(double)) { .... } class myclass { double a; double b; double c; void mymethod(...) { // need call legacy_function() such uses , b 1 unknown // a+b*x } note cannot change definitions or declarations in legacy code. i hope making sense. suggestions.. there's no clean way solve problem. has no elegant solution within bounds of standard language. one thing can provide global or static variable serve this pointer intermediate callback wrapper function (see below), , write static intermediate callback wrapper function delecate call non-static class method class myclass { ... static myclass *myclass_this; double callback_wrapper(double d) { assert(myclass_this != null); return myclass_this

iphone - Can the UI Automation instrument be run from the command line? -

is there way open uiautomation instrument through terminal? will possible write applescript open apple's uiautomation tool , load application tested? can please tell me there way through scripting or through command line can open uiautomation , select app tested, select test script? instruments -t /developer/platforms/iphoneos.platform/developer/library/instruments/\ plugins/automationinstrument.bundle/contents/resources/automation.tracetemplate \ <full_path_to_application> -e uiascript <path_to_script.js> \ -e uiaresultspath <output_results_path> for xcode >= 4.5 instruments -t /applications/xcode.app/contents/applications/instruments.app/contents/plugins/\ automationinstrument.bundle/contents/resources/automation.tracetemplate \ <full_path_to_application> -e uiascript <path_to_script.js> \ -e uiaresultspath <output_results_path> for xcode >= 6.1 instruments -w <device id> -t \ /applications/xcode.app/con

Why has Python decided against constant references? -

note: i'm not talking preventing rebinding of variable. i'm talking preventing modification of memory variable refers to, , of memory can reached there following nested containers. i have large data structure, , want expose other modules, on read-only basis. way in python deep-copy particular pieces i'd expose - prohibitively expensive in case. i sure common problem, , seems constant reference perfect solution. must missing something. perhaps constant references hard implement in python. perhaps don't quite think do. any insights appreciated. while answers helpful, haven't seen single reason why const either hard implement or unworkable in python. guess "un-pythonic" count valid reason, really? python scrambling of private instance variables (starting __ ) avoid accidental bugs, , const doesn't seem different in spirit. edit: offered modest bounty. looking bit more detail why python ended without const. suspect reason it's hard i

haskell - Monads in monad transformer context -

i have trouble gripping monads , monad transformers. have following contrived example (not compilable): import control.monad import control.monad.error import control.monad.reader data state = state int int int type foo = readert state io readeither :: string -> either string int readeither s = let p = reads s in case p of [] -> throwerror "could not parse" [(a, _)] -> return readeithert :: io (either string int) readeithert = let p s = reads s in runerrort $ l <- liftio (getline) readeither l foo :: foo int foo = d <- liftio $ readeithert case d of right dd -> return dd left em -> liftio $ putstrln em return (-1) bar :: foo string bar = liftio $ getline defaults = state 0 0 0 if copy functionality of readeither readeithert, works, have nagging feeling can leverage power of existing readeither function, can't figure out how. if try lift readeither in

java - Is jCaptcha thread safe? -

i'm using jcaptcha in project , needed behavior not directly available. looked source code see if can extend obtain want , found store implementation use ( mapcaptchastore ) uses hashmap store... no synchronization. i know jcaptcha not work in clustered environment, not case, how multiple clients @ same time? store implementation synchronized externally or should roll own , make sure synchronized? tia! judging reading source mapcaptchastore, class not thread-safe. i'm not 100% willing stand behind answer though, because synchronisation may happening @ higher level (eg accesses single instance of mapcaptchastore may synchronised on object). you use implementation of captchastore. example, ehcachecaptchastore

svn - Best practices regarding merging bugfixes from trunk into a feature branch using TortoiseSVN -

i have case branch represents new version in there refactored data layer, of bug fixes applied trunk. doing oppsite way since of documentation have encountered refer merging branch trunk. still keep version branch , bug fixes in sync, how can done easily? if there conflicts due fact version branch has many changes it's directory hierarchy , files. best practice in case? subversion knows scenario of "feature branch": http://svnbook.red-bean.com/en/1.1/ch04s04.html#svn-ch-4-sect-4.4.2 i think applies degree situation. idea there changes trunk branch later easier re-integrate trunk. experience subversion not run smoothly like. other systems git or mercurial supposedly better job this.

php - Best way to code Achievements system -

i'm thinking of best way design achievements system use on site. database structure can found @ best way tell 3 or more consecutive records missing , thread extension ideas developers. the problem have lots of talk badges/achievement systems on website -- it's talk , no code. where's actual code implemention examples? i propose here design hope people contribute , create design coding extensible achievement systems. i'm not saying best, far it, it's possible starting block. please feel free contribute ideas. my system design idea it seems general consensus create "event based system" -- whenever known event occurs post created, deleted, etc calls event class so.. $event->trigger('post_created', array('id' => 8)); the event class finds out badges "listening" event, requires file, , creates instance of class, so: require '/badges/' . $file; $badge = new $class; it calls default event passing d

c# - Entity Framework DDD using partial class -persistance ignorance -testability -

i want use entity framework , autogenerated classes in application. i'm not interested on: persistance ignorance testing i care 1 thing: keep application organized keep things simple i read domain drive design , i'm interested on because claim simplify complex applications. when read code real application example shocked complexity of approach. my idea use partial classes extend classes generated ef. ther try approach , can give me advice? so, if understand correctly, hoping use data access tool, entity framework in particular, implement application. it sounds not in fact interested in doing domain driven design project. i think that's fine position in. ddd incorporates ideas , patterns , tools useful outside of ddd. however, others, caution going half way down ddd road. true concept of domain model. once begin attempting implement true domain model, practically need rest of pieces of ddd in order make work you. find without piece

php - CodeIgniter Accessing Multi-Dimentional Arrays in Views -

i've got little problemo. in codeigniter controller i'm loading same view many times array. each view assigned value, in turn added $data array pass view. i'm having problems getting data out of $data array in master template view. here's how created array: $data['views'][$current_value][$counter] = $this->load->view('sub_view', $data, true);` this inside while loop cycles through $counter until i've got data need. finished array have views, have many current values, each have many counters. what code should use try , out of array in master view? i've tried many different methods! it's not playing ball. has got ideas. cheers! sparkles okay, i've fixed it. turns out quite simple mistake, turns out knowledge of multi-dimensional arrays in codeigniter not bad. byeee x

security - How can I better protect my php, jquery, ajax requests from malicious users -

i send lot of data through jquerys getjson method, example of function is function dosomething(sid){ if(sid){ $.getjson("ajax/ajaxdosomething.php",{sid:""+sid+""}, function(data){ //alert(data); if(data.success == true){ $('#add_vote_div').html('vote received'); $('#list_data_div').html(data.html); } else{ $('#add_vote_div').html(data.message); } }); } }` the problem can @ source , see location of php file sending data to, therefore point browser there , append data url. checks on data make sure right data type, dont want users able go url @ all. i thought maybe put ajax files behind main document root work jquery can't link absolute paths like $.getjson("var/www/ajax/dosomething.php",{sid:""+sid+""} (main document root var/www/html/) if made $.postjson work better, doesn't exist,

xaml - How to move a silverlight storyboard into a resourceDictionary? -

i've tried copying , pasting storyboard resource dictionary doesn't work. how can move storyboard animation resource dictionary main xaml file clean , readable possible? here example of code want move animationresource.xaml <!-- story board controlling grid animation --> <storyboard x:name="moveball"> <doubleanimation duration="0:0:1" to="200" storyboard.targetproperty="(uielement.rendertransform).(transformgroup.children)[3].(translatetransform.x)" storyboard.targetname="grid" d:isoptimized="true"> <doubleanimation.easingfunction> <backease easingmode="easeinout"/> </doubleanimation.easingfunction> </doubleanimation> </storyboard> <!-- i've left out other default xaml layoutroot grid ---> <grid x:name="grid" horizontalalignment="left" margin="190,180,0,2

iphone - Problem adding custom objects to Mutable Array -

quick question regarding array's in xcode. have ht efollowing code, supposed go through array of strings has got through php , json, , trun these strings custom object strings ivars object add object new array: for (int = 0; i<[list count]; i++) { article *article = [[article alloc] init]; //creates custom object article.uid = [[list objectatindex:i] objectatindex:0]; article.title = [[list objectatindex:i] objectatindex:1]; //adds string ivars article.description = [[list objectatindex:i] objectatindex:2]; articlearray = [[nsmutablearray alloc] init]; //inits new array [articlearray addobject:article]; //should add object seems fail [article release]; //releases object nslog(@"%@", article.description); } nslog(@"%d", [articlearray count]); nslog([articlearray description]); } the code return correct values using nslog(@"%@", article.description); not correct lengt

jsf - richfaces and displaying errormessages -

<h:form id="usersettingsform"> <rich:messages> <f:facet name="errormarker"> <h:graphicimage value="/img/msgerror.png" /> </f:facet> </rich:messages> <h:outputtext value="description:" /> <h:inputtext label="description:" id="description" value="#{usersettingsform.instance.description}" required="true" size="5"> <f:validatelength minimum="3" /> </h:inputtext> <a:commandbutton value="validate" /> </h:form> when error occurs see e.g. this: screenshot how can display text "description" in front of "required field" ? like used on richfaces demo page @ richfaces demo page take @ <ric

javascript - How to create Semaphore between HTML elements loaded async -

i have in html page, element appears several times, , running same js. problem is, want specific function if first 1 run (his siblings never ran - yet). i need semaphore sync between them. unable know how declare variable , semaphore in way in js. there lots of approaches. you need put flag somewhere . in absense of else, can put on window , use name that's unlikely conflict else. then javascript quite straightforward: if (!window.myuniquenameflag) { window.myuniquenameflag = true; // processing } but again, putting things on window not ideal if can avoid it, although it's very common practice. (any function or variable declare @ global scope property of window .) if function declared @ global scope (and therefore occupying symbol), can avoid creating second symbol. instead of: function foo() { // ...your processing... } do this: var foo = (function() { var flag = flase; function foo() { if (!flag) { fla

php - Jquery ajax callback gives 500 error while compiling ziparchive -

i'm using ajax request (using jquery) compile ziparchive in php. files have zipped 1 gb, tooks long time zip these files. due timeout think ajax request callbacks internal server error (500). when i'm compiling zip archive of 50 mb working, when became bigger doesn't work anymore. when execute page manually error occured too, has ziparchive function in php. does know how problem can occured , how solve it? php ini settings high (so not solution) thanks check apache's rlimitmem setting, bit php's memory_limit . also try different combinations doing ajax upload without zipping , zipping without upload. try different compression (e.g. gzip), if debug system.

Sharepoint 2010 BDC: Connecting to Oracle an using assembly fails -

i'm trying make bdc connection in sharepoint 2010 oracle database using assembly. when unit testing assembly, works perfectly, when using in bdc, following exception: 'the provider not compatible version of oracle client' the rest of bdc model works fine; if return dummy objects instead of actual oracle results assembly, show should. any ideas? make sure of following: 1. can connect oracle client same machine. 2. running code , called assembly has same bit executable (32\64) for me latter problem , had reinstall..

iphone - How to update a UIButton label from another view controller -

i have uitabbar application, has 3 tabs. first tab has uiviewcontroller uibutton displays modal uiviewcontroller allow user select date. i'm having trouble updating label of uibutton when user has selected chosen date. my main view controller .h / .m #import <uikit/uikit.h> @interface searchviewcontroller : uiviewcontroller { iboutlet uibutton *butfromdate; } @property (nonatomic, retain) uibutton *butfromdate; - (ibaction)pickdate:(id)sender; @end //////////////////////////////////////////// #import "searchviewcontroller.h" #import "searchdatepickerviewcontroller.h" @implementation searchviewcontroller @synthesize butfromdate; - (ibaction)pickdate:(id)sender{ searchdatepickerviewcontroller *sampleview = [[[searchdatepickerviewcontroller alloc] init] autorelease]; [sampleview setmodaltransitionstyle:uimodaltransitionstylepartialcurl]; [self presentmodalviewcontroller:sampleview animated:yes]; } - (void)dealloc { [butf

.net - Sign a dll using cmd -

i have dll (project.dll) want sign dll using cmd don't have source code of it. is possible sign dll without sourcecode. if yes, please let me know how it. you can sign assemblies after have been compiled. having source code irrelevant. use sn.exe , , al.exe tools. see how use them here .

linq to sql - LINQ2SQL A problem with return items based on a parameter -

i occured strange problem. have method public static void processcategories(int? myid) { var tmplist = adapter.category.where(x => x.idparentcategory == myid).tolist(); } when myid == null (the parameter), tmplist doesn't contain elements, if type x.idparentcategory == null items returned. why ? try this: public static void processcategories(int? myid) { var tmplist = adapter.category.where(x => x.idparentcategory == myid || (myid == null && x.idparentcategory == null)).tolist(); }

c# - instantiating an nhibernate Collection -

in order entity getting null ref on orderitems. occurs when order first created. i'd able add like order.orderitems = new iesi.collections.set<orderitem>(); the error "cannot access protected constructor "set" here public class order { public virtual int id { get; set; } public virtual iset<orderitem> orderitems { get; set; } public virtual void addorderitem(orderitem item) { item.order = this; // orderitems below null orderitems.add(item); } } <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="estore.domain" namespace="estore.domain.model"> <class name="order" table="orders"> <id name="id" type="int32" column="id" unsaved-value="0&qu

sdk - Face detection on iPhone -

what library can use enable face detection on iphone? need detection, not recognition. there else opencv? this project might helpful https://github.com/beetlebugorg/pictureme

SQL Server Question - Query to XML -

alright, i've got query: select orders.orderid, productid, unitprice, quantity, orders.orderdate [order details] left join orders on orders.orderid=[order details].orderid orders.orderid='10248' or orders.orderid = '10249' xml auto, elements; and when execute gives following xml: <orders> <orderid>10248</orderid> <orderdate>1996-07-04t00:00:00</orderdate> <order_x0020_details> <productid>11</productid> <unitprice>15.4000</unitprice> <quantity>12</quantity> </order_x0020_details> <order_x0020_details> <productid>42</productid> <unitprice>10.7800</unitprice> <quantity>10</quantity> </order_x0020_details> <order_x0020_details> <productid>72</productid> <unitprice>38.2800</unitprice> <quantity>5</quantity> </order_x0020_details> </orde

documentation - OpenGL ES - where to find great resources -

as title describes - looking opengl es resources. lot of seeing beyond level of startup... looking resources build knowledge - starting off simple , working complex topics. any suggestions appreciated! good luck that... opengl documentation downright comical. have used gl es in 3 android projects far, , while it's quite easy once you've got hang of it, can't recommend particular online source. i invested in opengl superbible , worked through first 4 chapters or so, , knew enough projections , textures etc pick needed pretty quickly.