Posts

Showing posts from January, 2014

javascript - Change JS function to jQuery -

how can change code take advantage of jquery? function download(elm) { var iframe = document.createelement("iframe"); var param = elm.innerhtml; //$get("filedownload").innerhtml; //iframe.src = "generatefile.aspx?filename=386c1a94-fa5a-4cfd-b0ae-40995062f70b&ctype=application/octet-stream&ori=18e73bace0ce42119dbbda2d9fe06402.xls";// + param; iframe.src = "generatefile.aspx?" + param; iframe.style.display = "none"; document.body.appendchild(iframe); } it this: function download(elm) { $("<iframe />", { src: "generatefile.aspx?" + elm.innerhtml }) .appendto("body").hide(); } this jquery 1.4+ $(html, props) syntax, older versions this: function download(elm) { $("<iframe />").attr("src","generatefile.aspx?" + elm.innerhtml) .appendto("body").hide(); } past creation .appendto() appe

What is most common way to embed UML into Java code? -

i'm trying add uml sequence , class diagrams java code, in order explain internals , design concepts. these diagrams specified in javadoc blocks , converted png/gif images attached api html. what tool can use automation of process (i'm using maven 3)? uml diagrams within javadocs : article shows how easy , simple include uml diagrams within javadoc , keep them updated every change in source code repository.

cocoa - Records in NSMutableArray not sorted -

i using nsarraycontroller display records in nstableview . reading selected record using [recordarray objectatindex:[tableview selectedrow]] . working fine when don't click of headers in table sort data. when click header sort data, data sorted on screen not in recordarray , order of recordarray not match order of data in table view anymore. my recordarray of type nsmutablearray , contains records of type browserrecord. browserrecord contains fields name , type (both nsstring , readwrite). i've followed guidelines , examples found in books , on internet , find confusing doesn't work me (my previous version of code without core-data working fine). must doing strange. hope can point me out right direction. your array controller managing sorted contents. ask -arrangedobjects.

dynamic - What is the difference between CLR and DLR in C#? -

what difference between clr , dlr in c#? these 2 concept comparable? the common language runtime (clr) core set of services offered .net – type system, jit, garbage collector, &c. available .net languages, hence "common" part. the dynamic language runtime (dlr) builds atop of , offers services dynamic languages: dynamic types, dynamic method dispatch, code generation, &c. idea make things uniform , share them among dynamic languages work predictably , similar, things on clr across languages too. in way comparable, "normal" language on .net uses clr, dynamic language should use dlr, use clr well. basic sets of functionality designers considered when common across languages. ironpython , ironruby implemented on top of dlr, c# 4's dynamic feature.

xpath: how to select all text nodes that precedes or follows <br> tags ? possible for \n? -

text<br> text2<br> text3<br/> br tags may self closing or not. would possible regular text: text\n text2\n text3\n you can give: //br/preceding-sibling::*/text() where //br select breaks in document

social networking - How to update a Identi.ca from Twitter -

there "out-of-the-box" way update twitter identi.ca. but, there solution update identi.ca status twitter ? if use: twitterfeed.com http://api.twitter.com/1/statuses/user_timeline/llaumgui.rss&trim_user=true have unsightly "llaumgui:" before each twitt... i have found answer: how remove twitter username rss feed use pipes.yahoo.com/pipes/pipe.info?_id=zncl_xdx2xgvxug5p2iyxq remove username rss feed use twitterfeed.com service

javascript - How to resize nyroModal once content height/width has been changed -

i using nyromodal show modal window. works fine when initial content showed. in content have jquery toggle method, makes visible other sections. i want modal auto resize new content area. how can implement that. i haven't tried this, nyromodal listens window resize events resize modal, maybe triggering 1 here. e.g. $(window).resize(); however if "modal window" iframe, nyromodal won't know size resize modal to.

jQuery selected name -

if tom selected drop down box, how name , not value using jquery resulting output tom? <select id="emp" > <option value=1>tom</option> <option value=12>harold</option>e <option value=32>jenny</option> </select> var res = $('#emp :selected').text(); this gets element the id emp , gets the descendant element :selected , returns the .tex() content . here's plain javascript version: var el = document.getelementbyid('emp'); var res = el.options[el.selectedindex].text;

winapi - Enumerating processes that record or playback on Windows XP -

i enumerate processes, have open handle of soundcards in system. ideally "process - sound card - action" relation, action might playback or record. is there win32 api getting information on windows xp? api work on newer versions of windows? you can find out handles open in process analyzing memory. enumerating processes done using enumprocesses() you can use system api (brought ddk only, unfortunately) if want more info (as i'm sure do) here's useful thread. sysinternals

c# - How to allow an activex object to print? -

i have activex control in web page print out bills. works fine on local when try in remote server, can't print out, gives me error. system.security.securityexception: request permission of type 'system.drawing.printing.printingpermission, system.drawing, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a' failed. the role of user app running under, doesn't have permission print. please give user, permission print. or check application's .net trust level (you can find in features view of web application in iis management console) add attribute above method, in making activex object , requesting print. [system.security.permissions.permissionset(system.security.permissions.securityaction.assert, unrestricted = true)] public void blabla [ //your code }

java - Exception when use android tabs with intent to start activity -

i have error when use intent start activity when choose tab intent = new intent().setclass(this, tab1.class); mtabhost.addtab(mtabhost.newtabspec("tab_test1").setindicator("search").setcontent(intent)); the erroe sorry ! application has stopped unexpectedly , please try again later look here possible solution (this seems common tabhost issue)

is vb.net row-major or column-major in 2d array allocation? -

is vb.net row-major or column-major in 2d array allocation? .net stores 2d arrays in row major order. ref . (about half-way down!) cli spec (section 8.9.1) states: array elements shall laid out within array object in row-major order (i.e., elements associated rightmost array dimension shall laid out contiguously lowest highest index). actual storage allocated each array element can include platform-specific padding.

c++ - Another BUG of VC++ 2010? About declaring a constant REFERENCE in a header -

several lines of code worth thousand words: i have 3 simple files: header.h, main.cpp, other.cpp // header.h #pragma once inline const int& getconst() { static int n = 0; return n; } const int& r = getconst(); // main.cpp #include "header.h" int main() { return 0; } // other.cpp #include "header.h" when compiling simplest project, vc++ 2010 complains follows: clcompile: other.cpp main.cpp generating code... other.obj : error lnk2005: "int const & const r" (?r@@3abhb) defined in main.obj d:\test\debug\bug.exe : fatal error lnk1169: 1 or more multiply defined symbols found build failed. time elapsed 00:00:00.29 ========== build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== i sure bug of vc++ 2010, because of following 2 references: 1, c++ standard says: (at page 140 of n3126) "objects declared const , not explicitly declared extern have internal linkage." 2, msdn says:

Memory leak problems while splitting a string in C -

im trying split string according following rules: words without "" around them should treated seperate strings anything wiht "" around should treated 1 string however when run in valgrind invalid frees , invalid read size errors, if remove 2 frees memory leak. if point me in right direction appreciate it the code calls split_string char *param[5]; for(i = 0;i < 5;i++) { param[i] = null; } char* user = getenv("logname"); char tid[9]; char* instring = (char*) malloc(201); / while((printf("%s %s >",user,gettime(tid)))&&(instring =fgets(instring,201,stdin)) != null) { int paramsize = split_string(param, instring); the code tries free param for(i = 0;i < 5;i++) { if(param[i] != null) { free(param[i]); fprintf(stderr,"%d",i); } } i

javascript - Google Maps API v3: Add Polylines inside a loop? -

i'm in process of migrating our map application v2 v3 (3.2). had loop read latlng , put them in array display polyline on map. set length of array 0 , fill again in loop other latlng display polyline... , on (many times). it working fine in v2, not in v3. since code complex, tried write simpliest code possible demonstrate issue: function setpolyline(points) { var polyline = new google.maps.polyline({ path: points, strokecolor: '#ff0000', strokeopacity: 0.5, strokeweight: 2 }); polyline.setmap(map); } var mapdiv = document.getelementbyid('map'); var mapcenter = new google.maps.latlng(0,0); var mapoptions = { zoom: 2, center: mapcenter, backgroundcolor: '#e1e1e1', maptypeid: google.maps.maptypeid.roadmap } map = new google.maps.map(mapdiv, mapoptions); var points=[]; points[0]=new google.maps.latlng(-35, 71); points[1]=new google.maps.latlng(-36, 75);

garbage collection - Order of memory disposal and GC in C# -

what happens in c# when: 1) method gets invoked. 2) method allocates memory (e.g. memorystream mm = new memorystream()). 3) exception occurs in method caught invoking classes. does resource "mm" gets freed garbage collector? security risk (e.g. dos)? p.s.: know best practice explicitely free allocated resource. mean use "using"-statement or "try/catch/finally"-block. does resource "mm" freed garbage collector? once dead, yes. gc run , free memory if unreferenced. is security risk? let's precise in our terminology. asset of value: private data, user's time, , on. attacker wishes harm asset. threat manner in attacker harm. vulnerability aspect of scenario taken advantage of attacker make threat. to answer question need know: what asset? who attacker? what threat attacker poses asset? what vulnerability can attacker take advantage of make threat? only once state answers questions can possibly

extjs - Ext JS Dependent combo box -

i new extjs, , trying implement following functionality: i have 2 select drop down menus, transformed using extjs. how can make sure if value in 1 combo box selected, other value should set default value? thanks. edited: code till now: ext.onready(function(){ var converted = new ext.form.combobox({ typeahead: true, triggeraction: 'all', transform:'id_select1', width:600, forceselection:true, emptytext:'select' }); var convertedcdr = new ext.form.combobox({ typeahead: true, triggeraction: 'all', transform:'id_select2', width:600, forceselection:true, emptytext:'select' }); }); i using coldfusion query database , populate drop down menus: <cfquery name="getdata1" datasource="abc"> select * table1 </cfquery> <cfquery name="getdata2" datasource="abc"> select * table2 </cfquery> <select

android - How can I check the current time on a droid device and put that into an integer? -

i know there date() class built api, line of code grabs time of day? use calendar.get(calendar.hour_of_day) take @ link text

How to opent text file for editing, ASP.NET? -

the page has link text file placed somewhere in network. if click link file opened in browser without opportunity edit it. how user can click , open in his/her favorite text editor? thanks if trying edit contents of text file why not display contents in textbox , let users update contents , save it.

c# - Is there a LinkedList collection that supports dictionary type operations -

i profiling application trying work out why operations extremely slow. 1 of classes in application collection based on linkedlist. here's basic outline, showing couple of methods , fluff removed: public class linkinfocollection : propertynotificationobject, ienumerable<linkinfo> { private linkedlist<linkinfo> _items; public linkinfocollection() { _items = new linkedlist<linkinfo>(); } public void add(linkinfo item) { _items.addlast(item); } public linkinfo this[guid id] { { return _items.singleordefault(i => i.id == id); } } } the collection used store hyperlinks (represented linkinfo class) in single list. however, each hyperlink has list of hyperlinks point it, , list of hyperlinks points to. basically, it's navigation map of website. means can having infinite recursion when links go each other, implemented linked list - understand it, means every hyperlink, no matter how many times refere

Windows Batch Script Feeding Arguments -

suppose have script takes couple of command-line arguments , dumps results stdout . manually invoking script this: perl foo.pl arg1 arg2 arg3 without changing script in question, possible under windows take contents of file (e.g., input.txt multi-line text file arg{1,3} delimited whitespace on each line) , execute this: foreach line in input.txt perl foo.pl current_line >> output.txt right now, have perl script this, wondering if possible anyway. i'm gonna yes. i searched web google windows batch loops , got page: http://www.robvanderwoude.com/for.php . i dug around on site , found page: http://www.robvanderwoude.com/ntfor.php#for_f so looks code like... for /f %%variable in (input.txt) perl foo.pl %%variable >> output.txt

c# - Why is LINQPAD assuming this variable is a System.Int32 and how can I change its mind? -

i'm trying optimize query plugged linqpad keep getting null reference error, can't assign null value system.int32.. when comment out folderid 1 @ end there, error no longer occurs. why assume folderid system.int32 , how can make int32? instead it's nullable , can run query? (from groupbundle in groupbundles join usergroup in usergroups on groupbundle.groupid equals usergroup.groupid join bundle in bundles on groupbundle.bundleid equals bundle.bundleid usergroup.userid == 75 orderby bundle.bundlename select new { bundleid = bundle.bundleid, bundlename = bundle.bundlename, bundleicon = bundle.bundleicon, usespecialplayer = (bundle.usespecialplayer != null && bundle.usespecialplayer == true) ? true : false, height = bundle.puheight, width = bundle.puwidth, userid = 75, companyid = 32, isfavorite = ((from f in favorites f.favoritetypeid == 1 && f.userid == 75 &a

iphone - CLLocationManager not prompting the user and returns NULL -

till yetsterday working fine on iphone. starting today, noticed cllocationmanager not prompt user "this app wants use location" , proceeds return me null in didupdatetolocation. have tried signing app dev provisioning, adhoc , prod profiles. also, making sure delete app before trying this. earlier moment run app first time, prompt me push notifications , gps prompt. now, none of these prompts showing up. my app cllocationmanager startupdatinglocation in appdelegate --> applicationdidlaunch , applicationdidlaunchwithoptions. also, cllocationmanager not call didfailwitherror. replying myself. using testflighapp.com beta testing , not sure if causing it, had go ti iphone-->settings-->general-->reset-->reset location warnings. once did , ran app, did prompt me gps , started working fine after that.

Mapping interface on multiple hierarchies with NHibernate -

given 2 classes not related, 1 of member of inheritance hierarchy, how can map interface on both of classes can query against interface , have appropriate concrete type returned? e.g. public abstract class survey { public guid id { get; private set; } } public class inviteonlysurvey : survey { public icollection<invite> invites { get; private set; } } public class invite : isurveygateway { public guid id { get; private set; } public inviteonlysurvey survey { get; private set; } } public class sharedsurvey : survey, isurveygateway { ... } public interface isurveygateway { guid id { get; } } currently have mapped survey, inviteonlylivesurvey , sharedlivesurvey using table per class hierarchy , trying figure out how map isurveygateway can query against , have nhibernate find matching entity ( invite or sharedlivesurvey ) seamlessly. isurveygateway instances readonly remaining persistence concerns managed through mappings shared

Apache Load Balancer on Top of Tomcat 6 - Missing Something and it's Not Working -

i'm trying basic apache 2.2 load balancer running on top of 2 tomcat 6 installations. i'm reading through documentation , i'm having trouble getting working correctly. i'm have apache configuration correct, think i'm missing in tomcat settings that's preventing connection. tomcat connector documentation how modify apache, doesn't mention needs change in tomcat settings. here's basic set up. 3 installs on same machine (this test setup). so, apache 2.2 installed in c:\apache directory. listens on port 80. 2 tomcat 6 installs, 1 listens on port 81, 1 on port 82. apache route tomcat servers, acting 100% load balancer. here's errors i'm getting in mod_jk.log file when try connection @ http://localhost:80/index.jsp . it's 502 bad gateway error. [mon nov 15 13:05:04.681 2010] [3596:1496] [error] ajp_connection_tcp_get_message::jk_ajp_common.c (1245): wrong message format 0x4854 127.0.0.1:81 [mon nov 15 13:05:04.681 2010] [3596:14

numpy - csv to matrix in scipy -

i can't simple matrix operations work on data, life of me haven't been able figure out i'm doing incorrectly: data = np.genfromtxt(dataset1, names=true, delimiter=",", dtype=float) x = np.matrix(data) print(x.t*x) traceback (most recent call last): file "genfromtxt.py", line 11, in <module> print(x.t*x) file "/usr/lib/pymodules/python2.6/numpy/matrixlib/defmatrix.py", line 319, in __mul__ return n.dot(self, asmatrix(other)) typeerror: can't multiply sequence non-int of type 'tuple' print(data) gives: [ (3.0, 32.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 9.0, 0.0, 5.5606799999999996, 9.0) (4.0, 43.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 9.0, 0.0, 5.7203099999999996, 16.0) (5.0, 40.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 9.0, 0.0, 5.9964500000000003, 25.0) ..., (5.0, 50.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 12.0, 0.0, 6.2146100000000004, 25.0) (6.0, 50.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 12.0, 0.0, 6.291570

ruby on rails - Rails3: rewrite url_for for subdomain support, how to extend action mailer to use such url_for -

i take code subdomain railscast module urlhelper def with_subdomain(subdomain) subdomain = (subdomain || "") subdomain += "." unless subdomain.empty? [subdomain, request.domain, request.port_string].join end def url_for(options = nil) if options.kind_of?(hash) && options.has_key?(:subdomain) options[:host] = with_subdomain(options.delete(:subdomain)) end super end end class applicationcontroller < actioncontroller::base include urlhelper end it ok use modified url_for in views of controllers. have trouble actionmailer. i tried use following: class notifier < actionmailer::base include urlhelper end but actionmailer views still use old unmodified url_for actiondispatch::routing::routeset. what best practice add new url_for add following code file app/helpers/url_helper.rb: def set_mailer_url_options actionmailer::base.default_url_options[:host] = with_subdomain(request.subdoma

windows - See the stack of a process or what files and assemblies is calling or using -

al right! might sound crazy. i want know if possible see code or specific process using. have scheduled task supposed ran process. font end app says scheduled task executed successfully, don't see in logs. i want know if there tool see process doing. the best suite windows sysinternals mark russinovich (now bought microsoft). here . use process explorer . ever wondered program has particular file or directory open? can find out. process explorer shows information handles , dlls processes have opened or loaded. the process explorer display consists of 2 sub-windows. top window shows list of active processes, including names of owning accounts, whereas information displayed in bottom window depends on mode process explorer in: if in handle mode you'll see handles process selected in top window has opened; if process explorer in dll mode you'll see dlls , memory-mapped files process has loaded. process explorer

.net - Automatically Populating TextBoxes of a software from another vendor from my DB? -

i have software using. software has number of textboxes , cannot access code. how can automatically populate these textboxes through own databases? so example have win form of vendor has textfield of: first name last name address now want populate these textboxes own database. there anyway it? thank you! without know software , whether supports api, suggestion contact manufacturer of product first. if fails have consider using reflection , code injection. may not allowed in license. check carefully.

php - Convert String 'ten' to Integer 10 -

possible duplicate: converting words numbers in php is there php function convert string such 'ten' integer? if not how go it? have tried google , php.net search no success here's proof of concept class wrote this... check out: class wordtonumber { public $modifiers = array( 'hundred' => 100, ); public $negatives = array( 'minus' => true, 'negative' => true, ); public $numbers = array( 'zero' => 0, 'one' => 1, 'two' => 2, 'three' => 3, 'four' => 4, 'five' => 5, 'six' => 6, 'seven' => 7, 'eight' => 8, 'nine' => 9, 'ten' => 10, 'eleven' => 11, 'twelve' => 12, 'thirteen' => 13, 'four

Solr Search not showing results -

i new solr, doing prototype. indexed 5 documents , committed. now, if go http://localhost:8983/solr/admin/ , see 5 documents indexed. if search of terms in documents, don't see results. but, if : , see 5 records. what doing wrong. ideas? please help. thanks. probable problems: solr has cache of query. hold shift when hitting refresh button. the field querying on not indexed. change configuration of schema file. you may need specify field query. use "field:query" syntax.

android - Is there any way to send audio file to the speech-to-text recognition -

i want android speech recognition system analysing audio file , not default incoming voice microphone. is there way ? thank you. i suppose works in similar way chrome api - http://mikepultz.com/2011/03/accessing-google-speech-api-chrome-11/ as has mentioned can convert microphone file .flac file , send speech api, , same result. can use sox , convert yourself. hope helps. dias

jQuery(this) and ExternalInterface -

hey guys, i've got externalinterface call javascript function. how can use jquery target .swf called function? for example, i'm calling "changeobject" function using externalinterface. how jquery modify same flash files object tag? have , doesn't work: function changeobject() { jquery(this).css('height','500px'); }; jquery(this) get's returned undefined. not know id of object element. it's dynamic id. there multiple .swf's on page too. thanks! so set new flashvar unique playerid. this: var flashvars = {}; flashvars.src = '<?= $this->get('link') ?>'; flashvars.playerid = '<?= "flash-".uniqid(); ?>'; var params = {}; params.allowscriptaccess = 'always'; var attributes = {}; attributes.id = '<?= $this->get('attributeid') ?>'; swfobject.embedswf('<?= $this->get('pluginurl') ?>/flash/wiredriveplayer.swf', '

c# - DLLImport: passing short type parameter -

i'm trying pass parameter of short type c++ unmanaged function imported dll. in c++ dll code have following function: __declspec(dllexport)void changeicon(char *executablefile, char *iconfile, uint16 imagecount) { // code, doesn't matter } in c# managed code import function following code: [dllimport("iconchanger.dll")] static extern void changeicon(string executablefile, string iconfile, ushort imagecount); and call it: ushort imagecount = 2; changeicon("filepath", "iconpath", imagecount); the application executes function fine; however, message following text pops out: managed debugging assistant 'pinvokestackimbalance' has detected problem in 'foo.exe'. additional information: call pinvoke function 'bar.iconchanger::changeicon' has unbalanced stack. because managed pinvoke signature not match unmanaged target signature. check calling convention , parameters of pinvoke signature match tar

functional programming - fold_tree in OCaml -

as may know, there higher order functions in ocaml, such fold_left, fold_right, filter etc. on course in functional programming had been introduced function named fold_tree, fold_left/right, not on lists, on (binary) trees. looks this: let rec fold_tree f t = match t leaf -> | node (l, x, r) -> f x (fold_tree f l) (fold_tree f r);; where tree defined as: type 'a tree = node of 'a tree * 'a * 'a tree | leaf;; ok, here's question: how fold_tree function work? give me examples , explain in human language? here's style suggestion, put bars on beginning of line. makes clearer case begins. consistency, first bar optional recommended. type 'a tree = | node of 'a tree * 'a * 'a tree | leaf;; let rec fold_tree f t = match t | leaf -> | node (l, x, r) -> f x (fold_tree f l) (fold_tree f r);; as how works, consider following tree: let t = node(leaf, 5, node(leaf, 2, leaf))

vbscript debugger -

i have vbscript works in development not server. i want debug this, don't want install visual studio on server. what lightweight way debug using debugger? if you're referring "classic" vbscript, i.e. .vbs files, microsoft has tool available called microsoft script debugger functions more or less visual studio debugging session. it's lightweight option short of adding debug statements code.

jquery - How to hide a div by clicking the same toggle button or elsewhere in the document -

right can show div clicking button, , hide using same button. that's working fine, user able click outside of newly shown div or button show it, , still hide it. hey guys, first time asking question here, i'm sorry if didn't enter code right or something. have button, , want 1 way open hidden div (clicking said button), 2 ways close (clicking same opening button or elsewhere in document). here current code. //this part works fine opening , closing, can't click outside button make close once opened.<br/> $(".account").click(function () { $(".accountlinks").toggle(); $(".account").toggleclass("active"); }); $(document).click(function(e) { $('.accountlinks').hide(); $(".account").removeclass("active"); }); $('.accountlinks').click(function(e) { e.stoppropagation(); }); is there way see if opened, , close document.click function using $('.account').

authentication - Possible to switch a large PHP backend from HTTP Auth to a session-based system? -

i'm working add better authentication system mature backend site. i've been using http authentication because it's easy setup. site has grown, downsides method have become more , more pronounced; specifically, lack of security on standard http connections, , lack of standard mechanism log users out. i've read on every php authentication question can find on so, still haven't found satisfactory solution upgrading large existing codebase use session-based system. takeaway answers seems be: don't roll own if don't know you're doing session-based authentication really involved subject i have rolled own user registration system before, , indeed, seems woefully insecure looking @ now. can see taking months polish, when want doing working on backend itself. i imagine common problem. pretty every website i've built has required @ least minimal backend, , think few developers have chops ("expertise") build airtight system. i&#

bash - Oneliner to calculate complete size of all messages in maillog -

ok guys i'm @ dead end here, don't know else try... i writing script e-mail statistics, 1 of things needs calculate complete size of messages in maillog, wrote far: egrep ' hostname sendmail\[.*.from=.*., size=' maillog | awk '{print $8}' | tr "," "+" | tr -cd '[:digit:][=+=]' | sed 's/^/(/;s/+$/)\/1048576/' | bc -ql | awk -f "." '{print $1}' and here sample line maillog: nov 15 09:08:48 hostname sendmail[3226]: oaf88gwb003226: from=<name.lastname@domain.com>, size=40992, class=0, nrcpts=24, msgid=<e08a679a54da4913b25adc48cc31dd7f@domain.com>, proto=esmtp, daemon=mta1, relay=[1.1.1.1] so i'll try explain step step: first grep through file find lines containing actual "size", next print 8th field, in case "size=40992,". next replace comma characters plus sign. then delete except digits , plus sign. then replace beginning of line "(",

PHP - Codeigniter professional structure -

i graduating in next month. applying entry level php developer jobs. many companies asking send sample code. i sending sample controller, view , model files , screenshots of outputs, not getting through. please me. doing wrong? supposed send them? there professional way of writing/structuring code? my sample code files are: controller <?php class newsrelease extends controller { function newsrelease() { parent::controller(); $this->load->helper('url'); // $this->load->helper('form'); $this->load->model('news_model'); $this->load->library('session'); } /* loads home page called 'home_view'. before loading this, checks wheter admin logged in or not , clears admin session. because, when admin logged out, shown page. */ function index() { $checksession=$this->session->userdata('name'); if(isset($che

How to clear the Android Stack of activities? -

i have application several activities in android , want user able log-out pressing menu button. problem have that a) android doesn't let terminate application and b) when send user loginactivity again can press back , right previous activity in. i tried launch activity 2 following flags: intent intent = new intent(this, loginactivity.class); intent.setflags(intent.flag_activity_new_task); intent.setflags(intent.flag_activity_clear_top); startactivity(intent); i tried each 1 of them themselves. i tried calling finish() after startactivity(intent) read in stackoverflow question. in login activity, override button, hides app instead of finishing activity: @override public boolean onkeydown(int keycode, keyevent event) { if (keycode == keyevent.keycode_back) { movetasktoback(true); return true; } return super.onkeydown(keycode, event); } also sure set android:alwaysretaintaskstate="true" on root activity, an

How to abbreviate MySQL queries in PHP? -

i have page needs make 6 identical queries difference between them being value of "category": $query = "select * table_name category="category1"; instead of writing out 6 different $query variables ($query1, $query2, etc.) each different category, i'd abbreviate can pass in category variable each time instantiate $query, so: $query = "select * table_name category='$cat'"; $results= mysql_query($query,'category1'); there must way this, can't find syntax anywhere passing variable mysql query in way (i checked php.net, site, various other php resources on google). can me out? much appreciated, thanks! you can use sprintf that: $query = "select * table_name category='%s'"; $results= mysql_query(sprintf($query,'category1'));

vim - Python: open and display a text file at a specific line -

i don't use python often, develop simple tools in make life easier. used log checker/crude debugger sas. reads sas log line line checking errors in list , dumps finds standard out (i'm running python 2.6 in redhat linux environment) - along error, prints line number of error (not that's super useful). what i'd optionally feed script line number , have open sas log in gvim , display scrolled down line number i've specified. haven't had luck finding way - i've looked pretty thoroughly on google no avail. ideas appreciated. thanks! jeremy once you've got line number, can run gvim filename -c 12 , go line 12 (this because -c <command> "execute <command> after loading first file", -c 12 saying run :12 after loading file). so i'm not sure if need python @ in case; sending line number direct gvim may need.

php - Can't Upload File on IIS -

i on shared-hosting account godaddy it's windows server , getting error when attempting upload file: warning: move_uploaded_file(d:\hosting\6903\html\pdfs\aldomypdfap.pdf) [function.move-uploaded-file]: failed open stream: permission denied in d:\hosting\6903\html\back.php on line 436 warning: move_uploaded_file() [function.move-uploaded-file]: unable move 'd:\temp\php\php98c.tmp' 'd:\hosting\6903\html\pdfs\aldomypdfap.pdf i have heard can set php.ini file change directory it's being uploaded to, work, can't access php.ini file. i have tried create own php.ini file in root of directory, , causes sorts of problems, such not finding correct mysql configuration files, godaddy's support on remove custom php.ini file, ridiculous, know. i have tried use ini_set this ini_set('upload_tmp_dir', 'd:/hosting/6903/html/pdfs/'); but hasn't made effect. have other options here? thank you! update: coda octal permissions read 777 of de

file get contents - PHP file_get_contents on a Google search? -

i'm trying use php return resultant html of google search. so instance <?php $file = file_get_contents('http://www.example.com',false); echo $file; ?> will return html contents of example.com. problem is, when try on google search url, e.g., http://www.google.com/#sclient=psy&hl=en&q=cats , returns html main google page , not search results 'cats'. what's easiest way this? you want url of form: http://www.google.com/search?q=cats the url you're using new "instant search"

algorithm - Python: find a duplicate in a container efficiently -

i have container cont . if want find out if has duplicates, i'll check len(cont) == len(set(cont)) . suppose want find duplicate element if exists (just arbitrary duplicate element). there neat , efficient way write that? [python 3] ok, first answer has gotten quite bit of flack, thought i'd try few different ways of doing , report differences. here's code. import sys import itertools def getfirstdup(c, totest): # original idea using list slicing => 5.014 s if totest == '1': in xrange(0, len(c)): if c[i] in c[:i]: return c[i] # using 2 sets => 4.305 s elif totest == '2': s = set() in c: s2 = s.copy() s.add(i) if len(s) == len(s2): return # using dictionary lut => 0.763 s elif totest == '3': d = {} in c: if in d: return else:

javascript - How to save Google Maps V3 distance result to MySQL database? -

(and sorry in advance being such basic question @ core) i have mysql database location info, , php script can put new, user-submitted location database. want (immediately) find distances between newly-submitted location , subset of existing locations in database using google maps directions request, , store these distances in database. i can select locations subset via php , use javascript fetch distance data google maps, how transfer these javascript variables database? -what's best way save group of javascript variables separate entries in mysql database? thanks help! carl if have distances loaded variables in js code, can make xmlhttprequest send them server php script put them database. pseudo-code this: js: function storedistance(pointid1, pointid2, distance) { var xhr = new xmlhttprequest(); xhr.open("post", "/savedistance.php", true); xhr.send("pid1=" + pointid1 + "&pid2=" + pointid2 + "&dis

How to process login with spring security core and grails -

i have integrated spring security core in grails project , s2-quickstart too. so got basic gsps, domain controllers also. so have 1 user id = 'me' , password (encoded) = 'password' inside database role = 'role_admin'. now confuse api classes have. need show login page on start of project , if user enters correct id password should redirect dashboard page. have written following piece of code : urlmapping.groovy ================= "/"(controller:"login", action:"auth") logincontroller.groovy ====================== class logincontroller { def authenticationtrustresolver def springsecurityservice def index = { redirect(action: 'auth', params: params) } def auth = { //checking licensing stuff .... .... } def signin = { if ( params.username == null ) redirect(action: 'login') def config = springsecurityutils.securityconfig if (springsecurityserv

c++ - Simple boolean operators for bit flags -

i attempting learn more implement in project. i have got basically: unsigned char flags = 0; //8 bits flags |= 0x2; //apply random flag if(flags & 0x2) { printf("opt 2 set"); } now wishing little more complex things, wanting apply 3 flags this: flags = (0x1 | 0x2 | 0x4); and remove flags 0x1 , 0x2 it? thought applying bitwise not (and bitwise , apply it): flags &= ~(0x1 | 0x2); apparently remain there or either way when check. i not know how check if not exist in bit flags (so cannot check if previous code works), this? if(flags & ~0x2) printf("flag 2 not set"); i can not find resources recent searches apply this, willing learn teach others, interested. apologize if confusing or simple. and remove 2 it? thought this: flags &= ~(0x1 | 0x2); to remove 2 flags, apparently remain there or either way. that correct way remove flags. if printf("%d\n", flags) after line, output shou

android - Display only child items in Expandable list No need of parent indicator -

hi displaying items according different categories using expandable listview.now want display items ,no need of parent name or parent indicator.is there solution expandable list view diplay child items .i don't have time thats y displaying items expandable list view(i alredy developed one) .so please give me suggestions.it urgent.thanks in advance i think cannot have child view without group view in expandablelistview. adapter using populating group , child view?

OWL universal quantification -

i half way reading owl2 primer , having problem understanding universal quantification the example given is equivalentclasses( :happyperson objectallvaluesfrom( :haschild :happyperson ) ) it says happy person if children happy persons. if john doe has no children can instance of happyperson? parent? i find part confusing, says: hence, our above statement, every childless person qualified happy. but wouldn't violate objectallvaluesfrom() constructor? i think primer quite job @ explaining this, particularly following: natural language indicators usage of universal quantification words “only,” “exclusively,” or “nothing but.” to simplify bit further, consider expression you've given: happyperson ≡ ∀ haschild . happyperson this says happyperson only has children happyperson (are happy). logically, says nothing existence of instances of happy children. serves universal constraint on children may exist (note includes instanc

prolog - reversible "binary to number" predicate -

what best way convert binary bits (it might list of 0/1, example) numbers in reversible way. i've written native predicate in swi, there better solution ? best regards use clp(fd) constraints, example: :- use_module(library(clpfd)). binary_number(bs0, n) :- reverse(bs0, bs), foldl(binary_number_, bs, 0-0, _-n). binary_number_(b, i0-n0, i-n) :- b in 0..1, n #= n0 + b*2^i0, #= i0 + 1. example queries: ?- binary_number([1,0,1], n). n = 5. ?- binary_number(bs, 5). bs = [1, 0, 1] . ?- binary_number(bs, n). bs = [], n = 0 ; bs = [n], n in 0..1 ; etc.

objective c - ViewController may not respond to'method' problem -

i know common problem, googled lot , seems no luck solve problem. have @interface testviewcontroller:uiviewcontroller , in implementation file have method defined: -(void)method1 { something; [self method1];//here need call method if statement true , line warning testviewcontroller may not respond to'method1' got } -(void)method2{ [self method1] //but there no problem line } can me? in advance! your method declarations missing in header. add -(void)method1; -(void)method2; to testviewcontroller.h file update: the reason why don't warning second call ( [self method1] within method2) is, compiler knows method1 @ point. (because implementation occurs before method2)

asp.net - Developing with SQL Server 2005 and deploying to SQL Server 2000 -

i'm developing web application using sql server 2005, asp.net mvc, asp.net sql membership provider (for authentication , authorisation), , linq sql. works great , running planned in development environment. however, production environment has sql server 2000 installation, , unable obtain copy of sql server 2000 use in development. upon deploying web application the production environment, options have migrating database (schema + data) 2005 2000? you should make sure database compatibility in development system set sql server 2000, , consider using tool such redgate toolbelt scripting out schema , data deployment.

Anyone know why Delegate.BeginInvoke isn't supported on Silverlight? -

the msdn docs state: in silverlight, begininvoke method automatically defined on delegate types throws notsupportedexception, cannot use make asynchronous method calls on thread pool threads. but doesn't state why. anyone have idea? complex question. begininvoke method declarations delegates looks like [methodimpl(0, methodcodetype=methodcodetype.runtime)] public virtual iasyncresult begininvoke(...some params...); most important part here methodcodetype.runtime. specifies method implementation provided runtime. more runtime implementation may read in this pretty old still actual article . silverlight cross platform framework. should implement own platform independent (i.e. managed) mechanism of asynchronous execution (threading , dispatching). that's story of managed deployment.current.dispatcher class , begininvoke method might called silverlight. btw both dispatcher , dispatcheroperation classes cls compliant guarantees work @ differ

perl - Catalyst + mod_cgi -

i developed catalyst application deploy. host ( ovh ) allows perl applications via mod_cgi. unfortunately, i'm used running catalyst apps on mod_perl. have no experience mod_cgi whatsoever, , can't seem find documentation on how should catalyst app running on mod_cgi. any chance of guys give me hand? has of ever run catalyst app on ovh's services? thanks, ldx catalyst.pl creates cgi program. foo-bar> cd .. > catalyst.pl -scripts foo::bar > ls foo-bar/scripts/ for catalyst 5.8, code of foo-bar/scripts/foo_bar_cgi.pl excluding pod looks like: #!/usr/bin/env perl use catalyst::scriptrunner; catalyst::scriptrunner->run('foo::bar', 'cgi'); 1;

Drools error with IKVM -

we using drools engine on our client written in c#. using ikvm convert drools jar , our java beans dll's using ikvm. rule similar this:- rule "aggregate rule" when $b : bill(billamount > 100) $n : number(doublevalue > 100) accumulate ( $l : lineitem() $b.finditems("color", "blue"), sum($l.getsellingvalue())) voucherseries fact0 = new voucherseries(); fact0.setseriescode( "aggregate voucher" ); insert(fact0 ); voucherlist.add(fact0); system.out.println("sum" + $n); end this rule works fine when run java based drools api's, while running ikvm converted drools, throws following error:- unable cast object of type 'accumulatememory' type 'frommemory'. any ideas on might going wrong ? this can have many causes. example classloading problem. can bug in ikvm. etc. i think not receive helpful answer here. should contact mailing

gtk - Using Vim warning style in gVim -

when example edited file changed outside of vim, vim issues warning , offers reload file. in command line vim green text on bottom appears, in gvim there gtk+ popup window instead. vim behaviour more, , i'd have in gvim well, how can change that? there option enable behavior in gui version of vim. if c set in guioptions , console-like dialogs used instead of graphical popup ones. :set guioptions+=c

java - How to simulate 120 concurrent users of a web application with real conditions? -

how simulate > 120 concurrent users using load test framework such jmeter? real concurrency, far understand, possible if use 120 servers or 120 cpu cores. how did/do test web application or service real conditions? i have found jmeter work fine, use across 4-5 pc's accurate results. although may believe 120 concurrent users may difficult simulate single pc, have realise in real work scenario, 120 simultaneous users not accessing server @ same time, therefore cpu threading algorithms sufficient simulate load. what need understand usage of application users, i.e. how many requests per second/minute single user , make sure test simulates effectively. so, our technique use jmeter running on 5 pcs running different tests, , monitor server performance during tests. there of course many other products available price able better simulate web traffic, have found jmeter needs.

c# - asp.net mvc avoid duplication -

i have users table in no 2 same users can exists , best way error free? what did wrote check duplication in controller, said me it's not right thing do. said put unique on database table? have implemented on several other controllers well. ought change it? there several places should this. at database table level: use email username , mark unique constrant at model validation level can check email , return validation error at client side, can place code using async request check duplicate email or username in real time when user enters username in textbox -- edit -- it suggested place 3 better validations. inconsistent data worst thing system else. because think is, correct data = quality -- end edit -- please keep in mind validation code should placed @ model , learn how write manageable oo code can see example of mvc store front . hope help

c# - Making a twitter mono client -

hey everyone! making small twitter client using mono whant know if there librarys use. using twitterizer http://www.twitterizer.net mono isn't officialy supported. i new in comments , links welcome. i don't officially support using mono twitterizer, because i've barely ever used mono , couldn't relied on support. there have been few mono projects implement twitterizer, notably smuxi (http://www.smuxi.org/main/). although few revisions behind, source code start if you're looking modify twitterizer use mono.

eclipse: validate xml with xsd -

Image
does know if possible validate xml xsd while editing xml in eclipse? this how xml begins: <root xmlns:xi="http://www.w3.org/2001/xinclude" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="../definitions.xsd"> right click , validate. if not validated, eclipse cannot reach xsd file. definitions.xsd in parent directory of xml? can define xml catalog entries xsds. anyway, if fine, during saving should validate xml. validation come code completion of elements , attributes. both work or neither. update: picture make validate action more clear:

iphone - NSClassFromString - doesn't work -

Image
i'm trying use dynamic typing in obj-c, i've got following code , errors: for me seems good, don't want work, ideas? since not creating new instance (just retrieving one), there no need this. sufficient: // if don't know exact class of cell, type common superclass of cells uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"rssitemcell"];

arrays - PHP: help with this logic -

i have problem. have table of support tickets (wh_task). each task has date_completed (d/m/y) , has_met_sla field (0 or -1). want allow user search table date_completed , display chart based on results. the charts data has can populate barchart (fusion charts): year: 2010 | month: nov | sla met: 12 | sla missed: 2 year: 2010 | month: oct | sla met: 15 | sla missed: 1 the chart have numbers x-axis , "nov 2010" along y. each month along y has 2 columns, met , not met. so, can create kind of chart no problem it's generating data i'm having trouble coming with. below query: $tsql = "select task_id, has_met_service_level_agreement, date_completed ". "from wh_task ". "where (task_status_id = 5) , (account_id =$atid)"; $stmt = sqlsrv_query( $conn, $tsql); if( $stmt === false) { echo "error in query preparation/execution.\n";

c# - How to read access rights from access mask? -

user can have following access rights: read = 1 create = 2 edit = 4 delete = 8 publish = 16 administer = 32 when access rights saved in database, 1 number used represent access rights user. e.g. 3 = read + create 25 = read + delete + publish how can access rights given number (access mask)? any appreciated! var mask = (accessrights)25; var rightsformask = enum.getvalues(typeof(accessrights)) .cast<accessrights>() .where(x => mask.hasflag(x)); foreach (var right in rightsformask) { // displays "1:read", "8:delete", "16:publish" console.writeline((int)right + ":" + right); } // ... [flags] public enum accessrights { read = 1, create = 2, edit = 4, delete = 8, publish = 16, administer = 32 } if you're not using .net4 hasflag method won't available, in case you'll need change where clause read where(x => (mask & x) == x) .