Posts

Showing posts from June, 2013

mysql - Ruby on Rails maximum weird results -

i doing simple call here , i'm unsure why results erratic. foo.maximum('bar') bar looks this |bar | |----- |16 | |5 | |2 | |10 | |7 | |8 | |10 | |9 | i expect call respond maximum value 16. thing noteworthy in respect these values are, because have no way of knowing if going come in int or float, strings. getting max of character value rather numbers themselves? if can't alter database , need deal strings, in ruby instead. however, may expensive if foo table has ton of stuff in it: foo.select("bar").collect{|foo| foo.bar.to_f}.max or if wanted avoid instantiating bunch of activerecord objects, above code selecting single field: activerecord::base.connection.query("select bar foo").collect{|foo| foo.first.to_f}.max

Posted data variables not being saved by PHP script -

i'm (junior) pen tester , i'm trying make script demonstrate dangers of xss attack client. i've got php script meant log user:pass combos when victims (i.e. myself in demo) redirected malicious page i'm hosting. this part of source login: <input type="text" id="form_login_username" name="form[login][username]" value="" class="large" /> <input type="password" id="form_login_password" name="form[login][password]" value="" class="large" /> i'm new php might basic that's cause problem. here php script log details: <?php $filename = "login_details.txt"; $username = $_post["form[login][username]"]; $password = $_post["form[login][password]"]; $fh = fopen($filename, "aw") or die("cannot open file"); fwrite($fh, $username . ":" . $password . "\r\n"); fclose($fh); wi...

php - Delete several row together-array -

i want delete several row foreach , have output bool(false) not array following code. how fix it? <input type="checkbox" name="checked[]" value="1"> function delete_test() { $delete = $this->input->post('checked'); if (is_array($delete) && count($delete) > 0) { foreach ($delete $val) { $this->db->query("delete hotel_units relation '$val'"); } var_dump($delete); echo "<br>is array"; } else { var_dump($delete); echo "<br>not array"; } // output is: bool(false) not array } i can guess $this->input->post means, if checkbox called 'checked[]' need $post: $this->input->post('checked[]');

floating point - Python array multiply -

hh=[[82.5], [168.5]] n=1./5 ll=n*hh what i'm doing wrong? received error : "can't multiply sequence non-int of type 'float'" i try add float(), not solve problem; i need multiply each element in array... all **ok idea number * array, how multiply array*array, tried same number*array, have problems: edit 2:** hh=[[82.5], [168.5]] n=zip(*hh) ll = [[x*n x in y] y in hh] ??? when multiply sequence x in python, doesn't multiply each member of sequence - repeat sequence x times. that's why x has integer (it can't float). what want use list comprehension: hh = [[82.5], [168.5]] n = 1.0 / 5 ll = [[x*n x in y] y in hh]

visual studio - VS2010 - 2 projects, 1 solution - debug both under 1 instance -

what want can't unusual. in solution, have mvc3 project , webforms project. mvc3 project meat & potatoes of application- it's user interact with. 2nd project going shared "content delivery" project. it'll shared many projects. there nothing in says has webforms, it's meant static css/js/images. on top of that, i'd use built-in vs.net development server. i have tried variety of things: setting mvc project start-up project , without "always start when debugging" property set true/false ( result: can't access files in /webforms project ) setting multiple start-up projects ( result: 2 instances of development server run on different ports ) setting webforms project reference main mvc project( result: can't access files in /webforms project ) setting virtual path under properties --> build webform project ( result: can't access files in /webforms project ) my goal to: keep these 2 separate projects when run mvc ...

Multithreaded Proxy Server implemented in java -

i implementing multithreaded proxy server in java accept messages clients , forward them server acknowledge reception of message. however, i'm having trouble doing so. point out doing wrong? thanks. proxyapp: public class proxyapp { public static serversocket server = null; public static socket client = null; public static void main(string[] args) { try { server = new serversocket(6789); socket clientsocket = null; while(true) { client = server.accept(); if(client.isconnected()) { system.out.println("proxy listening client on port 6789"); } thread t1 = new proxyhandler(client); t1.start(); clientsocket = new socket(inetaddress.getlocalhost(), 6780); if(clientsocket.isbound()) { system.out.pri...

c# - Posting to a REST webservice from .NET? -

i trying hit web service using instructions here: http://help.seeclickfix.com/kb/api/creating-an-issue i came code below: string paramcontent = "api_key=afs684eas3ef86saef78s68aef68sae&issue[summary]=abetest&issue[lat]=39.26252982783172&issue[lng]=-121.01738691329956&issue[address]=111 abe st., nevada city, ca"; byte[] parambytes = encoding.utf8.getbytes(paramcontent); httpwebrequest req = (httpwebrequest)webrequest.create("http://seeclickfix.com/api/issues.xml"); req.method = "post"; req.contentlength = parambytes.length; //req.contenttype = "application/x-www-form-urlencoded"; using (stream reqstream = req.getrequeststream()) { reqstream.write(parambytes, 0, parambytes.length); } using (httpwebresponse resp = (httpwebresponse)req.getresponse()) //here! { if (resp.statuscode != httpstatuscode.ok) ...

c - crash network and consequent state of socket -

i know how state of socket become when network on work crashes. problem when simulate collapse of network select() function, controls socket, returns me socket theoretically should not set. it's possible operating system set crashed socket both in writing , in reading? the first thing keep in mind computer typically not know when "network crashes" per se. computer know whether or not receiving packets network, or not. (some computers might know if electrical signal on local ethernet port has gone away, since possible more distant parts of network go down without affecting signal on local ethernet cable, information useful). in practice, if network between computer , (the computer talking to) stops working, you'll see following effects: (1) udp packets send dropped without trace, , without error indication. , of course won't receive udp packets remote peer either. (2) data traffic on tcp connection between computer , remote peer grind halt....

c++ - searching for hundreds of patterns in huge Logfiles -

i have lots of filenames inside webserver's htdocs directory , take list of filenames search huge amount of archived logfiles last access on these files. i plan in c++ boost. take newest log first , read backwards checking every single line of filenames got. if filename matches, read time logstring , save it's last access. don't need file more want know last access. the vector of filenames search should rapidly decrease. i wonder how can handle kind of problem multiple threads effective. do partition logfiles , let every thread search part of logs memory , if thread has match removes filename filenames vector or there more effective way this? try using mmap, save considerable hair loss. feeling expeditious , in odd mood recall mmap knowledge, wrote simple thing started. hope helps! the beauty of mmap can parallelized openmp. it's way prevent i/o bottleneck. let me first define logfile class , i'll go on implementation. here's header fi...

c - Windows console api -

i'm not experienced in windows programming , want know api windows uses making text user interface in c, way ncurses on unix-based systems. part of win32 api? can more information? there's windows console api . and, can ncurses windows .

iphone - How to handle the touches event in subView -

here code: mainview: nsarray *btarray = [nsarray arraywithobjects:@"1",@"1",@"1",@"1",@"1",nil]; buttonbarcomponent *bottomebuttonbar = [[buttonbarcomponent alloc] initbuttonbarcomponentwithbuttonarray:btarray]; bottomebuttonbar.frame = cgrectmake(0, 340, 320, 200); [self.view addsubview:bottomebuttonbar]; subview: -(id)initbuttonbarcomponentwithbuttonarray:(nsarray *)btarray { self = [[uiview alloc] initwithframe:cgrectmake(0, 340, 320, 200)]; self.backgroundcolor = [uicolor whitecolor]; } but why cant run code in touches event? try setting user interaction enabled view , subview

javascript - IFRAME and back / forward button -

i working on simple .hta application has control pane , iframe. i have added , forward button, not appear work. if links "a" , "b" in following example clicked, , forward buttons not anything. how can achieved? test.hta =================================== <!doctype html> <html> <head> <title>back / forward buttons</title> <hta:application id="test" applicationname="test" icon="res/icon.ico" showintaskbar="yes" singleinstance="yes"> </head> <body> <div class="strip"> <button onclick="output.history.back(); return false">back</button> <button onclick="output.history.forward(); return false">forward</button> </div> <div id="iframe-wrap" class="iframe-container"> <iframe id="output" name="output" src="...

asp.net - How to iterate gridview or listview using jQuery? -

how know client side how many rows there gridiview or listview except header row. like this: var number_of_rows = $("#<%=gridview1.clientid %> tr").size();

types - Java 6 annotation processing -- getting a class from an annotation -

i have custom annotation called @pojo use automatic wiki documentation generation: package com.example.annotations; import java.lang.annotation.elementtype; import java.lang.annotation.retention; import java.lang.annotation.retentionpolicy; import java.lang.annotation.target; @retention(retentionpolicy.source) @target(elementtype.method) public @interface pojo { class<?> value(); } i use this: @pojo(com.example.restserver.model.appointment.appointment.class) to annotation resource method annotation processor can automatically generate wiki page describing resource , type expects. i need read value of value field in annotation processor, getting runtime error. in source code processor have following lines: final pojo pojo = element.getannotation(pojo.class); // ... final class<?> pojojavaclass = pojo.value(); but actual class in not available processor. think need javax.lang.model.type.typemirror instead surrogate real class. i'm not sure how ...

java - How to do complex calculation in Jasper Reports / JRXML -

i new jasper reports. can tell me how complex calculation (like 1-((x/(y*somevalue))+somevalue) ) in jasper reports/jrxml? you can use expression that

c# - Working with enumerations marked with Flag Attribute in the PropertyGrid -

i have enumeration marked flag attribute. how can establish convenient editing property type of enumeration in propertygrid? should able set such values enumvalue1 | enumvalue2. also, customized strings enum values should displayed in propertygrid. inherits propertygrid & override methods...

Ruby on Rails: How can I add a css file with rails project? -

the application.html.erb file: <!doctype html> <html> <head> <title>site</title> <%= stylesheet_link_tag :all %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> </head> <body> <%= yield %> </body> </html> i have file "cake.generic.css" in public/ folder. but when reload page effect of css file not working. if see page view source see this: <!doctype html> <html> <head> <title>site</title> <link href="/assets/all.css" media="screen" rel="stylesheet" type="text/css" /> <script src="/assets/jquery.js?body=1" type="text/javascript"></script> <script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script> <script src="/assets/home.js?body=1" type="text/javascript"></...

security - JBoss 6 limit JMX to localhost -

i can not find conclusive documentation on different avenues jmx invokation on jboss 6.0.0.final. the jboss.org guide securethejmxconsole specifies how set authentication realm jmx-console.war web app , jmx-connector. feel there other ways of accessing jmx. rmi, httpinvoker? ideally, know best way limit jmx access localhost. so, how go making sure avenues of jmx accessible localhost only? there's official documentation repository red hat products, includes jboss eap (the red hat product based on jboss as). documentation eap 5.x, should similar jboss 6 (eap 5.x based on jboss 5.1). http://docs.redhat.com/docs/en-us/jboss_enterprise_application_platform/5/html/administration_console_quick_start_guide/ch04s02.html in short, you'll have change 2 files: server/$profile/conf/jboss-service.xml server/$profile/deploy/jmx-invoker-service.xml

openxml - Remove page numbering from a section break -

does have clue how remove page numbering section break in word 2007 doc? i have put 3 documents together 1st part contains page numbering , formatting 2nd part ends takes numbering 1st part , continues it. ends section break(next page) 3rd page takes numbering (the numbering starts 1) , don't want that. the last part contains covers , other info pages , don't want numbering on them. the 2nd , 3rd parts inserted using altchunk . i've tried locking 3rd part editing, i've tried putting white rectangle on footer, in front of text, i've tried putting section break (continuous) @ beginning of 3rd part...all nothing. 3rd part adopts same footer previous parts. can please give me feedback, ideas on how find solution or workaround?

installation - Reporting Server Home Page Only displays When Run as Administrator -

i having issues setting reporting server. can open http://localhost/reports when run internet explorer administrator. when try open server, logging in same user service account, prompted credentials before proceeds. settings need check\change allow me open reports home page without having open ie administrator locally or having enter username , password remote connection? here error receiving if open ie not admin. user 'domain\user' not have required permissions. verify sufficient permissions have been granted , windows user account control (uac) restrictions have been addressed. connect ssrs report manager (/reports) admin, check see when click on folder settings. should give security settings root folder. make sure account included here, whether ad group or individually. content manager permissive setting.

HTML Table width in percentage, table rows separated equally -

when create table in html, table width of 100%, if want cells (tds) divided in equal parts, have enter width % each cell? "obliged" it? e.g.: <table cellpadding="0" cellspacing="0" width="100%" border="0"> <tr> <td width="25%"></td> <td width="25%"></td> <td width="25%"></td> <td width="25%"></td> </tr> </table> or following right procedure, not write width in each tds if want each of them devided equally: <table cellpadding="0" cellspacing="0" width="100%" border="0"> <tr> <td></td> <td></td> <td></td> <td></td> </tr> </table> i know works both manners want know "legit" way it. you need enter width % each cell. wait, there...

Java spring @RequestParam JSP -

current controller code: @requestmapping(value = "/city", method = requestmethod.post) public string getweather(@requestparam("city") int city_id, @requestparam("text") string days, //this gives errrors, when remove line, okay model model) { logger.debug("received request show cities page"); //int city = // attach list of subscriptions model model.addattribute("city", service.getcity(city_id)); // resolve /web-inf/jsp/subscribers.jsp return "city"; } this jsp file(view): <form method="post" action="/spring/krams/show/city"> vali linn <select name="city"> <c:foreach items="${cities}" var="city"> <option value="<c:out value="${city.id}" />"><c:out value="${city.city}" /></option> </c:fore...

php - Pear Auth package -

reading larry ullman's php 5, told install pear auth package , pear db. according pear website, db package has been deprecated in favor of mdb2. installed latter (mdb2) package. i'm getting warning when run program. fatal error: class 'db' not found in /users/michaelmitchell/pear/share/pear/auth/container/db.php on line 150 i'm not sure if have done wrong (if so, what?) or if auth package somehow referring deprecated db class, or else? the third line below if (!db::isconnection($this->db) line 150 of db.php. can help? function _prepare() { if (!db::isconnection($this->db)) { $res = $this->_connect($this->options['dsn']); if (db::iserror($res) || pear::iserror($res)) { return $res; } } if ($this->options['auto_quote'] && $this->db->dsn['phptype'] != 'sqlite') { if (strpos('.', $this->op...

database - Android: Accessing DB -

i have following code: dbadapter dbadapter = new dbadapter(this); dbadapter.open(); arraylist<string> queryresultlist = new arraylist<string>(); cursor cur = dbadapter.db.query("mytable", columns, where, null, groupby, null, null); cur.movetofirst(); while (cur.isafterlast() == false) { queryresultlist.add(cur.getstring(0)); cur.movetonext(); } cur.close(); dbadapter.close(); this code runs on device never run before, i.e. wiped emulator samsung galaxy s device app removed after first trial. means database reading being created first on device. custom database. on 2.2 runs fine, on 2.1-update1 (api level 7) wont, isafterlast() true, there since api level 1. 1 idea? or idea can figure out? thanks, a. hmm, why not use: cursor cur = ...; while (cur.movetonext()) { queryresultlist.add(cur.getstring(0)); } cur.close();

java - Unitils / DBunit / Oracle - how to insert dataset in oracle views? -

it seems simple question. have unitils tests in spring application. database contains oracle views , want insert dataset these views. know possible set options dbunit (table type properties). find nothing unitils. is there unitils properties inserting dataset views ? thank help ok think find way configure unitils. needs java code. have tested solution, seems work. first find properties in unitils (unitils.properties): unitils.module.dbunit.classname=org.unitils.dbunit.dbunitmodule unitils.module.dbunit.runafter= unitils.module.dbunit.enabled=true so seems possible override dbunitmodule this public class dbunitmodule extends org.unitils.dbunit.dbunitmodule implements module { /* * (non-javadoc) * * @see org.unitils.dbunit.dbunitmodule#getdbunitdatabaseconnection(java.lang.string) */ @override public dbunitdatabaseconnection getdbunitdatabaseconnection(final string schemaname) { dbunitdatabaseconnection dbconnection = su...

Why is a 1 character .NET string 32 bytes in x64? -

i've been trying figure out overhead of string in .net 4 x64. i've got far. 16 byte object header x64 4 bytes stringlength field (arraylength gone in .net 4) (length + 1) * 2 bytes string content (utf-16, null terminated) so you'd expect 1 character string 16 + 4 + 4 = 24 bytes . it's divisible 8 shouldn't need padding. but when @ sizes in windbg see them taking 32 bytes . when !dumpobject them size 28 bytes, assume getting rounded 32. what's going on? there round of memory alignment happening? i suspect first character aligned on 8-byte boundary on x64, when passed pointer unmanaged code, it's properly-aligned pointer. figures fit in the ones got measuring string size recently, leading formulae of: 32 bit: 14 + length * 2 (rounded 4 bytes) 64 bit: 26 + length * 2 (rounded 8 bytes) so in 64 bit clr, 0-length string takes 32 bytes reckoning.

huffman algorithm in python -

hi! could how fix problem in huffman algorthm (if put parts) internet site: http://www.builderau.com.au/program/python/soa/huffman-coding-in-python/0,2000064084,339283616,00.htm error: itemqueue = [node(a, len(list(b))) a, b in groupby(sorted(input))] typeerror: 'builtin_function_or_method' object not iterable thanks! i think forgot declare input . should work fine otherwise.

Creating a scala Reader from a file -

how instantiate scala.util.parsing.input.reader read file? api mentions in passing pagedseq , java.io.reader, it's not clear @ how accomplish that. you create fileinputstream, pass inputstreamreader , pass apply method of streamreader companion object, returns streamreader, subtype of reader. scala> import scala.util.parsing.input.{streamreader,reader} import scala.util.parsing.input.{streamreader, reader} scala> import java.io._ import java.io._ scala> streamreader(new inputstreamreader(new fileinputstream("test"))) res0: scala.util.parsing.input.streamreader = scala.util.parsing.input.streamreader@1e5a0cb

java - How do you update a value in a Quartz JobDataMap? -

i'm using quartz-scheduler 1.8.5. i've created job implementing statefuljob. schedule job using simpletrigger , stdschedulerfactory. it seems have update trigger's jobdatamap in addition jobdetail's jobdatamap in order change jobdatamap inside job. i'm trying understand why it's necessary update both? noticed jobdatamap set dirty. maybe have explicitly save or something? i'm thinking i'll have dig source code of quartz understand going on here, figured i'd lazy , ask first. insight inner workings of jobdatamap! here's job: public class hellojob implements statefuljob { public hellojob() { } public void execute(jobexecutioncontext context) throws jobexecutionexception { int count = context.getmergedjobdatamap().getint("count"); int count2 = context.getjobdetail().getjobdatamap().getint("count"); //int count3 = context.gettrigger().getjobdatamap().getint("count...

java - Help deleting fields from an HTML table -

so not sure how tag one, have dynamically loaded html table, contains values can deleted, using check boxes user decide row delete. here code far: <table id="comments" align="center" width="59%"> <thead> <th class="headerclass" width="7%">delete</th> <th width="15%" class="headerclass">date</th> <th class="headerclass" width="15%">employee</th> <th class="headerclass">comment</th> </thead> <tbody> <% while (result.next()) { commentdate = stringutils.defaultstring(result.getstring("commentdate")); commentuser = stringutils.defaultstring(result.getstring("cname")); comment = stringutils.defaultstring(result.getstring("xbs_comment")); %> <tr> <td class="normal"...

java - JTabbedPane mouseover paint issue -

i working application experiencing painting issues on users computers when mouse passes on tabs in jtabbedpane . have similar issues on other interactive components jbutton s. have ever seen error occur on mouse overs. the application being run 1.6.0_20 , have tried flag recommended in update 10 in case issue d3d (-dsun.java2d.d3d=false). since new user cannot post picture illustrate error. best example can think of using windows paint eraser on image create similar seeing. i appreciate can provide. without sscce exhibits problem describe, it's hard specific, reminds me of rendering artifact associated setting opaque property true without rendering area defined component's bounds. in particular, if override paintcomponent() , "do not honor opaque property, see visual artifacts." finally, default opacity setting of components varies & feel, effect may platform dependent.

javascript - How to structure a express.js application? -

is there common convention breaking , modularizing app.js file in express.js application? or common keep in single file? i have mine broken follows: ~/app |~controllers | |-monkey.js | |-zoo.js |~models | |-monkey.js | |-zoo.js |~views | |~zoos | |-new.jade | |-_form.jade |~test | |~controllers | |-zoo.js | |~models | |-zoo.js |-index.js i use exports return what's relevant. instance, in models do: module.exports = mongoose.model('phonenumber', phonenumberschema); and if need create phone number, it's simple as: var phonenumber = require('../models/phonenumber'); var phonenumber = new phonenumber(); if need use schema, phonenumber.schema (which assumes working routes folder , need go 1 level , down models) edit 4 the express wiki has list of frameworks built on top of it. of those, think twitter's matador structured pretty well. used similar approach how load parts of app. derby.js looks extremely interes...

timer - How to find how much time has elapsed in C++ using sys/times.h -

i want following: get t1 run program t2 display t2 - t1 basically i'm trying find out how time program used. have seen several solutions this, 1 1 sys/times.h used, haven't quite figured out. how can done? struct timeval timestart,timeend; int error1=gettimeofday(&timestart, null); //stuff want measure goes here int error2=gettimeofday(&timeend, null); if(error1 || error2) return -1; //some error occured //this gives result in microseconds. return (timeend.tv_sec - timestart.tv_sec)*1000000.0+(timeend.tv_usec - timestart.tv_usec);

regex - Visual Basic 6 Regular Expression [Hexadecimal] failing to replace properly -

i'm trying replace native x86 asm c++ code can make emulator. i got this if ereg(asm, "push ([a-f0-9\s]+)", false) asm = ereg_replace(asm, "push ([a-f0-9\s]+)", _ "regs.d.esp -= 4;" & vbnewline & _ "*(unsigned int *)(regs.d.esp) = $1;", false) end if functions found on internet.. should work.. on google. function ereg(stroriginalstring, strpattern, varignorecase) ' function matches pattern, returns true or false ' varignorecase must true (match case insensitive) or false (match case sensitive) dim objregexp: set objregexp = new regexp objregexp .pattern = strpattern .ignorecase = varignorecase .global = true end ereg = objregexp.test(stroriginalstring) set objregexp = nothing end function function ereg_replace(stroriginalstring, strpattern, strreplacement, varignorecase) ' function replaces pattern replacement ' varignorecase must tru...

php - Zend, Ajax/Jquery and Progressive Enhancement -

i have been using php/zend quite while , need start using ajax improve our overall user experience. working on being able display modal window (a box) in middle of page display dynamic information user (this "info" number of small pages displayed in box, form, warnings, messages, advertizing...). trying scope biggest number of browsers/versions , possibles. would guys agree first should have info (pages) need display divided in different actions/controllers , them use ajax pull info in modal box scope situation? mean users without fancy browser still navigate? i pretty sure that's faces on daily basis. how guys deal this? in opinion, if have print different content, can use 1 controller ("box") , 1 action (said "view"). besides, have little database of content , can use same controller/action , give different content changing parameter. in way, want, can serve them in lot of different way (for example "fancy" browser). hope h...

mysql - What is the correct and easiest way to do prepared statements with PHP's mysqli? -

i have been using old mysql api in php long time , want start using mysqli both speed , security new project i'm working on. i've looked through manual , read several tutorials, i'm finding lot of conflicting , confusing information on how prepared statements in mysql. is there in code doesn't need there, , there missing? also, easiest way simple (seems involved such simple task)? procedural: // build prepared statement $query = mysqli_prepare($link, "select email users id = ?"); // bind parameters statement mysqli_stmt_bind_param($query, 's', $_get['id']); // execute statement mysqli_stmt_execute($query); // bind variables result mysqli_stmt_bind_result($query, $email); // print results while (mysqli_stmt_fetch($query)) { echo $email; } // close statement mysqli_stmt_close($query); // close connection mysqli_close($link); object-oriented: // build prepared statement $query = $link->prepare("select email users id...

java - Wondering how to compare sets -

im trying create program takes 2 types [like pokemon] select two, , computer selects two, , comparison occurs saying won. try implementing comparator ? it's super effective. (of course, if it's pokemon might want rig computer wins more often...)

iphone - problem with NSSortDescriptor .i am sorting the in ascending order(alphabetical order) -

i using nssortdescriptor sort custom objects key bandname , not getting output in alphabetical order. how fix that? -(void)getdetails { nslog(@"in getdetail method"); songrequestappdelegate *appdelegate = [[uiapplication sharedapplication] delegate]; nsmanagedobjectcontext *context1 = [appdelegate managedobjectcontext]; nsentitydescription *entitydesc = [nsentitydescription entityforname:@"addtofav" inmanagedobjectcontext:context1]; nsfetchrequest *request = [[nsfetchrequest alloc] init]; [request setentity:entitydesc]; nserror *error; nsmutablearray *array_new=[[nsmutablearray alloc]init]; [array_new addobjectsfromarray:[context1 executefetchrequest:request error:&error]]; //[self.fetchedobjects addobjectsfromarray:[context1 executefetchrequest:request error:&error]]; [request release]; **nssortdescriptor *sortdescriptor; sortdescriptor = [[[nssortdescriptor alloc] initwithkey:@"bandname" asc...

PHP date difference extremly hard to accomplish -

i have dates subtracting days current date , time. let suppose current date may 1, 2011 after subtracting 30 days april 1, 2011 how accomplish in php? please help $unixtime = strtotime("may 1, 2011 -30 days"); $human_readable = date('f j, y', $unixtime);

android - webview gallery -

i new android developement. doing webview gallery. in gallery load images , set layout mwebview.setlayoutparams(new gallery.layoutparams(70,85)); this 70 , 85 height , width webview when images webview.loadurl time big , small images load... problem images display more width size , lower width won't set dynamically set height , width. it's height , width depend on whaterver images comes url ...see below code u can understand more detail ......... public view getview(int position, view convertview, viewgroup parent) { webview mwebview = new webview(mcontext); mwebview.loadurl(it2[position]); mwebview.setwebviewclient(new webviewclient()); mwebview.getsettings().setjavascriptenabled(true); mwebview.setlayoutparams(new gallery.layoutparams(70,85)); websettings websettings = mwebview.getsettings(); mwebview.setbackgroundcolor(0); mwebview.setinitialscale(100); ...

html - styling each line inside pre with css -

i have html code <pre> line 1 line 2 line 3 </pre> how can put css style "lines" inside <pre> , without adding other wrapper it? what mean like pre lines{ color: red} i'm having difficulties on finding css selector that. in advance. you can use little css3 trick, gradients. create automatically, without spans, "zebra" effect: background: #555; background-image: -webkit-linear-gradient(#555 50%, #505050 50%); background-image: -moz-linear-gradient(#555 50%, #505050 50%); background-image: -ms-linear-gradient(#555 50%, #505050 50%); background-image: -o-linear-gradient(#555 50%, #505050 50%); background-image: linear-gradient(#555 50%, #505050 50%); background-position: 0 0; background-repeat: repeat; background-size: 4.5em 4.5em; try different css "line-height" text appears correctly. see: http://www.dte.web.id/2012/03/css-only-zebra-striped-pre-tag.html#.uuov6lugkom

Add web references to Windows service -

i'm going add web references windows service. but whatever have done not useful. is there special way add web references windows service? i'm beginner when comes windows services. any appreciated regards, first of all: make sure service works (without web service reference) - needs install , start properly. then add logging - run? run to? catch exceptions might happen , log those, too. you might want check out "hybrid" approaches, allow write code command-line app first (which can debugged), , once works okay, can install service: hybridservice: switch between console application , service hybrid windows service topshelf - service-construction helper .net

c# - Sort a collection based on another collection -

i have collection of file names part of pathname being specific word. can order collection : var files = f in checkedlistbox1.checkeditems.oftype<string>() orderby f.substring(0,3) select f; but now, want sort not alphabetical order on pathname part according specific order given collection. so let's pathname part can "ate", "det" , "rti". have string collection : {"det", "ate", "rti"} want use sort filenames after sorting, filenames appear partname in order "det" first, "ate", "rti". how achieve -> need use own comparer ? three different variants, depending if want use string[] , list<string> or dictionary<string, int> (good if have many elements search for) string[] collection = new[] { "det", "ate", "rti" }; var files = f in checkedlistbox1.checkeditems.oftype<string>() orderb...

c# - how to get the prefect url from html encoded url -

folderpath\0\microsoft%202007\chapter1\images how can remove %20 url path. use this string s = httputility.urldecode(@"folderpath\microsoft%202007\chapter1\images");

PHP not writing to files on windows server -

i have windows server 2008 standard edition. i'm trying execute simple command can later write admin logs on files. info ain't writing on files or creating file if doesn't exist. , page isn't issuing , warnings or errors windows permission. <?php $file=fopen("1.txt","a"); fwrite($file,"hello"); ?> any ? try find out if there error opening file without relying on php's error reporting: $file = fopen("1.txt","a") or die("error opening file: " . print_r(error_get_last())); secondly, if you're not getting errors on command line, make sure php set display them all. check out this question helpful tips on that.

codeigniter - PHP image resizing unknow source size, known output size -

i working on site @ moment, requires admins of site able upload pretty size of image, need find way image down size required front end of end site, needs done without know size of image user uploading, image needs scale 209x293 without looking awful. is possible? you should argue client, forget rule(accept image), , accept rather, images in proportion, or better , can use tool crop image, forcing user crop image in needed resolution. jcrop library in jquery can lot if want create cropping feature.

PHP get user information -

i made website login script. there guy makes false logins time. example usernames 'lfdjgh' , email addresses jkgfhkjghf@dkhfkgh.com. want find out person located etc. is there way find detailed information user? computer-name, ip address, location, etc? thanks i agree other answers have said, can use values passed $_server avoid this. along adding captcha page, can add ip address database, grabbed $_server['remote_addr'] , compare known spam ip's new registrations, , check if known spammer. do, , don't have spam @ (: happy hunting!

android - check whether lock was enabled or not -

i have check whether system lock enabled or not in settings. i used below line code boolean b = android.provider.settings.system.getint( getcontentresolver(),settings.system.lock_pattern_enabled, 0)==1; it returns true if set pattern lock , false if set pin/password password. i need check whether lock enabled or not either pattern/pin/password lock in settings. my code works pattern lock not pin/password lock. so please tell me how check type of locks. so question pretty old seems there no answer yet. after source code (from ramakrishna's link ) research , self experiments i'm wrote simple class job. public class locktype { private final static string password_type_key = "lockscreen.password_type"; /** * constant means android using unlock method not described here. * possible new methods added in future releases. */ public final static int something_else = 0; /** * android u...

c - SO_KEEPALIVE does not work during a call to write()? -

i'm developing socket application, must must robust network failures. the application has 2 running threads, 1 waiting messages socket (a read() loop) , other send messages socket (a write() loop). i'm trying use so_keepalive handle network failures. works ok if i'm blocked on read(). few seconds after connection lost (network cable removed), read() fail message 'connection timed out'. but, if try wrte() after network disconnected (and before timeout ends), both write() , read() block forever, without error. this stripped sample code directs stdin/stdout socket. listens on port 5656: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <pthread.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netinet/tcp.h> int socket_fd; void error(const char *msg) { perror(msg); exit(1); } //read stdin , write socket void* write_dae...

python - What should a Window Manager do with a ConfigureRequestEvent? -

for sins (and fun learning experience) writing window manager (i know, know). i'm using python , xcb (python-xpyb). so far have figured out need use substructureredirect mask on root window(s), , being passed events related applications' top-level windows. i'm testing launching xterm. i configurerequestevent, followed pause, followed configurerequestevent, , maprequestevent. when maprequestevent call connection.core.mapwindowchecked(e.window) , works, maps window pixel or 2 wide/tall. my question, then, should configurerequestevent make window correct size (assuming thats i'm missing)? more accurately, call? mapwindowchecked obvious choice, can't seem find how configure width/height. i'm guessing configurewindow, arguments accepts seem obscure me. last time called used xcb.xproto.cw.eventmask, none of flags in cw seem related width/height. ps documentation on of seems quite elusive me. i've looked @ couple of python window managers suppose...

java - Sort list on base of multiple criteria -

i sort list on base of multiple criteria. public class customercomparator implements comparator<customer> { public int compare(customer customer1, customer customer2) { int comparison = -1; comparison = customer2.getcustomerpriority().compareto(customer1.getcustomerpriority()); if( comparison == 0 ) { comparison = customer1.getcustomernumber().compareto(customer2.getcustomernumber()); } return comparison; } } basically, want sort in following order. customer higher priority should on top of list, , if 2 customers have same priority 1 lower customer number should go first. original: customer priority 1 0 2 0 3 1 4 0 5 0 it should sorted below: customer priority 3 1 1 0 2 0 4 0 5 0 thanks help. dd java's arrays.sort , collections.sort both stable sorting algorithms meaning can sort 1 comparator , another, ...

Sql Server - Any way to find which stored procedures return sets and which not? -

i need build service expose metadata stored procedures in sql server database. there way find out stored procedure return sets, , don't, can called, correspondingly, through executereader or executenonquery? thank you it turns out (i googled) way set fmtonly flag on on sql server. see here. here's example taken here : set fmtonly on; exec dbo.mytestsproc @param1 = null, @param2 = null, @param3 = null set fmtonly off; in case stored proc not return data, won't see output (at least observation in ssms). when proc return data, see column names being displayed without being returned. so sort of trial error kind of thing. note: tested proc uses table-valued parameter , did not produce output though proc return data. setting parameter null did not work , ssms complained nasty error. error seems related temp table being used inside proc , not table-value parameter still didn't produce empty resultset: msg 208, level 16, state 0, procedure s...

java - Need Help Getting A Simple Stop-Watch Working? -

so experimenting little stop-watch object , can't figure out why isn't working. have gui following; timeinfield jtextfield user enters start time of clock. timerfield jtextfield clock displayed timing. startbutton jbutton user clicks start clock. stopbutton jbutton user clicks stop clock. right now, timerfield displays running: 0 seconds. nothing else happens, maybe doing wrong first time trying this. start learning how use threads thought might me started. private void startbuttonactionperformed(java.awt.event.actionevent evt) { string starttim = timeinfield.gettext(); long starttime = long.valueof(starttim); boolean running = false; timer timer = null; long time = (system.currenttimemillis() - starttime)/1000; timerfield.settext("running:" + time + "seconds"); if (running==false) { running = true; timerfield.settext("running: 0 seconds"); } ...

winforms - Date and Time Format Problems in vb.net -

i trying truncate seconds part current date dim nowtime datetime = now.toshorttimestring the above code shows time in format hh:mm:ss i want in format hh:mm the date time picker shows date this 5/ 1/2011 (there space before 5 , before 1) dim nowtime datetime = now.toshorttimestring the above code shows date this 5/1/2011 (there no space before 5 or 1) i trying compare current date , time date , time in database. in database have saved date , time string. you need apply correct formatstring datetime.tostring() datevalue.tostring("hh:mm") and date: now.tostring("mm/dd/yyyy") more here

windows - Getting permission denied when pushing to git vps server -

Image
i installed git windows, creating ssh key , uploaded public server. i have working on mac, trying working on windows machine now. i did : chmod 700 ~/.ssh/ chmod 600 ~/.ssh/* here image of me doing ssh -v gitserveralias i have config file has gitserveralias , port etc. i tried clearing out known hosts file also. my config looks like: host serveralias user xxx hostname 123.234.452.232 port 22222 identityfile ~/.ssh/id_rsa tcpkeepalive true identitiesonly yes preferredauthentications publickey again have setup working fine on mac. two things check: do have "pubkeyauthentication yes" in sshd_config on server? try setting it. is there offending key in .ssh/known_hosts? try removing file.