Posts

Showing posts from May, 2013

javascript - How to run angularjs ajax request in loop but with delay? -

i need run 20-200 ajax requests in loop not hurt google.maps.geocoder want set delay 10 sec between each call. ajax request asynchronous therefore call next ajax request on response succeeded of previous one. if response quick, delay should take place. here code wrote far: ... $scope.addresslist = ....; $scope.taskcount = $scope.addresslist.length; geotaskloopasync(); function geotaskloopasync(){ // on success douncount taskcount var geo = new google.maps.geocoder(); geocoder.geocode( { 'address': address }, function(results, status) { $scope.$apply( function () { // response if($scope.taskcurr <= $scope.taskcount){ $scope.taskcurr++; return geotaskloopasync(); } return; }); }); so next? can add like: stop = $timeout(function() { if($scope.taskcurr <= $scope.taskcount){ ...

jquery - How to get JSON from a distant server in an express server? -

i'm looking way replicate jquery method getjson server side. server i'm using node.js server express framework written in coffeescript. the code have client side : # client ip $.getjson("http://jsonip.com?callback=?", (data) -> # more information ip $.getjson("http://freegeoip.net/json/" + data.ip, (fulldata) -> console.log fulldata)) the fulldata variable give me information client ip. i have avoid using javascript client side, try same server side, client ip doing : (req, res) -> # client ip req.ip but after that, have no idea how fulldata in json freegeoip.net server. help, ? i used skelly solution. so did : request = require 'request' (...) (req, res) -> url = 'http://freegeoip.net/json/' + req.ip request.get(url, (error, response, body) -> if !error console.log body ) the body contains data need. i'm sure david fregoli 's native node.js solution...

c# - Alternative to ASP.NET drop down list -

regardless of or try drop down list isn't working, <asp:dropdownlist id="drop1" runat="server" autopostback="true" enabledviewstate="true" onclick="drop1_selectedindexchanged" /> bind here, protected void page_load(object sender, eventargs e) { if (!ispostback) { binddropdownlist(); } //drop1.selectedindexchanged += new eventhandler(drop1_selectedindexchanged); } and here's method, never triggers (i use break point check) protected void drop1_selectedindexchanged(object sender, eventargs e) { //checkboxlist1.items.add("hahahha"); } is there alternative ?????????? need populate drop down list using, using (sqldatasource ds = new sqldatasource(connectionstring(), selectcommand())) { system.data.dataview dv = (system.data.dataview)ds.select(datasourceselectarguments.empty); ...

php - Changing joomlas default favicon path -

i try change joomlas default favicon , place in root of web. how can that? according joomla documentation , html.php looks both template , root folder favicon. therefor should show if put in in root . // try find favicon checking template , root folder $path = $directory . ds; $dirs = array( $path, jpath_base . ds ); foreach ($dirs $dir ) { $icon = $dir . 'favicon.ico'; if (file_exists( $icon )) { $path = str_replace( jpath_base . ds, '', $dir ); $path = str_replace( '\\', '/', $path ); $this->addfavicon( juri::base(true).'/'.$path . 'favicon.ico' ); break;''

plasticscm - Using git tfs with Plastic SCM Git Sync -

since plastic scm talks git protocol, possible configure plastic use "plugins" available git? i mean, can use the: git tfs <parameters here> to make git , tfs synced. don't want keep git in way. :)

ios - iVars references strong, weak or what? -

in obj-c, properties can configured weak/strong. instance variables. following - @interface myclass { nsobject *a; } does myclass's object keep weak reference a or strong, or else? think ivar not released until object released. why don't specify weak/strong ivar properties? the default reference ivar __strong , though can explicitly set __weak or __strong

mysql - Getting SQL error 1078 Before start of result set in Java program -

i have java method supposed column values 1 mysql row , create string values. when run, generates sql error 1078 "before start of result set." here the class in error occuring (problem in listposesinsection method: /** class used access database */ import java.sql.*; import java.util.arraylist; import javax.swing.joptionpane; public class yogadatabaseaccess { string dburl = "jdbc:mysql://localhost/yoga"; private connection connection; private resultset rset; private resultsetmetadata rsmetadata; private statement statement; private preparedstatement pstatementall = null; private preparedstatement pstatementpartial = null; // strings queries , updates string strlistposesnotprimary; string strinsertnewclass; string strinsertnewsection; string strinsertnewpose; string strupdateclass; string strupdatesection; string strupdatepose; string strarrangeposeorder; private string[] posearray; // constructor yogadatabaseaccess() { connecttodatabase(); } // m...

Complex Rails/Postgres SQL optimization -

restaurant has_many dish dish has_many photo photo belongs_to dish restaurant 1 dish 1 photo 1 may 9, 1:00 pm dish 2 photo 2 may 9, 2:00 pm dish 3 photo 3 may 9, 3:00 pm restaurant 2 dish 4 photo 4 may 9, 1:00 pm dish 5 photo 5 may 9, 2:00 pm dish 6 photo 6 may 9, 3:00 pm i'm trying retrieve latest 50 photos limit of 2 dish photos per restaurant. given data above i'd able retrieve photos ids 2, 3, 5, , 6 my current implementation ugly least. hash = {} bucket = [] photo.includes(:dish => [:restaurant]).order("created_at desc").each |p| restaurant_id = p.dish.restaurant.id restaurant_count = hash[restaurant_id].present? ? hash[restaurant_id] : 0 if restaurant_count < 2 bucket << p hash[restaurant_id] = restaurant_count + 1 end # if you've got 50 items short circuit. end i can't feel there's more efficient solution. ideas appreciated :-). there should w...

php - save data in cakephp database -

i have cakephp web app i'm developing. have userscontroller.php file,which handles users registrations , logins. when user logged in,he can use functionality of featurescontroller.php. fueaturescontroller.php has view file,the create.ctp . in create.ctp,the user inserts data html form , these data saved database,using $this->modelname->save($this->request->data). now,i want add field of database username of user did/used html,but till have not succeed! code looks this: $username = $this->session->read('auth.user.username'); so save username of user variable $username. but now,how can insert database? have tried various ways didn't work :/ anyone's welcomed,thank in advance :) you shouldn't add username form, it's not secure malicious user has modify html change it. instead, should set right before saving: $this->request->data['modelname']['username'] = $this->auth->user('username'...

Glibc-2.17 toolchain issue iconv folder undefined reference -

on building glibc on toolchain . libraries make succesfully (and test ok) flags unset except specified building default glibc. start building programs both , without flags on seperate fresh build attempts , every time in iconv folder breaks... i'll diverge second moan how iconv breaks in glibc me , has done long can remember... moving on though.... when gcc-4.8.0 passed gcc -nostdlib -nostartfiles -o /glibc-build/iconv/iconvconfig -wl,-dynamic-linker=/tools/lib/ld-linux-x86-64.so.2 -wl,--hash-style=both -wl,--warn-shared-textrel,--fatal-warnings /glibc-build/csu/scrt1.o /glibc-build/csu/crti.o gcc --print-file-name=crtbegins.o /glibc-build/iconv/iconvconfig.o /glibc-build/iconv/strtab.o /glibc-build/iconv/xmalloc.o /glibc-build/iconv/hash-string.o -wl,-rpath-link=/glibc-build:/glibc-build/math:/glibc-build/elf:/glibc-build/dlfcn:/glibc-build/nss:/glibc-build/nis:/glibc-build/rt:/glibc-build/resolv:/glibc-build/crypt:/glibc-build/nptl /glibc-build/libc.so.6 /glibc-build/l...

ios - using NSXMLparser, how do you parse an xml file which has same name tags but in different elements? -

is possible give path expressions in nsxmlparser? have xml file has few same name tags, in different element. there way differentiate between them. here xml: <schools> <school> <id>335823</id> <name>fairfax high school</name> <student> <id>4195653</id> <name>will turner</name> </student> <student> <id>4195654</id> <name>bruce paltrow</name> </student> <student> <id>4195655</id> <name>santosh gowswami</name> </student> </school> <schools> i'd create separate school , student objects. parser have properties currentschool , currentstudent . whenever parser hits <student> tag, call self.current...

php - How to preg_match for a specific pattern in a url? -

i use preg_match in php test format of url. url looks this: /2013/09/05/item-01.html i'm trying work : if (preg_match("/([0-9]{4})\/([0-9]{2})\/([0-9]{2})/[.]+[.html]$", $_server['request_uri'])) : echo "match"; endif; but something's not quite right. ideas? try: if (preg_match('!\d{4}/\d{2}/\d{2}/.*\.html$!', $_server['request_uri'])) { echo 'match'; } \d short [0-9] , can use different start/end delimiters (i use ! in case) make regexp more readable when you're trying match slashes.

linux - Locked sqlite IN THE WHOLE SYSTEM -

i got big problem in system. how, entire sqlite sistem become locked. not talking single database, talking every database in system. ladb08@newcastle:~$ touch new.sqlite3 ladb08@newcastle:~$ sqlite3 new.sqlite3 sqlite version 3.7.3 enter ".help" instructions enter sql statements terminated ";" sqlite> .tables error: database locked sqlite> even firefox cant open because of same problem. got no idea of why happened. server debian server, , used team develop site rails. centralize stuff in external git repo work own user, , own copy of stuff. another test: ladb08@newcastle:~/agendador/db$ lsof test.sqlite3 ladb08@newcastle:~/agendador/db$ fuser test.sqlite3 ladb08@newcastle:~/agendador/db$ strace -e fcntl sqlite3 test.sqlite3 .tables fcntl(3, f_getfd) = 0 fcntl(3, f_setfd, fd_cloexec) = 0 fcntl(4, f_getfd) = 0x1 (flags fd_cloexec) fcntl(3, f_setlk, {type=f_rdlck, whence=seek_set, start=1073741824, len=1}) = -1 enolck (no locks available) error: ...

python - Generate all possible replacements -

given replacement map {search: replace, search: replace, ...} , string, how generate list of possible replacements of string (first substring replaced, second substring replaced, both replaced etc). example: map = { 'bee': 'beta', 'zee': 'zeta', 'dee': 'delta' } source_string = 'bee foo zee bar bee' desired result = [ 'bee foo zee bar bee', 'beta foo zee bar bee', 'bee foo zeta bar bee', 'beta foo zeta bar bee', 'bee foo zee bar beta', 'beta foo zee bar beta', 'bee foo zeta bar beta', 'beta foo zeta bar beta' ] the order not important. 'bee foo zee bar bee' => ['bee', 'foo', 'zee', 'bar', 'bee'] : from itertools import product repl = { 'bee': 'beta', 'zee': 'zeta', 'dee': 'delta' } so...

css3 - CSS Keyframe Animation Similar to Stop Motion -

i need use keyframe animations move background-position of sprite sheet. however, not want animations, want hard frame frame look, similar gif. any ideas how achieve this? thanks much! yes, can achieve more beautifully, javascript css : @-webkit-keyframes sprite { 0% { background-position: 0px 0px; } 25% { background-position: 0px 0px; } 25.1% { background-position: -200px 0px; } 50% { background-position: -200px 0px; } 50.1% { background-position: -400px 0px; } 75% { background-position: -400px 0px; } 75.1% { background-position: -400px -200px; } 99.9% { background-position: -400px -200px; } 100% { background-position: 0px 0px; } } @-moz-keyframes sprite { 0% { background-position: 0px 0px; } 25% { background-position: 0px 0px; } 25.1% { background-position: -200px 0px; } 50% { background-position: -200px 0px; } 50.1% { background-position: -400px 0px; } 75% { background-position: -400px 0px; } 75.1% { background-...

symfony - Notice: Undefined index Repository Symfony2 -

i hope id table user using repository in action : $user = $this->getdoctrine()->getrepository('appmybundle:user') ->findbyusername($token['name']); $id = $user['id']; // $user->id or $user->getid() give me error? that give me error : notice: undefined index: id in /var/www/project/src/app/mybundle/controller/defaultcontroller.php line 56 finally var_daump output : echo "<pre>"; var_dump($user); exit(); echo "</pre>"; array(1) { [0]=> object(app\mybundle\entity\user)#351 (21) { ["id":protected]=> int(17) .... .... i think want call findonebyusername method instead of findbyusername . findby* return array of object , findoneby* return object. after in order id call getter $id = $user->getid(); hop it's helpful. best regard.

Angular.JS unsuccessfully tries to load a view with the OPTIONS HTTP method -

Image
i have been following along angularjs fundamentals in 60-ish minutes tutorial http://www.youtube.com/watch?v=i9mhiguzkem i doing fine until got 52 minutes in when tutor tests out app. @ point in app trying load view. when tried load app saw nothing in window. opened chrome dev tools > network , saw status view1.html , view supposed loaded in, load cancelled . noticed angular tried call via options method. here screenshot: in attempt solve issue came across question angularjs performs options http request cross-origin resource and similarity problem angular using options retrieve data. difference in case, angular retrieving cross-origin resource. makes sense not in case. trying load view located on system. here directory structure of angularapp folder located on ubuntu 12.10 desktop: . ├── app.html ├── partials │   ├── view1.html │   └── view2.html └── scripts └── angular.js the url use view app file:///home/max/desktop/angularapp/app.html what doing w...

security - Can XSS be executed on server? -

hi xss attack treated attack client's machine. there way make xss attack on server ? i want know there way execute code on server using client side interface in case of sql injection, here not database server simple web server or application server. sometimes, it's possible use xss vector trigger , leverage cross-site request forgery ( csrf ) attacks. having xss on website having control on javascript user execute when visiting it. if administrator stumbles upon xss code (either sending malicious link or means of stored xss), might him or execute requests or actions on webserver normal user wouldn't have access to. if know webpage layout enough, can request webpages on visitor's behalf (backends, user lists, etc.), , have results sent (exfiltrated) anywhere on internet. you can use more advanced attack frameworks such beef attempt exploit vulnerabilities in visitor's browser. if visitor in question website administrator, might yield interesting i...

jquery - jqm datebox, mode timebox giving error 'There is no mode by that name loaded/mode not given' -

i using jqm datebox; mode timebox. have added required libraries error: there no mode name loaded/mode not given. it used work previous versions of jquery , jquery mobile, doesn't work latest versions. <input name="timedatebox" type="date" data-role="datebox" data-options='{"mode": "timebox", "timeformatoverride":12}' id="timedatebox" /> here code: http://jsfiddle.net/abvqh/194/ working example: http://jsfiddle.net/gajotres/pfj7z/ you initializing wrong databox js files. there files don't exist: <script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.calbox.min.js"></script> <script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.datebox.min.js"></script> correct ones: <script type="text/javascript" src="http://dev....

javascript - Migrating menu tree code from jquery 1.7.1 to 1.9.1 -

i've js code working jquery 1.7.1 broken after migration 1.9.1 can see problem on http://jsfiddle.net/qk5ld/2/ . the code i'm using this: $("#navigation li ul").each(function(){ var = this; $(this).hide(); $(this).prev().toggle(function() { $(that).show(); }, function() { $(that).hide(); } ); }) i read toggle() no more supported i'm no js expert , i've lost many hours trying complete update js code. any idea? thank in advance. nicola. note: html used this: <div id="navigation"> <ul> <li id="category-2850"> <a href="/category/archiviazione/">archiviazione</a> <ul> <li id="category-3021"> <a href="/category/archiviazione/archiviaz...

Django-Nginx, 502-BAd Gateway Error -

i have implemented search page website on django-nginx platform. when pass long string parameter search page, server return "502 bad gateway" error. error logs shows "failed (104: connection reset peer) while reading response header upstream". please guide me resolve issue.

oracle - PHP calling ORA stored procedure: ORA-01722 invalid number -

i have ora stored procedure: procedure calc(code in number, extloan in number, loan in number, payment in number, duration in number, saleid in number, resultblob out clob); (currently header available). i have tried php call (i using oci_* functions directly, though have wrapper object them): $query = ' begin calc( :code, :extloan, :loan, :payment, :duration, :saleid, :result); end;'; $stmt = oci_parse($this->connection, $query); oci_bind_by_name($stmt, ':code', 100, 3, sqlt_int); oci_bind_by_name($stmt, ':extloan', 20000, 9, sqlt_int); oci_bind_by_name($stmt, ':loan', 50000, 9, sqlt_int); oci_bind_by_name($stmt, ':payment', 0, 9, sqlt_int); oci_bind_by_name($stmt, ':duration', 60, 3, sqlt_int); oci_bind_by_name($stmt, ':saleid', 2211445, 9, sqlt_int); // <- row generating error // tried these binds no luck (same error) //oci_bind_by_name($stmt, ...

PHP Notice: Undefined variable: nomor in C:\xampp\htdocs\test\tabel.php on line 19 -

i learning php, , found error in first lesson, had few hours try not know solution. <td><?php echo $nomor=$nomor+1; ?></td> my php code: <?php include "koneksi.php"; $query=mysql_query("select * biodata"); $jumlah=mysql_num_rows($query); echo "jumlah data ada : ".$jumlah; ?> <table border="1"> <tr> <th>nomor</th><th>nama</th><th>alamat</th><th>usia</th><th>aksi</th> </tr> <?php while($row=mysql_fetch_array($query)){ ?> <tr> <td><?php echo $nomor=$nomor+1; ?></td> <td><?php echo $row['nama']; ?></td> <td><?php echo $row['alamat']; ?></td> <td><?php echo $row['usia']; ?></td> <td> <a href="delete.php?id=<?php echo $row['id']; ?>" onclick="return confirm('apakah anda yakin?')">d...

tsql - Sql Server: How do I unpivot with an alias? -

i know can use alias on column pivot , i'd use alias unpivot well. select userid , contactmethod , contactmethodvalue users unpivot ( contactmethodvalue contactmethod in ( homephone [3000] , officephone [3001] , cellphone [3002] , fax [3003] , website [3005] ) ) unpvt however error when this. the way i've been able accomplish end goal use case statement in select clause, isn't pretty. select userid , ( case contactmethod when 'homephone' 3000 when 'officephone' 3001 when 'cellphone' 3002 when 'fax' 3003 when 'website' 3005 end ) contactmethod , contactmethodvalue users unpivot ( contactmethodvalue contactmethod in ( homephone , officephone , cellphone , fax , website ) ) unpvt is there better way? you cannot ...

GD Star Rating WordPress Plugin Not Working -

i have gd star rating wordpress plugin. working on admin side properly. not displaying stars on frontend. for example returning 500 internal server error on these pages http://novelsnippet.com/main/wp-content/plugins/gd-star-rating/gfx.php?value=5&set=oxygen&size=20&max=5 but file working on site properly. http://metroui.org/wp-content/plugins/gd-star-rating/gfx.php?value=5&set=oxygen&size=20&max=5 while working on issue found simple php page http://novelsnippet.com/main/test.php working here , other folder too. not working inside folders of wp-content. for example http://novelsnippet.com/main/wp-content/test.php this fixed me: go settings , disable loading css externally - many providers block external file inclusion security reasons. worked me, hope works else.

java - Confused at to why this arraylist code is not working? Includes alist.removeLast(); -

anyone know code does? i confused, , doesn't work reason though in textbook. here array list: arraylist<integer> alist = new arraylist<integer>(); while(!alist.isempty()){ alist.removelast(); } the alist.removelast(); piece of code has error in it im not sure piece of code supposed , how work. if exact code in textbook, textbook wrong. arraylist.removelast() not exist. however, linkedlist.removelast() exist. and looks method taking strange approach emptying list.

c++ - Regular expression to match one or more characters every type? -

there 3 types of characters: a-z , a-z , 0-9 . how write regular expression match words have 1 or more characters in 3 types? for example: match: abacc88, ua8za8, 88aa no match: abc, 118, aa7, xxzz, xyz111 this boost::regex re("^[a-za-z0-9]+$"); doesn't work. thanks assuming you're testing each word separately: boost::regex re("(?=.*[a-z])(?=.*[a-z])(?=.*[0-9])"); no need anchors. actually, in case boost doesn't support lookarounds: boost::regex re(".*[a-z].*([a-z].*[0-9]|[0-9].*[a-z])|.*[a-z].*([a-z].*[0-9]|[0-9].*[a-z])|.*[0-9].*([a-z].*[a-z]|[a-z].*[a-z])"); this every combination, @bill has pointed out.

c# - Why is Action<Action<T>> covariant? -

this i'm having hard time wrapping head around. understand action<t> contravariant , declared such. internal delegate void action<in t>(t t); however, don't understand why action<action<t>> covariant. t still not in output position. i'd appreciate if try explain reasoning / logic behind this. i dug around little bit , found this blog post tries explain it. in particular, didn't quite follow meant here under "explanation covariance of input" subsection. it same natural if “derived -> base” pair replaced “action -> action” pair. ok, first of let's clear mean saying action<action<t>> covariant . mean following statement holds: if object of reference type x may assigned variable of reference type y, object of type action<action<x>> may assigned variable of reference type action<action<y>> . well, let's see if works. suppose have classes fish , animal ...

sass - How do I correctly setup the scss file watcher in PhpStorm? -

Image
i have working, these settings takes quite while until change comes through in phpstorm. if rid of ../css/ part of argument string creates/updates css file in same directory scss file in, immediately. doing wrong? i'm using phpstorm 6.0.1 on os x 10.8.3 as it's mentioned in previous answer, have set output paths option accordingly. like: arguments: --no-cache --update $filename$:$fileparentdir$/css/$filenamewithoutextension$.css working directory: $filedir$ output paths: $fileparentdir$/css/$filenamewithoutextension$.css now output paths matches scss output directory, ide knows output , looks like

jquery - jqModal creating a weird bug in my scrollTo script -

at top of page have 4 links , each take different part of page. have used scrollto plugin works great, there weird bug script have noticed occurs after have called jqmodal popup window. when click on 1 of links page doesn't scroll expected. instead, skips section without scrolling , scrolls top of it. it's annoying , don't know how fix it. thought maybe include start position in script getting current position of top of page using: $(document).scrolltop() not work :( $('.home, #header ul li').click(function(e){ e.preventdefault(); var id = $(this).attr('data-rel'); window.location.hash = id.replace(/_/g,"-"); $.scrollto('#'+id+'_anchor', 500, { easing : 'easeincubic', onafter:function(){ $('.home, #header ul li').removeclass('selected'); $(this).addclass('selected'); } }); });

c# - INSERT error ASP.NET -

hey error saying there wrong code when inserting database, can't quite find it. error suggests in insert statement, appears on line "cmd.executenonquery();" . i'm using access database. error: syntax error in insert statement. con.open(); string mysql; mysql = "insert [user](firstname,surname,age,housenumber,postcode,username,password) values (?,?,?,?,?,?,?)"; oledbcommand cmd = new oledbcommand(mysql, con); cmd.parameters.addwithvalue("@p1", tbfirstname.text); cmd.parameters.addwithvalue("@p2", tbsurname.text); cmd.parameters.addwithvalue("@p3", int.parse(tbage.text)); cmd.parameters.addwithvalue("@p4", tbaddress1.text); cmd.parameters.addwithvalue("@p5", tbpostcode.text); cmd.parameters.addwithvalue("@p6", tbusername.text); cmd.parameters.addwithvalue("@p7", tbpassword.text); cmd.executenonquery(); con.close(); when add parameters value need convert matching t...

html5 - Make a textbox flat and blend into the page by removing border/glow -

Image
i have textbox seems confusing our users since try edit , it's indellible. changed background colour , removed borders have text on screen. below can see screenshots , without focus, html defines box , less styles it. my question how rid of faint blue border when out of focus , glow when in focus? html: <input class="span1 bg-light-blue" type="text" name="hand_unit_id" id="hand_unit_id" readonly="true" /> less: #hand_unit_id { border: none ! important; } #hand_unit_id:focus { border: none ! important; box-shadow: none ! important; outline: none ! important; } here's way might go bypasses whole styling issue altogether. may have accessibility benefits well. screen reader users may confused text field. http://jsfiddle.net/isherwood/nhv3g/2 <input id="my_text_box" type="text" value="scruff" style="display: none;" /> <span id=...

python - SQL inside code or procedure? -

this straight forward question regarding how insert or select data from/to database ? since i'm trying keep code clean possible, how i'm performing queries , inserts/updates: import sys import mysqldb configparser import safeconfigparser #------------------------------------------------------------ # select , insert # func should called like: # db_call('c:\dbconf.cfg','select * something') # or insert / update statement. #------------------------------------------------------------ def db_call(cfgfile, sql): parser = safeconfigparser() parser.read(cfgfile) dbtype = parser.get('database', 'db_type') db_host = parser.get('database', 'db_host') db_name = parser.get('database', 'db_name') db_user = parser.get('database', 'db_login') db_pass = parser.get('database', 'db_pass') con = mysqldb.connect(host=db_host, db=db_name, ...

java - How to fetch user who are disabled in LDAP active directory -

i have write java code find if particular user in active directory enabled or disabled. you can inspect useraccountcontrol bit flag attribute. 2nd bit indicates if user disabled (see remarks section on attribute's msdn page .) the easiest use bitwise filter in ldap query: (useraccountcontrol:1.2.840.113556.1.4.803:=2) this filter expression return disabled accounts (see more on usage of bitwise filters in this article ).

c++ - RC4 OpenSSL adds garbage characters when decrypted -

when decrypt file openssl's rc4 function part of it, contains garage characters rc4_key key; rc4_set_key(&key, pass.length(), (const unsigned char *) pass.c_str() ); rc4(&key, text.length(), (const unsigned char *)text.c_str(),(unsigned char *)decrypted.c_str()); any ?

python - How can I stretch a single widget in a horizantal layout in PyQt4? -

here 3 pushbutton equivalent in size, how increase size of first pushbutton occupies more space other 2 buttons. from pyqt4 import qtgui import sys class allwidgets(qtgui.qwidget): def __init__(self): super(allwidgets, self).__init__() layout = qtgui.qhboxlayout() #code pushbutton 1 pushbutton_1 = qtgui.qpushbutton() pushbutton_1.settext('first') layout.addwidget(pushbutton_1) #code pushbutton 2 pushbutton_2 = qtgui.qpushbutton() pushbutton_2.settext('second') layout.addwidget(pushbutton_2) #code pushbutton 3 pushbutton_3 = qtgui.qpushbutton() pushbutton_3.settext('third') layout.addwidget(pushbutton_3) self.setlayout(layout) if __name__ == '__main__': app = qtgui.qapplication(sys.argv) display = allwidgets() display.show() sys.exit(app.exec_()) the second (optional) argument of addwigdet() strech ...

ios6 - How to hide iOS 6 UIButton "gradient"? -

Image
when place uibutton on view doesn't contain white, strange "gradient" shown on bottom of button. doesn't happen in ios 5, nor happen when background of view beneath contains white. here's screenshot: how remove/hide effect? as far can tell, way around make custom button. it's part of rounded rect button , can't rid of it. there's interesting discussion of problem here: button background , gradient change since ios6

python - Function returns pointer to array with result. How to access this data -

i have function imported dll , defined in ctypes. set restype c_void_p . when call function, result returns pointer 32byte array of bytes. how can convert pointer python bytes type? here function (it's hmac openssl): self.hmac = self._lib.hmac self.hmac.restype = ctypes.c_void_p self.hmac.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_void_p, ctypes.c_void_p] edit: i've tried replacing c_void_p c_char_p . results, c_char_p represents null terminated string, results cut @ point of first 00h. if hmac not have zeros in result works perfectly. still not solve problem. using ctypes.c_void_p return type wrong thing do. for non-nul-terminated string, should set array of chars of right size; 32 in case, ctypes.c_char * 32 . restype pointer this, wrap in ctypes.pointer . you can access returned value bytes object using value (or raw ; it's same thing in context) attribute of pointer's contents ....

scaling geo coordinates in D3.js -

i draw circle in each coordinate. using width , height , , coordinates , how scale coordinates? i'm new d3.js , guess i'm doing wrong projection part. var width = 200, height = 200; var svg = d3.select("body") .append("svg") .attr("width", width) .attr("height", height); var coordinates = [ [43.08803611,-79.06312222], [43.09453889,-79.05636667] ]; var group = svg.append('g'); var projection = d3.geo.mercator() .translate([width,height]); var projectedcoordinates = []; (var i=0; i<coordinates.length; i++) { projectedcoordinates[i] = projection(coordinates[i]); } group.selectall("circle") .data(projectedcoordinates) .enter() .append("circle") .attr("r",4) .attr("cx", function(d){ return d[0]; }) .attr("cy", function(d){ return d[1]; }); you there...

javascript - Read string on Browser -

i need read string written in browser write 5 in 5 seconds necessary recover value of while being written. here's code write in php: set_time_limit(0); // $this->layout = null; $i = 0; for($i; $i<10;$i++){ echo 'line '.$i."\n"; flush(); ob_flush(); sleep(3); } echo 'lool'; now, how read jquery or other solution? for read contents in jquery need use dom style, can change result : echo "<div id='myid".$i."'></div> and code readable jquery, in jquery can access id code : $('#myid1').click(function(){$(this).hide);});

c++ linux Eventloop vs. sleep() vs select() -

i have so/dll program needs sleep -> check stuff -> sleep. which better way perform operation: // sleep loop while ( true ) { sleep( 1 ); // whatever time if ( flag_quit ) leave; if ( flag_something_else ) do_whatever(); } or // select loop while ( true ) { timeout.sec = 1.0; // whatever time timeout.msec = 0; zeroiftimedout = select( fdmax, fdlist, null, null, timeout ); if ( flag_quit ) break; // leave while loop if ( flag_something_else ) do_whatever(); if ( 0 == zeroiftimedout ) continue; // } or // well, write event loop in c++ the real questions are, which option less processor intensive? is there yield() both windows , linux replace sleep? if decide use in application, is, not in dll/so, there better way handle stdin select() method? would interruptable sleep better in method? an infinite (well, until there's input) sleep accompanies std::cin or getchar() . sleep y...

iphone - Drawing on a UITableViewCell backgroundView using CoreGraphics -

Image
i have subclass of uitableviewcell need draw custom backgroundview cell. implementing drawrect:, can draw view fine, behind tableview , tableviewcells. in order use cg draw custom backgroundview, need make separate uiview subclass drawing in , set cell's backgroundview? thanks! edit: screenshot i want blue drawn instead of white. in place of white. or @ least on top of it. i drawing shadow behind cell using ca, , have shadow behind view drawing. you need set background of contentview. mycell.contentview.backgroundcolor = [ uicolor greencolor ]; //

java - The equivalent of instanceof -

what equivalent of without using instanceof? maybe more simple while using true, false or else statements? public static void p (object...ar) { (int i=0; < ar.length; i++) { if (ar[i] instanceof int[]) { for primitive arrays can, instead of: if (ar[i] instanceof int[]) use: if (ar[i].getclass() == int[].class) note: above code works fine arrays of primitive types. please aware, though, instanceof checks if object in left-part subtype of class in right-part, while == not. objects , equivalent (myinstance instanceof myclass[]) (checks subtyping) is: ( myclass[].class.isassignablefrom( myinstance.getclass() ) )

performance - Cost of assigning to array -

i have program looks this: int i; double* = new double [2]; for(i=0;i<1000000;i++) { a[0] = 1.1231; a[0] = 1.1231; a[0] = 1.1231; .. } the line a[0] = 1.1231; has been copied manually 10.000 times, hence command called 10.000.000.000 times. takes 8.7 seconds run. however, if run loop 10.000.000 times , copy statement manually 1.000 times (aka same number of array assignments, different layout), runtime of 3 seconds. how can be? compiling -o0. there else need disable compiler optimization? asking because optimizing program , comparing performance of different containers... thanks!

c++ - Widgets must be created in the GUI thread Error !. How to correct the code? -

i have experience c++ i'm qt beginner few days. @ simple application code below, "main.cpp" code file in project. problem when try run application returns me error widgets must created in gui thread. how go around ?. possible write application works want without additional thread ?. if yes how ?. please help. can't working myself. #include <qapplication> #include <qwidget> #include <qboxlayout> #include <qgridlayout> #include <qpushbutton> #include <qspinbox> #include <qslider> #include <qradiobutton> #include <qframe> #include <qlcdnumber> #include <qprogressbar> #include "windows.h" dword winapi trd1entry(lpvoid lpparam) ; int main(int argc, char **argv) { qapplication app(argc, argv) ; qwidget *window = new qwidget() ; window->resize(500, 400) ; qhboxlayout *layout0 = new qhboxlayout() ; qgridlayout *layout1 = new qgridlayout() ; qvboxlayout *layout2 = ne...