Posts

Showing posts from February, 2014

Query to Update exisiting XML node in SQL Server -

how replace node in xml column new value. table : create table erversion ( erversionid int, change xml ) insert erversion values (123,'<changes><change property="custodian"><before>group ab</before><after>group ax</after></change></changes>') go insert erversion values (124,'<changes><change property="custodian"><before>group ax</before><after>group ab</after></change></changes>') go select * erversion i need update values in xml column "change" new values eg: "group ab" "group1" "group ax" "group2"... this duplicate, please check existing answers searching. you can find related question , answer here: update xml stored in xml column in sql server succinctly: update [tablename] set [xmlcolumn].modify('replace value of (/myxmldoc/@xmlproperty)[

Get sum of foreign key attribute using django -

class sales_line(models.model): sales_id = models.charfield(max_length=200) item = models.charfield(max_length=200) qty = models.integerfield() def __unicode__(self): return self.sales_id class loss(models.models): sale_id = models.foreignkey(sales_line) how can know how quantity lost if sales_id in loss table , sale lost you need use sum aggregates : from django.db.models import sum lost_sales_id = loss.objects.all().values_list('sale_id__sales_id', flat=true) total = sales_line.objects.filter(sales_id__in=lost_sales_id).annotate(sum('qty')) you need optimize models: class salesline(models.model): sales_id = models.charfield(max_length=200) item = models.charfield(max_length=200) qty = models.integerfield() def __unicode__(self): return unicode(self.sales_id) class loss(models.model): sale = models.foreignkey(salesline) now can this: lost_sales_id = loss.objects.all().values_list(&

html - meta tags do not work on indes -

this question has answer here: meta description/tag not working 1 answer all sites work fine, exept index page. meta not work, non of shows in google neither title of page. i not understand issue.. <!doctype html> <head> <!-- meta --> <title>open minded life path - how change life</title> <meta name="description" content="a collection of positve thinking , how change life-guides. best life changing solutions , tested self motivation techniques. "> <meta name="keywords" content="positive thinking, how change life, how change, how start new life, how change yourself, life changing solutions, unclutter, free thinking, life changes, positive approach, lifestyle, positive thinking, self motivation techniques, life coach"> <meta name="robots" content=

string - R: append a "character" type to a list of numeric values -

i have list of numeric values, say > list <- c(1,10,12,24) > list [1] 1 10 12 24 and want append string of characters output reads: > list [1] "name" 1 10 12 24 i tried following code: list <- c("name",1,10,12,24) or list <- c(1,10,12,24) list <- c("name",as.numeric(list)) but, predictably, numerics converted character type: > list <- c(1,10,12,24) > list <- c("name",as.numeric(list)) > list [1] "name" "1" "10" "12" "24" how can preserve numeric type while adding character type in front? [edit] goal add row existing data frame df df[1] contains strings , df[2:5] contain numerics. @fernando pretty has idea right: "row" should list if want combine data.frame . here couple of examples: ## sample `data.frame` mydf <- data.frame(a = c("one", "two"), b = 1:2, c = 3:4,

Make input text disabled/readonly in IE9 and below using javascript/jQuery -

anyone have idea how this? i have tried javascript below didn't work. element.readonly="true"; element.readonly="readonly"; element.disabled="disabled"; tried below jquery has not worked either. $("#id").attr("disabled","disabled"); $("#id").attr("disabled",true); $("#id").attr("readonly",true); $("#id").attr("readonly","readonly"); am doing wrong or there way achieve ie9 , below? thanks if setting attribute value on element, need use string equal attribute setting. example, if setting disabled attribute, should set equal "disabled" . html <input type="text" disabled="disabled" /> javascript $("#id").attr("disabled", "disabled"); if setting property value, need use boolean value: true or false . properties set in javascript: javascript element.dis

javascript - Cascading ComboBox drops model binding after setting initial value empty -

my scenario: cascading dropdowns ending combobox (partial view) used in master->details scenario kendo grid ddl->ddl->ddl->cb goal: on page load dropdownlists being initialized data 1 one default value, , combobox should stay empty on grid selecteditemchanged partial view being filled data , combobox should display appropriate element. in case works follows: on page load combobox displays '0' (null suppose?) on selection change blinks selected value model.id , shows appropriate text or if clear text/value propery of kendocombobox when parent dropdownlist data loaded: on page load combobox empty on selection change blinks above stays empty if change combobox control 4th dropdownlist still "blinks" in works fine. selected item model preserved correctly in dropdown. i cannot provide complete example because it's heavy don't think it's necessary. this how lists data cascading. on parent's databound event

javascript - jQuery draw a border in real time -

does know of plugins can use gradually draw border around element in real time? example, give impression drawing border around element opposed appearing @ once. you apply top border, right border, bottom border, left border incrementally 250 ms delay or whatever you'd like.

extjs - Controller doesn't seem to be running -

Image
nothing in controller seems working. so, have checked the network tab of google chrome web developpement , have noticed controller file isn't running. have ctrl find name of controller , can't find it. here's print sceen of it. here main app file app.js ext.application({ name: 'uniselect', requires: ['ext.messagebox',], controller: ['controleur'], views: ['main','listeclient'], model: ['listeclient'], store: ['listeclient'], icon: { '57': 'resources/icons/icon.png', '72': 'resources/icons/icon~ipad.png', '114': 'resources/icons/icon@2x.png', '144': 'resources/icons/icon~ipad@2x.png' }, isiconprecomposed: true, startupimage: { '320x460': 'resources/startup/320x460.jpg', '640x920': 'resources/startup/640x920.png', '768x1004': 'resources/startup/768x1004.png',

Phonegap Java call Javascript Function -

i making hello world type phonegap application android, in call javascript function native android code set text of 1 of paragraphs in app. i have javascript function define in app's html, , want call activity once app loads up. function sets text of paragraph in app. cannot work. here java activity code: public class myphonegapactivity extends droidgap { public droidgap c; public loadinfo info; @suppresslint("setjavascriptenabled") @javascriptinterface @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); super.init(); c = this; appview.getsettings().setjavascriptenabled(true); appview.getsettings().setjavascriptcanopenwindowsautomatically(true); appview.loadurl("file:///android_asset/www/index.html"); appview.setwebviewclient(new webviewclient() { public void onpagefinished(webview view, string url) {

android - Parameters to uiAutomator test class -

i new uiautomator. tried passing parameters method, run ignores passed it. wondering whether can pass arguments test class or test method in uiautomator? reference you can send in parameters via command line: adb shell insrument -e <name> <value> <package/runner> you can access value using bundle available if override oncreatemethod of instrumentationtestrunner. public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); value = (string) savedinstancestate.get("name"); }

android - how to do a login greeting (toast) and don't have to type again when user log in -

i make userlogin details, using shared preferences. when load application login page appear. after i've typed in , toast greeting user, such welcome [username]. when user login again, toast message welcome [username]. user not have type his/her name again go in application. in fact, when user click login, toast welcome [username], , he/she can continue application. however, in code, skip login page , , didn't toast name. did log.d nothing appear in logcat. can please me out? i think there's not right retrieve preference, not sure how can edit it, i'm new android. here code: protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.login); username =(edittext)findviewbyid(r.id.nameedittext); loginbutton = (button)findviewbyid(r.id.loginbtn); loginbutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) {

java - JavaMail - Stop automatically sending read receipts -

i'm developing mail client (imap/smtp) javamail . client talk exchange 2010 server automatically sends read receipts when set flag seen in messages require them. how can avoid server send these receipts? tried remove disposition-notification-to header messages following exception: javax.mail.illegalwriteexception: "imapmessage read-only" even if open folder in read_write mode. read problem due imap protocol limitation. there way not send read receipts? you can't in client. client doesn't it, , imap offers no way configure exchange. (also, imap offers no way modify messages. once stored, message can cached forever client , not modified other client.)

android - R not generated, XML file contains error but which XML file? -

Image
my r file not generated after clean project. , according research on stack overflow, think have error in xml file dont know xml contains bug. went through of them including androidmanifest file. is there way or tool me find out xml contains error? have been stuck problem 10 hours. please help! p.s have 2 different custom view both have same namespace (but uses in separate xml file), problem? androidmanifest file <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.packagename.appname" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="15" android:targetsdkversion="15" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@android:style/theme.holo.noactionbar.full

qt - Conversion from QString to hex -

i have same code in 2 different projects. qstring::number(data.tolong(&ok,2),16) works in 1 project , in other project not work. know reason be? code follows 1) unsigned short status; 2) long int setting; 3) bool ok; 4) qstring data_selected; 5) data_selected = lineedit_data->text(); //get binary value 6) data_selected = qstring::number(data_selected.tolong(&ok, 2), 16); //convert binary value hex value 7) setting = data_selected.tolong(&ok, 16); //convert string integer in line 5 getting data lineedit. line works fine. inserted new text edit box , displayed data there , there can see data. have data "1000000000001000". execute line 6, output of '8008' in first case , '0' in other project. problem. code same. have copied , pasted. in debugging can see difference. please can tell me why happening? i thought comment under answer clear. correct code detect problem: ulong setting; bool ok; data_selected = data_selected.trimm

Segmentation faults when running rails on ruby 1.9.3 -

running pretty sizable rails app, we've gotten around upgrading rails 3. our stack ruby-1.9.3p484, rails 3.2.16 , passenger 4.0.23 running on top of apache. after throwing traffic @ couple of our machines, started noticing few strange errors coming down. things random methods not being defined on objects have them, instance variables being nil inside ar associations, , objects being randomly replaced 'false'. around strange behavior. inspecting apache's logs gave bit of info, namely these errors coming in, more not, respective processes keel on well, on random bits of app. sometimes ruby node getting passed in null, other times random string overflowing, random stuff getting mangled about. none of happened during testing, 'reliable' way of reproducing far has been throw traffic @ respective machines , see when / if start exhibiting behavior. having gone through of this, here's list of things we've ruled out now: passenger's oob g

javascript - snap svg animate to original size and position -

when user hover baloon svg, want animate baloon svg (make bigger). , when user unhover baloon, baloon return original size. use reset original size , position. transform: 's1' it work in chrome, firefox, safari. but when tried on ie, expand animation work, reset animation doesn't work, blinked original size without animation. $balooncolumn.on('mouseenter', function() { animateexpandbaloon(); }); $balooncolumn.on('mouseleave', function() { animatenormalbaloon(); }); var animateexpandbaloon = function() { baloonshout.animate({ transform: 's1.1t5,10' }, 1000, mina.elastic); baloon.animate({ transform: 's1.05t' }, 1200, mina.elastic); baloonrighteye.animate({ transform: 's1t3,-2' }, 1200, mina.elastic); baloonlefteye.animate({ transform: 's1t3,-2' }, 1200, mina.elastic); baloontail.animate({ transform: 's1t15,0' },

parameters - Do PDFs sizes change depending on the program that opens it? -

i work company designing t-shirts. transfers printed company. transfers received recent design small, i'm guessing printed portrait instead of landscape. representative company order prints claiming isn't fault , that... "sometimes images receive not size send. due different formats of files , way our computers convert them." he says it's our fault because didn't send design dimensions him along design. file sent pdf. correct in understanding pdf open @ it's intended size? thought size embedded within pdf. i'm i'm correct, don't want call him out without knowing i'm correct. computers convert pdfs they're different size? terrible way pdfs operate, if that's case. the size embedded in pdf, , purpose of pdf format used final document format before printing. advice send note desired dimensions, perhaps it's machine resizes picture.

detect - Detecting Adobe Reader in ie11 with JavaScript -

i trying detect adobe reader plugin ie11, reason returns null. lead believe because ie11 doesn't use same plugin name older versions of internet explorer, not sure. i got code directly site (a user website!): http://thecodeabode.blogspot.com/2011/01/detect-adobe-reader-plugin.html the code works brilliantly until ie11 on windows 7, returns null in getacrobatversion. here full code it's easier all: var getacrobatinfo = function() { var getbrowsername = function() { return this.name = this.name || function() { var useragent = navigator ? navigator.useragent.tolowercase() : "other"; if(useragent.indexof("chrome") > -1) return "chrome"; else if(useragent.indexof("safari") > -1) return "safari"; else if(useragent.indexof("msie") > -1) return "ie"; else if(useragent.indexof("firefox") > -1) return "

html - Can I apply CSS styles to part of document -

for example, have frontend , backend sites uses different templates , styles. there workflow - manager edits page text wysiwyg editor , saves , wants see result. it user friendly when stay in backend , able see edited text inline on page, in backend content div, frontend styles. let's assume, need see text formatting styles, , have separate css file styles. my solutions: 1)create page custom layout (only content div) , show in backend iframe. 2) process css file , prepend backend div class name selector every rule in css. print style tag processed css. is there more elegant solution issue? @begin_style @end_style? thanks!

sql - Why SQL_PROFILE not showing recommendations? -

i trying run sql tuning advisor sqlplus. following below steps create to create tuning task using sql_id: declare l_sql_tune_task_id varchar2(100); begin l_sql_tune_task_id := dbms_sqltune.create_tuning_task ( sql_id => '19v5guvsgcd1v', scope => dbms_sqltune.scope_comprehensive, time_limit => 60, task_name => '19v5guvsgcd1v_tuning_task', description => 'tuning task statement 19v5guvsgcd1v.'); dbms_output.put_line('l_sql_tune_task_id: ' || l_sql_tune_task_id); end; / to execute tuning: exec dbms_sqltune.execute_tuning_task(task_name => '19v5guvsgcd1v_tuning_task'); to check report: set pagesize 10000 set linesize 20000 select dbms_sqltune.report_tuning_task('19v5guvsgcd1v_tuning_task') recommendations dual; set pagesize 24 when run create tuning task block

Xcode: Thread 1 Signal SIGABRT -

i new xcode , language , trying make simple calculator , after adding more view error "thread 1 signal sigabrt" , app wont open in ios simulator. error points line of code: return uiapplicationmain(argc, argv, nil, nsstringfromclass([appdelegate class])); i tried searching before didn't understand other answers talking about. http://i.imgur.com/merys26.png here screenshot of comes when attempt run program that mean´s call method or other stuff not exists. ray wenderlich has tutorial. can post message console?

Site give different response when request sent by jQuery jPlayer -

i trying use jquery jplayer (downloaded 2.5.0 demo, using circle player) play remote link http://data10.5sing.com/t1t5vtb4et1r47ivrk.mp3 , link can played in browser, or using wget download, in these cases server responded 200 ok. if play using following code, server responded 403 forbidden, why that? <!doctype html> <html> <head> <meta charset=utf-8 /> <!-- website design by: www.happyworm.com --> <title>demo : jplayer circle player</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="/static/skin/circle.skin/circle.player.css"> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript" src="/static/js/jquery.jplayer.min.js"></script> <script type=&q

How do I give global access to an object in Scala without making it a singleton or passing it to everything? -

i have logger class logs events in application. while need 1 instance of logger in application, want class reusable, don't want make singleton , couple specific needs application. i want able access logger instance anywhere in application without having create new 1 every time or pass around every class might need log something. have applicationutils singleton use point of access application's logger: object applicationutils { lazy val log : logger = new logger() } then have loggable trait add classes need logger: trait loggable { protected[this] lazy val log = applicationutils.log } is valid approach trying accomplish? feels little hack-y. there better approach using? i'm pretty new scala. be careful when putting functionality in object s. functionality testable, if need test clients of code make sure interact correctly (via mocks , spies), you're stuck 'cause objects compile final classes , cannot mocked. instead, use pattern: tr

jquery - Extract a number from a string? (Javascript) -

var amount = "(21)"; how go getting number? have gotten work with... var amountresult = amount.substring(1, amount.length-1); ...but feels incorrect. what's better, more flexible way if not surrounded 2 characters? thanks! using regular expression more flexible: var amountresult = amount.match(/\d+/)[0]; and turn number: var amountresult = parseint(amount.match(/\d+/)[0], 10);

windows - Need a batch file to move files -

i looking small, free program can use move files 1 folder another. i've done little research , think batch files might best bet. unfortunately, i've never used batch files before , have absolute basic programming skills (took computer science course on java in college). this looking for: i have multiple folders within 1 specific folder (.....\phase_2_document_prep) have lots , lots of pdf files within, on 25,000. i have master excel spreadsheet contains file name of each pdf document , folder supposed in. of now, current files mixed different folders. can create pipe delimited text file has file name , folder. i need program import txt file containing file name , target folder, search through current 1 specific folder , sub folders find file name (pdf) , move each file target folder. ============== update ======================= code i'm working keep getting ...\files unexpected @ time error , nothing copying. code: set filelist=c:\users\mcuomo\documents\t

php - How can I determine if the same user is registering again in my application? -

this question has answer here: prevent users starting multiple accounts? 10 answers so, here need do. have web application have developed laravel 4, people register gain access to. use email username. here catch though. award our users points using website, have daily cap of points, , if user goes on daily limit, capped , can't receive points no more. problem that, don't want same user register multiple times multiple email addresses , avoid cap in way. i've thought of using cookies this, cookies can deleted. i've thought of using ip address, ip addresses change, , different users can have same ip address. so, looking more fool proof solution. ideas appreciated. thanks! this related stack overflow question has lot of ideas, technical rundown of various issues using unique emails, versus cookies/ip addresses this. there brief discussion

sum - Summing Vector elements until a Positive element is encountered - R -

i'm new r , i'm looking through book called "discovering statistics using r". although book implies don't need statistical background, of content isn't covered/explained... i'm trying sum elements of vector starting position 1 until positive element present. i found this question similar i'm trying achieve. when implement it, doesn't seem work (and appears include first positive element)... my program is: veca <- runif(10, -10, 10); suma <-sum(veca [1:min(which(veca < 0))]); is there more robust way calculate without using loops works every time , doesn't add positive element? i'm not @ looping stage of books yet. i found this site asks similar question answer errors: sum(veca [seq_len(which.max(veca > 0)]); you want use > not < sum elements until first positive 1 reached. you're summing 1 until first negative value reached (including first negative value). sum(veca[1:min(which(ve

mysql - Query with WHERE / sub query containing multiple records -

this query: select * img_ref id_img = (select `id_img` img_ref `id_user`=4) i'm trying select records img_ref id_img = id_img attached specific id_user. however, subquery contains multiple rows/results , therefore throws error "subquery returns more 1 row". how modify statement "where id_img=" part , subquery allow multiple rows? thanks in advance. when using subquery equals, subquery can return single record. use in return multiple records: select * img_ref id_img in (select `id_img` img_ref `id_user`=4) for performance reasons (check post ), may want move join : select i.* img_ref join img_ref i2 on i.id_img = i2.id_img , i2.id_user=4 sql fiddle demo

css - Single gradient to multiple images -

i result: image the images cropped in png without background , and black color, gradient in separate images possible css ? you're going need place images inside of div , style div 's background desired gradient. example: html <div id="gradient"> <img src="..." /><img src="..." /><img src="..." /> </div> css #gradient { width: 300px; //whatever total width of images height: 61px; //whatever height of images ... //gradient css goes here } here fiddle showing in action: http://jsfiddle.net/2ahhu/

java - SELECT DISTINCT on 2 or More JOIN -

i'm trying execute query 2 joins in hiveql have error hive> select distinct ft.status_id > fact_tweet ft > join place_dimension dp on (ft.hotspot_id = dp.hotspot_id , dp.type='park') > join dimension_status ds on (ft.status_id = ds.id , array_contains(ds.hashtags,'bebop')); failed: nullpointerexception null ? this hive server/metastore error. other queries running ok? please, check logs errors , paste them her

C++: Understanding Header Files & Header Guards with Easy Addition Example -

i can't head around headers , header guards. i've read other questions , answers still can't make work in visual studio 2013: main.cpp #include "stdafx.h" #include <iostream> #include "add.h" int _tmain(int argc, _tchar* argv[]) { std::cout << "3 + 4 = " << add(3, 4) << std::endl; system("pause"); return 0; } add.cpp #include "stdafx.h" //added later; working (and see question 2 below) #include "add.h" //added later; nor working (and see question 2 below) int add(int x, int y) { return x + y; } add.h #ifndef add_h #define add_h int add(int x, int y); #endif when compile, console window flashes on-screen disappears. error list contains: error 1 error lnk2019: unresolved external symbol "int __cdecl add(int,int)" (?add@@yahhh@z) referenced in function _wmain c:\users\danny\documents\visual studio 2013\projects\addition program\main\mai

python - How to remove one of the two duplicate blocks in a file? -

i have difficult problem. know there many 're' masters in python out there. please me. have huge log file. format this: [text hello world yadda lines lines lines exceptions] [something i'm not interested in] [text hello world yadda lines lines lines exceptions] and on... block 1 , 3 same. , there multiple cases this. ques how can read file , write in output file unique blocks? if there's duplicate, should written once. , there multiple blocks in between 2 duplicate blocks. i'm pattern matching , code of now. matches pattern doesn't duplicates. import re import sys itertools import islice try: if len(sys.argv) != 3: sys.exit("you should enter 3 parameters.") elif sys.argv[1] == sys.argv[2]: sys.exit("the 2 file names cannot same.") else: file = open(sys.argv[1], "r") file1 = open(sys.argv[2],"w") java_regex = re.compile(r'

batch file - Running a command in all folders under a parent subdirectory -

i have case have n number of sub folders under parent folder x. folder names not in order. i have requirement have go each of these subfolders , perform specific task or run command (for example create text file called new.txt). how can this? put script bellow in bat file , place in root directory tree. run it. create file new.txt in folders. can replace command or add others. %%a folder path. @echo off /f "tokens=*" %%a in ('dir /b /s /ad') ( rem command execute each folder type nul >"%%a\new.txt" )

GitHub: Add a fork reference to a repository -

i have own github repository want fork new name because it's 99% same code, have small changes separate functionality. details: eggers/dt-breeze typescript declaration file breeze using q.promise eggers/dt-breeze-angular typescript declaration file swaps out q.promise ng.ipromise i didn't see way fork own repository, created created separate repo, , pushed original code changes new repo, prefer have fork reference. i saw question: add github fork existing repository 2 years ago, hoping there update. the simplest solution remain branch within repo , mentioned musicmatze . fork doesn't exist one's own repo (and can't have 2 repos same name ): can clone, , add upstream remote fork ( see gist ), won't benefit pull request mechanism. the other solution create second github account, , use (truly) fork repos first account.

visual studio 2012 - Binding Windows Forms to Access Database, How to? -

i created windows form in c# , want bind combo boxes fields in database user can write predefined list of data db enter new value. have datasource , form set up, can't 2 work together. c# windows form set 3 comboboxes need bind these comboboxes 3 fields in access database user open form, enter data directly access table without having open access. thanks the following msdn page has information started: walkthrough: simple data access in windows form

java - Android -How can I open different list for single list row -

i have xml (i don't know if it's perfect): <?xml version="1.0" encoding="utf-8"?> <lista> <riga> <id>1</id> <title>fornace</title> <thumb_url>http://i43.tinypic.com/29lzjpv.jpg</thumb_url> <prova> <title>prova1 - fornace</title> </prova> </riga> <riga> <id>2</id> <title>basilica</title> <thumb_url>http://i40.tinypic.com/qs8ihe.jpg</thumb_url> <prova> <title>prova2</title> </prova> </riga> <riga> <id>3</id> <title>foro boario</title> <prova> <title>prova3</title> </prova> </riga> </lista> and want parse , open different lists single list row. how can do? mainactivity:

jquery - Binding Flexslider to outside div? -

i wondering if it's possible bind flexslider events outside divs? i'm looking way bind outside or change based on picture being viewed (a description precise.) is possible? thanks in advance. you can in way: html: <div id="slider" class="flexslider"> <ul class="slides"> <li> <img src="slide-1.jpg" /><!-- image/slide --> <span>description 1</span><!-- description --> </li> <li> <img src="slide-2.jpg" /><!-- image/slide --> <span>description 2</span><!-- description --> </li> </ul> </div> css: .slides { position: relative; } .slides li span { width: 500px; height: 40px; position: absolute; bottom: - 50px; } you can position slide li span (description) ever want. change positions of elemen

windows - Topshelf, NLog and File Permissions -

i have windows service application uses topshelf library , i'm installing in aws during cfn-init using handy command line features topshelf. c:\handy_service\> handyservice.exe install start this installs service in registry , calls sc start , it's quite useful because checks service name matches expect , allows configure user service run using nice fluent api. the installer code writes diagnostic logs nlog if service configured use nlog in general. the problem this: installer runs default local administrator account ami starts , nlog file gets created user. when service starts network service user, doesn't have permission write nlog log file. how can service write log file? i've thought setting permissions programmatically looks nasty , i'd have determine log file name generated dynamically based on ec2 instance id. also, it's not entirely obvious @ point log file first created. easiest hack might go having 2 nlog.configs , switching 1 out @ en

casting - warning: assignment makes integer from pointer without a cast. whats wrong? -

i got warning "warning: assignment makes integer pointer without cast"! want figure out mean? , need change in fucntion create_rectangle..... thank you. appreciated struct point { int x; int y; }; struct rectangle { struct point upperleft; struct point lowerright; char label[namesize + 1]; }; and code: struct rectangle *create_rectangle(struct point ul, struct point lr, char *label) { struct rectangle *r = malloc(sizeof(struct rectangle)); r->upperleft=ul; r->lowerright=lr; r->label[namesize+1]= strncpy(r->label,label,namesize); //here warning r->label[namesize] = '\0'; return r; } strncpy returns pointer assigning char. (actually, assigning illegal address r->label[namesize+1] beyond bounds of array.) it should struct rectangle *create_rectangle(struct point ul, struct point lr,

php - CodeIgniter not submitting form values to database -

setting "method" attribute of form fixed me, submitting database fine, now, have similar problem validating credentials maybe has same root problem since forgot method in first place, thank much. i have problem while attempting learn codeigniter , general mvc principles. i have sign form view <div class="container"> <form class="form-horizontal" style="width:500px;" action="sign_up"> <fieldset> <!-- form name --> <legend>sign up</legend> <!-- text input--> <div class="control-group"> <label class="control-label" for="username">username</label> <div class="controls"> <input id="username" name="username" placeholder="username" class="input-xlarge" required="" type="text"> <p class="help-block">your username</p> </div&g

Jinja variable scope or how can I access integer which have been incremented inside loop? -

i have following jinja template: {% set counter = 0 %} {% f in somearray %} {% set counter = counter + 123 %} {% endfor %} // here want print {{counter}}, 0. i looked @ answer can jinja variable's scope extend beyond in inner block? did not help. tried create array variable , access it {% set counter = 0 %} {% set sz = [0] %} {% f in somearray %} {% set counter = counter + 123 %} {% set sz[0] = counter %} <---- crash here {% endfor %} jinja documentation says nothing array access... please help. to use array counter need modify code (and hacks!) show way of doing want without extensions. ok, main problem in code when set variable on jinja statement keeps value in scope (is local variable definition on function in python) , since jinja doesn't provide strightforward way of setting outside variables created on template need hacks. magic works using list: import jinja2 env = jinja2.environment() print env.from_string(""" {%- set coun

xml - XSLT : Converting int to float / double value -

i have xml file. how can convert int value double or float or vice versa using xslt? example, assume following source document : <a> <b> 22 </b> <a> result document <a> <b> 22.0 </b> <a> you can use format-number() function. <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="b"> <b> <xsl:value-of select="format-number(., '#.0')" /> </b> </xsl:template> </xsl:stylesheet>

Endianness conversion cost on architectures -

today there 2 kinds of cpu architectrues, big endian , little endian. data needs converted between 2 representations. each cpu architecture, instruction set in particular, different , each allows different implementations changing endianness. cpus contain specific instructions while others not. my question this, today's architectures more efficient have data , convert on le architectures or other way around, in order minimize data conversion latency , maximize throughput in le communication. second question, can cost of conversion quantified, there data on matter? how costly conversion in java byte array? there data on specific jvms on specific architectures? different on dalvik? afaik relevant architectures x64, arm, mips , jvm/dalvik. missing any? data should in native endian except case copy value , send without processing. how can operations reversed endian (except bitwise operators)? network activities slower cpu, not compared ram. you'll hardly ever s

ruby - to_json give "nil is not a symbol", but object is not nil -

i'm receiving strange error here. generate random data , insert array, can see below: @all_stores = [] in 0..10 item = item.new( :name => generate_random_product(), :description => generate_random_product(), :url => generate_random_product(), :image_url => generate_random_product(), :type => "goods", :category => "electronics" ) @all_stores << item end write_to_file() after that, call method save array of items file, following: def write_to_file() items_to_json() end def items_to_json() file.open("public/data.json", "w") { |f| f.write(@all_stores.to_json)} puts "saved @ 'public/data.json'" end running that, receive following error: rake aborted! nil not symbol /home/paladini/.rvm/gems/ruby-2.0.0-p353@global/gems/activemodel-4.0.2/lib/active_model/serialization.rb:108:in `block in serializable_hash' /home/paladini/.rvm/gems/ruby-

Excel VBA - Loop needed for a column -

i'm new excel vba , can't figure out how work. have column (column k), header in k1. spreadsheet every day , has different number of rows. column k has numbers 0-100. need highlight rows colors depending on value in column k. have far, goes way down , makes every column red font. need loop through k2 last k cell value , change font color of each row. columns("k").select dim firstcell integer dim finalcell integer firstcell = range("k2") finalcell = range("k65536").end(xlup).row = firstcell finalcell if > 5 rows(i).select selection.font .color = rgb(255, 0, 0) end elseif = 4 rows(i).select selection.font .color = rgb(226, 107, 10) end elseif = 3 rows(i).select selection.font .color = rgb(0, 176, 80) end elseif = 2 rows(i).select selection.font .color = rgb(0, 112, 192) end elseif = 1 rows(i).select selection.font .color = rgb(112, 48, 160)