Posts

Showing posts from August, 2011

how to supress popup window from emacs programatically? -

for example, have setup in .emacs (defun gtags-create-or-update () "create or update gnu global tag file." (interactive) (if (y-or-n-p-with-timeout (format "run gtags create/update tag file code @ %s (default no)? " default-directory) 5 nil) ; default - no run (unless (= 0 (call-process "global" nil nil nil " -p")) ; tagfile doesn't exist? (let ((olddir default-directory) (topdir (read-directory-name "gtags: top of source tree: " default-directory))) (cd topdir) (shell-command "gtags -v") ;; (shell-command "gtags && echo 'created tagfile'") (cd olddir)) ; restore ;; tagfile exists; update (shell-command "global -uv")))) ;; (shell-command "global -u && echo 'updated tagfile'"))) (add-hook 'c-mode-c

javascript - Why I cannot add field to a JS object? -

i'm programming node sequelize orm mysql. need add new field object sequelize returns on query, doesn't seems work. category.find({ where: { id: req.params.id }, include: [item] }).success(function(category) { var items = category.items; var ci = category.items.map(function(item) { return item.id; }); delete category.items; // works category.item_ids = ci; // doesn't // category['item_ids'] = ci; // doesn't work res.send({ category: category, items: items }); }); object.isextensible returns true on category object, can't figure out how extend it try this: .success(function(category) { category = category.tojson(); // convert simple js object ... category.item_ids = ci; ... res.render(...); });

php - How to write a function similar to $_GET? -

is there function works $_get ? mean function transforms "?var1=5&var2=true" to $var1=5; $var2="true"; so can use 1 variable (string) in function , fetch many variables it? like: function manual_get($args){ /* ? */} function myfunction($args) { manual_get($args); if(isset($var1))/* doesn't have way, btw */ { do_something($var1); } //etc } p.s. : don't want use $_get url because file class file (namely database_library.php) don't execute directly, or make ajax call. require_once(); it. yes, there is. called parse_str : http://php.net/manual/en/function.parse-str.php

php - how to prompt search query into a dynamic iframe -

hi there creating data grid loads data database , had created search box prompts search queries when user inputs value want show search query same iframe loading file of data table , when search box empty should show data table , if user enters query should load query here script <div style="float: right; border: 1px; padding-right: 20px;"> <div class="search"> <input type="text" name="s" maxlength="64" placeholder="search" id="inputstring" onkeyup="lookup(this.value);" /> <img src="images/srch.png" id="srch_btn"/> </div> </div> </div>

java - Getting records from database with variable condition -

i'm trying lists of records id in specific set. set application via web service. should write query this: select * tbl_data id in (?, ?, ?, ?) . problem (?, ?, ?, ?) part variable length. 1 request like: select * tbl_data id in (?, ?, ?) , like: select * tbl_data id in (?, ?, ?, ?, ?, ?) . don't loop , records 1 one. there way build query? you can generate in part of query in code. if know should instead of ? symbol , run loop , build it. string sqlpart = "("; (every symbol last){ sqlpart += symbol; sqlpart += ","; } sqlpart += lastsymbol; sqlpart += ")"; string sql = "select * tbl_data id in " + sqlpart;

javascript - Change Arial to some other font on the whole webpage -

i'm thinking script can change webpage's font appearance arial other font face of choice. how should go doing that? i understand: * { font-family: "somefont"; } but won't achieve objective target arial text. i can use jquery or javascript, whichever more efficient , fast. edit: seems people have difficulty understanding question. i'll explain more, want arial text on webpage, if exists , change in appearance. i going suggest looping through stylesheets array and, each style sheet, loop through rules, find ones defining arial font, , change other font want. way wouldn't have visit every element on page. the problem suggestion, though, inline styles on elements. so hate say, you'll have visit every element on page. pages, won't problem, mileage may vary. here's how you'd jquery: $("*").each(function() { var $this = $(this); if ($this.css("font-family").tolowercase().indexof(&qu

css3 - CSS Navigation Menu Won't Resize -

website: www.medtransportcenter.com the navigation menu pure css, built css3 menu software. menu on site displays sizes each element off. i've been trying make each element more (around 140-150px width / height fine), instance can see comments wider others (252px x 50px). i've tried manually overriding width in separate stylesheet comments element: li#menu-item-139.menu-item.menu-item-type-post_type.menu-item-object-page.menu-item-139 { width: 140px; } unfortunately, didn't work , i'm stuck on how fix it. appreciated. there % widths set in stylesheet like ul#css3menu11>li:nth-child(4) { width: 26%; basically need play them or remove them.

iphone - Price ui text field: how to allow user to enter only one decimal dot in to the text field for price like 283.99 -

this question has answer here: limiting text field entry 1 decimal point 9 answers i have tried code follow this helps me allow user enter only numbers , dot (decimal point) but problem user can allow n number of decimals in method. i want allow 1 decimal and 2 digits after decima like 123.00 , 123423432353.99 but not 123.4.4 , 123.12345, 123...23 - (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string{ if (string.length == 0) { return yes; } nscharacterset *mycharset = [nscharacterset charactersetwithcharactersinstring:@"0123456789."]; (int = 0; < [string length]; i++) { unichar c = [string characteratindex:i]; if ([mycharset characterismember:c]) { return yes; } } uial

java - Scale 2D-Array using Bicubic Interpolation -

i want scale arbitrary double[][] double[][] different dimensions. values of resulting array should calculated based on input array using bicubic interpolation. i know done in image processing decades now, unable find library or @ least working code snippet works 2d-array rather specific image objects, that's why i'm asking here. more specific requirements: as far i've understood, value of point between corners of 3x3-grid can calculated directly using bicubic interpolation, first function need double interpolate(double[][] grid3by3, double x, double y)` where x , y between 0.0 , 1.0 the next step of course ease process 3x3 grid chosen every point automatically , can like `double[][] interpolate(double[][] input, int newwidth, int newheight)` this me new array specified dimensions same borders input array. where want this: `double[][] interpolate(double[][] input, int newwidth, int newheight, double minx, double miny, double

c - Perform CURL only if last CURL is more than 10s ago -

i have procedure in smartmeter daemon log counter of gas consumption: void http_post(const char *vzuuid) { sprintf(url, "http://%s:%d/%s/data/%s.json?ts=%llu", vzserver, vzport, vzpath, vzuuid, unixtime()); curl *curl; curlcode curl_res; curl_global_init(curl_global_all); curl = curl_easy_init(); if(curl) { file* devnull = null; devnull = fopen("/dev/null", "w+"); curl_easy_setopt(curl, curlopt_useragent, daemon_name " " daemon_version ); curl_easy_setopt(curl, curlopt_url, url); curl_easy_setopt(curl, curlopt_postfields, ""); curl_easy_setopt(curl, curlopt_writedata, devnull); if( (curl_res = curl_easy_perform(curl)) != curle_ok) { syslog(log_info, "http_post(): %s", curl_easy_strerror(curl_res) ); } curl_easy_cleanup(curl); fclose ( devnull ); } curl_global_cleanup(); } i want execute if last call more 10s ago. thought of global variable last_time r

ios - How to add a key and string in dictionary? -

Image
my plist file: nsarray *documentpaths = nssearchpathfordirectoriesindomains(nscachesdirectory, nsuserdomainmask, yes); nsstring *path = [[documentpaths lastobject] stringbyappendingpathcomponent:@"data.plist"]; dict = [nsdictionary dictionarywithcontentsoffile:path]; loop through array, adding annotations , calculate distance: ann = [dict objectforkey:@"blue"]; [resultarray addobject:@"blue"]; for(int = 0; < [ann count]; i++) { nsstring *coordinates = [[ann objectatindex:i] objectforkey:@"coordinates"]; double reallatitude = [[[coordinates componentsseparatedbystring:@","] objectatindex:1] doublevalue]; double reallongitude = [[[coordinates componentsseparatedbystring:@","] objectatindex:0] doublevalue]; myannotation *myannotation = [[myannotation alloc] init]; cllocationcoordinate2d thecoordinate; thecoordinate.latitude = reallatitude; thecoordinate.longitude = reallongitude; myannotati

Using PHP Slim Framework -

i want use slim php in project first time. manual says: install composer in project: curl -s https://getcomposer.org/installer | php create composer.json file in project root: { "require": { "slim/slim": "2.*" } } install via composer: php composer.phar install add line application’s index.php file: <?php require 'vendor/autoload.php'; i'm afraid, don't it. should commands "curl" , "php" used? access webspace through filezilla. how can apply such command? what steps anyway? sadly, manual not helpful @ all. see http://www.slimframework.com/install : manual install download , extract slim framwork project directory , require in application’s index.php file. you’ll need register slim’s autoloader. <?php require 'slim/slim.php'; \slim\slim::registerautoloader(); and there links zip-files.

android - SQLiteDatabase.openDatabase(...) vs getWritableDatabase -

i bundled database app in assets folder. @ first activity, copy database correct location (no problem here). my question; better use opendatabase (string path, sqlitedatabase.cursorfactory factory, int flags) or use getwritabledatabase method of sqliteopenhelper class? which more efficient? i'm accustomed using getwritabledatabase method, requires passing of context, feel can without since don't need onupgrade or oncreate function of sqliteopenhelper. getwritabledatabase sqliteopenhelper 's way of opening databases. if not need sqliteopenhelper , not need call getwritabledatabase either.

mysql - how to manage server load when million of users hit at once in my php website? -

i new php development, working on website social networking site , having more 5000 members. website has built in dolphin-boonex php. however website running smooth no problem. afraid after 5 years if million of users hit @ same time, happen? breakdown. how overcome problem. how facebook manage load on server every minute has millions of hit @ time. please me ideas, link. programming methodology should use this? how should database manage? thanks, this not as php question operating systems question. serve 1 million users use linux virtual server load balances traffic between several machine or consider cloud service. but mark baker suggested, quite unlikely have deal many requests.

How can i load 2 spring context in same JVM? -

i've 2 applications each 1 uses different spring application context configuration on same jvm, , every time tries run both of them found problem last 1 configuration overrides previous 1 spring context loaded last 1 configuration, advices how overcome this, letting every application runs it's configuration without affected other spring context.

usb - Is there any way how to hard reset FTDI chip using libftdi or libusb? -

i need reset ft2232h in order regain mpsse output after switching ft245 sync fifo, using ftdi_usb_reset() (on both channel , channel b) cannot mpsse after ft245 enabled , way regain access mpsse unplug , replug usb ftdi. but need in software, because time time design in fpga gets stuck , since debugging stucks in fpga tedious , not guaranteed i'll find stucks, need mpsse access reset pin of fpga , unplugging device not convenient. this needed firmware updates, need mpsse put fpga hi-z access spi flash bitstream , inconvenient user replug usb device before updating fw. is there libftdi or libusb way to, ideally reset power of usb device?

typedef - Defining variable for recursive data structure in C -

i have function sortbyname returns recursive data structure sortedlist . sortlist contains pointer recursive data structure stud_type , defined below. typedef struct stud_type_ { int matricnum; char name[20]; struct stud_type_ *next_student; } stud_type; typedef struct sort_list { stud_type *cur; struct sortlist *next; } sortlist; stud_type listofstudents; // assume not null sortlist * sortbyname() { sortlist *slist; //sort algorithm here return slist; } ... ... int main() { //trying define curtest = sortbyname() here while (curtest!=null) { printf("name: %s\n", curtest->cur->name); curtest = curtest->next; } } now assign variable in main() function hold return value sortbyname function can iterate through while loop , print out results. how define variable? tried sortlist curtest; , sortlist * curtest; no avail. or there wrong definition of sortbyname functi

google app engine - webapp2 changes html tags in pure text -

i want make gae application webapp2 compatible. code worked great webapp: insert = '<p><font color="red"><b>some text</b></font></p>' template_values = { 'insert': insert, ... } path = ... self.response.out.write(template.render(path,template_values)) the content of variable insert put web page output webapp. content of variable "analyzed" webapp2 , content changed when inserted in webpage. webapp2 inserts this: &lt;p&gt;&lt;font color=&quot;red&quot;&gt;&lt;b&gt;some text&lt;/b&gt;&lt;/font&gt;&lt;/p&gt; how can go old behavior? thanks help. have @ safe : https://docs.djangoproject.com/en/dev/ref/templates/builtins/#safe & autoescape : https://docs.djangoproject.com/en/dev/ref/templates/builtins/#autoescape . eg: {{ inserthtml|safe }} or {% autoescape off %}{{ inserhtml }}{% endautoescape %}

ruby on rails - Sorting records quickly from a model with 500k records -

i attempting sort records in model has 500k rows in it. when attempted procedure had 200 records , used following code , pulled out records 1-5 list popular: @mostpopular = product.find(:all, :order => 'click_count desc') however, have far larger dataset, grinds computer halt , looking try complete search in more efficient manner. i have tried adjusting code @mostpopular = product.order('click_count desc').limit(10) still take long time complete... is there more efficient way pull out top 10 popular records large dataset? thanks time the answer not in rails, it's in database. write query log, can see query being done: logger.debug product.find(:all, :order => 'click_count desc').limit(10).to_sql once have sql in hand, head on database's console , ask show query plan , statistics query. don't database you're using, in postgresql, you'd use explain command. i'll see row scan (aka sequence scan) being d

android - Voice recognition not working as a service when Google Search version > 2.2.10.573038 -

some friends , have been working in app requires have service running listening voice commands. have implemented listener. however, after started having problems because operating system killed service after while (i suppose reclaim resources). (apparently) fixed problem making service foreground process (calling startforeground). we have been testing app in range of devices , found out app still being killed os in devices. having close @ issue found out devices app being killed have google search version greater or equal 2.3... (for instance 2.4.10.626027) if uninstall updates , downgrade version 2.2.10.573038 works charm. by way, have mentioned google search here because when start voice listener, package named com.google.android.googlequicksearchbox started. does have idea of why might be? or main differences exist between versions 2.2.10.573038 (and older) , after? of course solution downgrade version compatible newer versions too...

linux - why i can not disable multicast request -

i use following command disable eth0 interface's multicast mode , not works : sudo ifconfig eth0 -multicast when this, eth0's configure so: ifconfig -v eth0 eth0 link encap:ethernet hwaddr 00:16:3e:e8:43:01 inet addr:10.232.67.1 bcast:10.232.67.255 mask:255.255.255.0 broadcast running mtu:1500 metric:1 rx packets:46728751 errors:0 dropped:0 overruns:0 frame:0 tx packets:15981372 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 rx bytes:8005709841 (7.4 gib) tx bytes:3372203819 (3.1 gib) then, icmp echo_request in host 10.232.67.2: ping 224.0.0.1 and tcpdump package on host 10.232.67.1: tcpdump -i eth0 host 224.0.0.1 -n tcpdump: verbose output suppressed, use -v or -vv full protocol decode listening on eth0, link-type en10mb (ethernet), capture size 96 bytes 21:11:03.182813 ip 10.232.67.2 > 224.0.0.1: icmp echo request, id 3639, seq 324, length 64 21:11:04.184667 ip

c# - How to save and load in panel? -

i want save image panel bitmap , want load saved image after form comes out of minimizing mode. bitmap bmp = new bitmap(panel1.width, panel1.height); panel1.drawtobitmap(bmp, panel1.bounds); bmp.save(@"c:\test"); panel1.backgroundimage = image.fromfile(@"c:\test"); and event should use minimizing event? p.s. c# beginner. edited drawing panel's contents. should done inside paint event handler, this: private void panel1_paint(object sender, painteventargs e) { using (pen p = new pen(color.red, 3)) { // panel's graphics instance graphics gr = e.graphics; // draw panel gr.drawline(p, new point(30, 30), new point(80, 120)); gr.drawellipse(p, 30, 30, 80, 120); } } saving panel's contents image. part should done somewhere else (for example, when click on "save" button): private void savebutton_click(object sender, eventargs e) { int width = panel1.size.width; int h

java - Scale an image with Graphics2D -

in game making want power ups airdrops. have image of crate want draw bigger have drawn it. want image become progressively smaller times looks it's dropped air. have crafted code think should work reason doesn't. if(power.getpowerup()){ double cratex = (int) power.getx(); double cratey = (int) power.gety(); image crate = power.getcrate(); int cratew = crate.getwidth(null) + 100; int crateh = crate.getheight(null) + 100; if(cratew > 64){ g2d.drawimage( power.getcrate(), (int) cratex, (int) cratey, cratew, crateh, ); cratex += .5; cratex += .5; cratew -= 1; crateh -= 1; } else { g2d.drawimage( power.getcrate(), (int) cratex, (int) cratey, cratew, crateh, ); } } i have method inside paintcomponent(graphics g) , use thread repaint graphics. why doesn't work? have use values class? how make progressively smaller? you recreating cratew , crateh variables everytime method calle

Find and replace specific characters in Word headings -

i have huge size word document (32mb). want find , replace following characters (say space or nothing, remove them) in headings (h1 h9 or every heading level being used) , not anywhere else: ,-_;~%&*()?/. can help? want using macro. know manual way using find dialog cumbersome because of huge size of document. thank help.

jQuery how to get number from string? -

i have html: <span class="price-old" style="padding: 2px;">179,00 dkk</span> or be: <span class="price-old" style="padding: 2px;">1.750,00 dkk</span> how number? try this: parseint($('.price-old').text().replace(/[^0-9.]/g, "")); //<-- remove parseint() include value after decimal point demo

applescript - 'tell application "Finder" to restart' brings up WorkflowServiceRunner.xpc wants to make changes -

i wrote reboot scripts both snow leopard , lion boot between them. sl script works fine, seems lion has additional security feature requires password when script run. i dialog requesting password says: "workflowservicerunner.xpc wants make changes. type password allow this" is there way in code send pw info runs automatically? you mean had type password because of tell application "finder" restart ? in case, can use do shell script "killall finder" tell application "finder" open

c - Using shared memory with matrices -

i want create matrix in shared memory segment. in second programme can read taillex , tailley matrix has '0' in value. create matrix in function initialisersegmem , values ok... have problem pointers... my struct mem_share: typedef struct mem_partage{ int** carte; int tailley; int taillex; }mem_share; mem_share initialiserdonneemem(grille* g){ mem_share mem_share_carte; int x = g->taillex; int y = g->tailley; int i,j; mem_share_carte.carte = malloc(y*sizeof(int*)); for(i=0;i < y;i++){ mem_share_carte.carte[i] = malloc(x*sizeof(int)); } mem_share_carte.carte = g->carte; mem_share_carte.tailley = y; mem_share_carte.taillex = x; return mem_share_carte; } void initialisersegmem(mem_share *mem_share_carte){ int shmid,id_memoire,i,j; int test = 100; int *adresse_mem; key_t cle; cle = 9999; /* creation of shared memory segment */ if(shmget(cle,(int) sizeof(mem_sh

c - From []byte to char* -

i want wrap c function takes char* pointing (the first element of) non-empty buffer of bytes. i'm trying wrap in go function using cgo can pass []byte , don't know how conversion. simplified version of c function's signature is void foo(char const *buf, size_t n); i tried passing pointer first byte in slice with c.foo(&b[0], c.size_t(n)) that doesn't compile, though: cannot use &b[0] (type *byte) type *_ctype_char in function argument so what's correct procedure here? go-wiki describes reverse situation. ok, turned out easier thought: (*c.char)(unsafe.pointer(&b[0])) does trick. (found @ golang-nuts .)

node.js - Exporting functions to multiple callers in different files -

i'm building logging module can called multiple callers located in different files. my objective initialize log file @ start of program , have callers call function logs file initialized earlier without going through whole initialisation again. i can't quite grasp concept of module exports hence i'm hoping can help. the actual logging occurs on method write. on main app.js file, can initiate , log fine. however on different file, i'm having mental block on how can log file without going through creating logfile again. var fs = require('fs'); var fd = {}, log = {}, debug = false; var tnlog = function(env, file, hostname, procname, pid) { if (env == 'development') debug = true; fd = fs.createwritestream(file, { flags: 'a', encoding: 'utf8', mode: 0644 }); log = { hostname: hostname, procname: procname, pid: pid }; }; tnlog.prototype.write = function(level, str) { if (debug) console.log(str); else { log.

asp.net - Web Application and DDD -

i'm new ef, want develop web application sell. i've been reading ddd (domain-driven design ), find implementation complicated. suggestions or project understand architecture.? i plan on using orm: openaccess or nhibernate you use openaccess orm quick start scenarios section , product samples kit , contains end-to-end integration samples different technologies. should have more specific questions, contact product's support team , can guide through process.

c# - ASP.Net Webproject - Textfiles java like with velocity -

i absolutely new asp.net developmentent , have been working through tutorials since now. one thing missing java way externalize text files, can contain variables. in java using velocity such purpose. i need user specific email. in java load a text file this: hello mr. $name, registration. customer id is: $customerid .... now i able load text file via velocity , replace given variables easyly. is there way in asp.net? if not, proper way this? you define email template in mvc view, render view string, using model provide replacements. see 'razor .cshtml style' part of answer this post technical details of rendering view string.

iphone - Parse JSON link in Objective C -

i`m building app ipad. can give me advice on how parse json link in objective c, can image (media_655fa.png) "item_media"? example code: { "id":"6", "item_type":"page", item_name":"intro_page", "item_media":"http:\/\/demo.test.biz\/test\/var\/uploads\/default_item\/media_655fa.png", "item_text":"" } or, if has advice on how it. problem in link php sends json_encode() . how can in objective c json_decode or regexp in php? you can parse json : // ***************** fetching data ******************* // nsurl *url = [nsurl urlwithstring:[nsstring stringwithformat:@"%@",siteapiurl]]; nsdata *data= [nsdata datawithcontentsofurl:url]; if (data == nil) { return; } nserror* error; nsmutabledictionary *jsonis = [nsjsonserialization jsonobjectwithdata:data options:kniloptions

fgets - Get the whole input of a string in C -

#include char option[64],line[256]; main() { printf(">>") (fgets(line, sizeof(line), stdin)) { if (1 == sscanf(line, "%s", option)) { } } print(option) } will first word, example />>hello world would output />>hello #include <stdio.h> int main(){ char option[64],line[256]; printf(">>"); if(fgets(line, sizeof(line), stdin)) { if (1 == sscanf(line, "%[^\n]%*c", option)) {//[^\n] isn't newline chars printf("%s\n", option); } } return 0; }

c++ - Echo server/client message cutoff using socket send()/recv()(winsock) -

the code echo_server , echo_client posted below. noticed when type message on length in echo_client, server truncates end of , echoes part of it. buffer size 1024 bytes , message i'm typing much, shorter length. what's going on here? how solve problem server echoes complete message provided under length limit? the server code: #include "stdafx.h" #include <iostream> #include <string> #include <string.h> #ifndef unicode #define unicode #endif #define win32_lean_and_mean #include <winsock2.h> #include <ws2tcpip.h> #pragma comment(lib, "ws2_32.lib") using namespace std; static int maxpending = 5; int main(int argc, char *argv[]) { wsadata wsadata; int iresult; int optv = 0; bool connected = false; char *optval = (char*)&optv; int optlen = sizeof(optval); string q = "quit"; const char *exit =q.c_str(); iresult = wsastartup(makeword(2, 2), &wsadata); if (iresult != no_error) { wprintf(l&quo

Objective-C HTML parsing. Get all text between tags -

i using hpple try , grab torrent description thepiratebay. currently, i'm using code: nsstring *path = @"//div[@id='content']/div[@id='main-content']/div/div[@id='detailsouterframe']/div[@id='detailsframe']/div[@id='details']/div[@class='nfo']/pre/node()"; nsarray *nodes = [parser searchwithxpathquery:path]; (tfhppleelement * element in nodes) { nsstring *postid = [element content]; if (postid) { [texts appendstring:postid]; } } this returns plain text, , not of url's screenshots. there anyway links , other tags, not plain text? piratebay fomratted so: <pre> <a href="http://img689.imageshack.us/img689/8292/itskindofafunnystory201.jpg" rel="nofollow"> http://img689.imageshack.us/img689/8292/itskindofafunnystory201.jpg</a> more texts file </pre> that's easy job , did correctly! what want content (or attribute) of a -tag, need

jquery - Declaring a script from a PartialView only once -

i have razor partialview works metro-ui-style tiles. it's simple partialview allows me display tiles bound viewmodel , nothing spectacular. since it's not used in pages, don't want include jquery block on every page load. instead prefer script declared inline partialview, registered once in pagecode. the view following (i have reenginered metrofy template) @model ienumerable<metrostyletile> <div class="container tiles_hub"> <div class="sixteen columns alpha"> @foreach (metrostyletile tile in model) { <div class="tile_item 4 columns alpha"> <a href="@url.action(tile.action, tile.controller, routevalues: tile.mvcarea != null ? new { area = tile.mvcarea } : null)" class="tile"> @html.label(tile.description) @if (tile.imageurl != null) { @html.image(tile.ima

actionscript 3 - how to perform event on flex line -

how perform event on flex line objects.so can able move or re-size line using mouse.i using flexline shown in below code:- spark.primitives.line; var st:stroke =new stroke(0x345654,1,1); var obj:line = new line(); obj.stroke =st; obj.xfrom =0; obj.yfrom=0; obj.xto = 500; obj.yto = 500; obj.addeventlistener =????? //how resize line using mouse?? please explain how addeventlistner on line or give other idea achieve this. it not possible. line not interactiveobject . you can add group , listen events, or draw line graphics on sprite , listen sprite events(this more lightweight). or may add graphic primitives line group , calculate code line appeared under group click.

jquery - Protection in my php form -

i'm html, css , not bad jquery php i'm total loss! form, best way add protection existing php code use on site. this page tutorial code http://jorenrapini.com/blog/css/jquery-validation-contact-form-with-modal-slide-in-transition this site removed link this php tutorial used form appreciate assistance adding proper protection. <?php //declare our variables $name = $_post['name']; $email = $_post['email']; $message = nl2br($_post['message']); //get todays date $todayis = date("l, f j, y, g:i a") ; //set title message $subject = "message website"; $body = "from $name, \n\n$message"; $headers = 'from: '.$email.'' . "\r\n" . 'reply-to: '.$email.'' . "\r\n" . 'content-type: text/html; charset=utf-8' . "\r\n" . 'x-mailer: php/' . phpversion(); //put email address here mail("youremail@domain.com", $subject, $body, $he

javascript - Error while redirecting callback to modal dialog window -

i have main search page find , enquire button. when click enquire button. open modaldialog window , allow user enter name , i'd , hit submit. transfer call servlet , query db. if response takes longer 30 sec. forward request modal page , resubmit form. when forward request modal window resubmit script error. script error occurs before form.submit. doing wrong in forwarding request. back. edited: file1.jsp: call file2.jsp on button click returnval= showmodaldialog ( "file2.jsp?name=jack" , "" , "dialogwidth:650px;dialogheight:400px" ); in file2.jsp: <form name="refresh" action="<%=contextpath%>/someservlet" id="refreshing" method="post" target="result"> i have name field here button submit set hidden param request_old ='n' </form> on submitting button: in somservlet.java i parameter call threadpool executor if request_old ='n' execute tpe else

php - How can i prevent SQL injection when using MySQLi? -

this question has answer here: how can prevent sql injection in php? 28 answers how prevent sql injections in sql query this? <?php $mysqli = new mysqli("ip", "username", "pass", "database"); /* check connection */ if (mysqli_connect_errno()) { printf("sorry, login server 'under maintainance'"); exit(); } $username = $_post["username1"]; $username = strtolower($username); $password = $_post['password1']; $hash = sha1(strtolower($username) . $password); $query = "select * accounts name='$username'"; if ($result = $mysqli->query($query)) { /* determine number of rows result set */ $rownum = $result->num_rows; if($rownum != 0) { while ($row = $result->fetch_assoc()) { { $acct = $row['acct']; $pass = $row['pass']; } if($ha

smoothley animate a span to fit its text with jquery -

i have created hangman game each letter in span. html <span class="letter">a</span> css .letter{ height:40px; width:40px; line-height:40px; text-align:center; } after puzzle solved want move letters beside each other form word, need resize span fit text (that 1 letter) avoid spaces. removing class contains height , width results need problem want smoothly. clone element, set clone width auto , measure width. remove it, , animate original width. something this: $('span.letter').each(function(){ var temp = $(this).clone(); $('body').append(temp); temp.css('width', 'auto'); var newwidth = temp.width(); temp.remove(); $(this).animate('width', newwidth); });

c# - Application crashing when adding item to listbox -

when try add listbox, application close. this have far. line causing close is: listbox1.items.add(term1) using system; using system.io; using system.collections; using system.collections.generic; using system.linq; using system.net; using system.windows; using system.windows.controls; using system.windows.documents; using system.windows.input; using system.windows.media; using system.windows.media.animation; using system.windows.shapes; using microsoft.phone.controls; namespace phoneapp1 { public partial class mainpage : phoneapplicationpage { // constructor public class item { public string itemline1 { get; set; } public string itemline2 { get; set; } } public mainpage() { initializecomponent(); list<item> list = new list<item>(); item item = new item(); item.itemline1 = "item11"; item.itemline2 = "item12"; list.add(item); item = new item(); it

sql - SSRS Visual Studio 2008 - How to compare name to pipe delimited list of names? -

i new sql. trying count of activities done specified people in persons table. pseudo sql query: select count activities table left outer join persons table p p.lastname + ', ' + p.firstname 'lastname1, firstname1 | lastname2, firstname2 |..." what way compare names in persons table pipe delimited list of names passed parameter in ssrs report? probably looking this: total of activities persons of interest select count(*) activities_count activites left join persons p on a.person_id = p.id 'lee, mark | doe, jhon' '%' + p.lastname + ', ' + p.firstname + '%' number of activities per person select p.id, count(*) activities_count activites left join persons p on a.person_id = p.id 'lee, mark | doe, jhon' '%' + p.lastname + ', ' + p.firstname + '%' group p.id here sqlfiddle

objective c - Theos/Logos Debug Logging -

i use theos lot in creating jailbreak tweaks , debug have been using built-in %log , , following messages through mac terminal sshing iphone , watch ing output using socat - unix-connect:/var/run/lockdown/syslog.sock >watch . now, when using type of logging, every single update made syslog itself, lot of information don't need(want) see. want see pertains logging. my question: there way debug tweak connecting through socat custom log? updates being logged? you can use "socat - unix-connect:/var/run/lockdown/syslog.sock | grep yourapp" parsing

html - Add/Remove an input field using javascript -

i working on alert button gets generated depending on select drop-down. javascript has been able read , send values of <select> drop-down want to. but, when comes displaying button triggers alert message, problem. issues -- not sure if removing child correctly (syntax issue) -- can't seem button display. instead, performs onclick command. javascript function displayinfo(key) { alert(key); } function determinedisplay(item, buttonlocation) { // selected value drop down var si = item.selectedindex; var sv = item.options[si].value; // create view button display info var vb = document.createelement("input"); // assign attributes button vb.setattribute("type", "button"); vb.setattribute("value", "view"); vb.setattribute("display", "inline-block"); vb.onclick = displayinfo(sv); // insert button var inserthere = document.getelementsbyid(buttonl

Adding a timer to my Lua program -

i'm new lua , i'm coding program. program letter going around , collecting other letters (kinda worm program). however, want timed. (i'm on computercraft mod minecraft still uses lua, don't think matters) i'm using os.pullevent( "key" ) can move letter, os.pullevent() pause program until it's satisfied. problem want timer ticking @ same time. ideas how this? thanks! term.clear() w = 1 h = 1 score = 0 function topline() term.settextcolor(colors.orange) term.setcursorpos(5,1) print("score: ", score) end function randloc() w,h = math.random(2,50) , math.random(3,17) term.setcursorpos(w,h) term.settextcolor(colors.red) print"o" end function drawborder() term.settextcolor(colors.blue) term.setcursorpos(1,2) print"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" print"x x" print"x x

ios - UITableView prepareForSegue not pushing to UIWebView -

Image
i'm trying push weblistviewcontroller webpageviewcontroller , when cell pressed push uiwebview show web article associated it. can't working- weblistviewcontroller.m #import "weblistviewcontroller.h" #import "feed.h" @interface weblistviewcontroller () @property (strong, nonatomic) nsarray *headlinesarray; @end @implementation weblistviewcontroller @synthesize tableview = _tableview; @synthesize headlinesarray; - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"standardcell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; feed *feedlocal = [headlinesarray objectatindex:indexpath.row]; nsstring *headlinetext = [nsstring stringwithformat:@"%@", feedlocal.headline]; cell.textlabel.text = headlinetext; return cell; } - (void)prepareforsegue:(uistoryboardsegue *)segue sender

javascript - How to access scope from compiler function directive? -

i have directive building html based on array sent attribute. can't access compiler function of directive. works inside link function, need in inside compile, otherwise new template doesn't compiled. code this: <multirangeslider values="ranges" variances="['master', 'master a', 'master b']"></multirangeslider> directive: angular.module("vtapp.directives"). directive('multirangeslider', function ($parse, $timeout, $compile) { return { restrict: 'e', replace: true, scope: { values: "=", options: "=", variances: "&" }, compile: function (element, attrs) { var htmltext, variances, values; variances = eval(attrs.variances); values = scope.ranges //scope undefined values = eval (attrs.variances) //returns string "ranges"

ipad - AIR for iOS app crashes on launch - only on i Pad1 -

been working on ipad book app in flashbuilder 4.6. on there performance issues ipad1/3 until learning gpu rendermode , setting stagequality low. these helped immensely. however, app starting crashing on startup - on ipad1. example page 1 of app had worked weeks ago crash. after more research, seemed static references page classes put in viewcontroller issue. seemed overwhelming memory. when put static reference page1 in vc worked. , in page 1 static references page 2 or 3. or whatever pages might link to. now, after reworking 70 other pages static reference pages need, crashing again. my question this, if have page 1 static reference page 2 , 3. , each of have references...all down line page 70, in essence getting loaded memory @ startup? the bigger question how best manage memory of air app have ~ 120+ "pages" or views in mvc parlance? ideally, want dynamically created view in memory don't think it's working. i've read other posts here , thinking load

shell - Go into sudo user, run couple of commands, go back to normal user in Python script -

the problem i've run want temporarily sudo user, run couple of commands, , go normal user , run commands in mode. you can find script i'm gonna use in here: https://github.com/greduan/dotfiles/blob/master/scripts/symlinks.py basically, when i'm installing scripts under /bin folder of dotfiles need sudo access in order make symlink folder. can find part of script under last statement in code. however, since depend on commands use current user guideline stuff, can't run entire script sudo . last time tried got lot of errors folder not existing. thanks can provide. if don't mind installing external dependency, sh module makes pretty simple: import sh sh.cp('foo.txt', 'bar.txt') sh.sudo: sh.cp('foo2.txt', 'bar2.txt')

java - Usability features for JComboBox within JTable -

i'm trying build table includes jcomboboxes both renderer , editor components. works fine, there 2 things can't seem solve. tabbing between cells should make jcombobox active clicking drop-down arrow should open option list regarding 1, editable combo should place focus within embedded text field, fixed combo should allow down arrow open list of options. regarding 2, find works depending on other cell active, other times have double click. cannot make behaviour consistent. for convenience have included clear example (i believe) uses recommended approach embedding jcomboboxes within jtables. thank constructive advice. import java.awt.component; import java.util.*; import javax.swing.*; import javax.swing.table.*; public class tablecombos { public static void main(string[] args) { jframe frame = new jframe("frame"); frame.setdefaultcloseoperation(windowconstants.exit_on_close); abstracttablemodel model = new defaultta