Tuesday, 15 January 2013

CkEditor Template Changes won't take effect -



CkEditor Template Changes won't take effect -

i downloaded ckeditor, unpacked, installed , stuff. working fine cannot alter templates in /plugins/templates/templates/default.js. deleted them, not working.

is how alter templates? (i desperate here)

please help!

try checking docs http://docs.ckeditor.com/#!/api/ckeditor.config-cfg-templates_files

config.templates = 'my_templates'; config.templates_files = [ '/editor_templates/site_default.js', 'http://www.example.com/user_templates.js ];

ckeditor

mysql - Login PHP it's not working -



mysql - Login PHP it's not working -

is code ok? seek create php login page it's not working...can help me? below source of php page. form written in extjs.

<?php $loginusername = isset($_post["loginusername"]) ? $_post["loginusername"] : ""; $loginpassword = isset($_post["loginpassword"]) ? $_post["loginpassword"] : ""; /*if($loginusername == "f"){ echo "{success: true}"; } else { echo "{success: false, errors: { reason: 'login failed. seek again.' }}"; }*/ //baza de datesession_start(); $conn = mysql_connect("localhost","root","pass"); mysql_select_db("hgr",$conn); $result = mysql_query("select * utilizatori username='" . $loginusername . "' , parola = '". $loginusername."'"); $row = mysql_fetch_array($result); if(is_array($row)) { echo "{success: true}"; $_session["userid"] = $row[id]; $_session["username"] = $row[username]; $_session["nume"] = $row[nume]; $_session["casa"] = $row[casa]; $_session["rol"] = $row[nivel_acces]; } else { echo "{success: false, errors: { reason: 'login failed. seek again.' }}"; } ?>

you have many errors in code :

$result = mysql_query("select * utilizatori username='" . $loginusername . "' , parola = '". $loginusername."'");

you check username , parola on same var. want :

$result = mysql_query("select * utilizatori username='" . $loginusername . "' , parola = '". $loginpassword."'");

you affecting vars without quotes :

$_session["userid"] = $row['id'];

check :

json_encode() send message in json instead of writing yourself mysqli_* or pdo cause you're using mysql_* deprecated mysql injections in query

php mysql session post

ios - How to limit character input in UIAlertView UITextField -



ios - How to limit character input in UIAlertView UITextField -

i trying limit number of characters user allowed input uitextfield within uialertview.

i've tried mutual answers on web. such shown below :

#define maxlength 10 - (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string { if ([textfield.text length] > maxlength) { textfield.text = [textfield.text substringtoindex:maxlength-1]; homecoming no; } homecoming yes; }

anyone able help?

.h file

@property (strong,nonatomic) uitextfield *alerttext; @interface locationsearchviewcontroller : uiviewcontroller<uitextfielddelegate>

.m file

- (ibaction)butpostalcode:(id)sender { uialertview *alrt=[[uialertview alloc]initwithtitle:@"" message:@"" delegate:self cancelbuttontitle:@"cancel" otherbuttontitles:@"ok", nil]; alrt.alertviewstyle = uialertviewstyleplaintextinput; [[alrt textfieldatindex:0] setplaceholder:@"enter postal code"]; alerttext = [alrt textfieldatindex:0]; alerttext.keyboardtype = uikeyboardtypenumberpad; alerttext.delegate=self; alrt.tag=100; [alrt show]; } -(bool) textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string { if(yourtextfieldname.text.length >= 10 && range.length == 0) { homecoming no; } homecoming yes; }

ios objective-c uitextfield uialertview

c# - Deserializing DataSet that contains 2d array with JSON.NET -



c# - Deserializing DataSet that contains 2d array with JSON.NET -

i trying deserialize below info dataset (i believe dataset right choice?). when data property has even number of columns, works alright, when have odd number of columns throws: additional text found in json string after finishing deserializing object.

request deserializing:

stream inputstream = controllercontext.httpcontext.request.inputstream; inputstream.position = 0; string json = new streamreader(inputstream).readtoend(); inputstream.close(); system.data.dataset dataset = null; dataset = jsonconvert.deserializeobject<system.data.dataset>(json);

mock data:

var valid = { "colheaders": [ { "text": "testheader1", "influence": 1, "weight": 20.5 }, { "text": "testheader2", "influence": 0, "weight": 30 } ], "rowheaders": [ { "text": "rowheader1" }, { "text": "rowheader2" } ], "data": [ ["data_00", "data_01"], ["data_10", "data_11"] ] } var not_valid = { "colheaders": [ { "text": "testheader1", "influence": 1, "weight": 20.5 } ], "rowheaders": [ { "text": "rowheader1" }, { "text": "rowheader2" } ], "data": [ ["data_00"], ["data_10"] ] }

c# serialization json.net

javascript - How to correctly set the footer? -



javascript - How to correctly set the footer? -

i tried many tutorials on web, tried javascripts nil worked footer. want stick bottom. if prepare in page content go below screen footer won't work in page have content within screen size. if fixe 1 other breaks. how can prepare this?

in page footer right : http://fast-garden-6871.herokuapp.com/logs

in page in midle of screen (you have scroll) : http://fast-garden-6871.herokuapp.com/delegates

please help!

add css code:

.wrapper { display: block; }

javascript html css footer sticky-footer

php - Laravel validate error -



php - Laravel validate error -

this error

symfony \ component \ debug \ exception \ fatalerrorexception phone call undefined method illuminate\validation\validator::make()

this code

$validator = validator::make($userdata,$rules); if( $validator->fails() ) { homecoming view::make('default::partials.user.getregistration')->witherrors($validator)->withinput(); }

what can be?

i believe have

use illuminate\validation\validator;

in file. (your ide thought beingness helpful.) utilize static :: call, validator should aliased illuminate\support\facades\validator. (the \app\config\app.php file default.)

chances changing utilize statement

use \validator;

will prepare things.

php laravel

Laravel Migration and seeding error -



Laravel Migration and seeding error -

i starting utilize laravel framework , command prompt. i'm having problem migration , seeding features, however.

i developing on wamp server on windows 7 64-bit os.

the database name 'laravel', next 2 tables:

migrations users

the users table contains next columns:

id name email username password

i used command line generate migration stored in app\database\migrations\2014_06_24_221654_test.php. created migration , batch fields in migration table.

i want seed email table, used databaseseeder.php in database\seeds folder.

<?php class databaseseeder extends seeder { public function run() { $this->call('usertableseeder'); $this->command->info('user table seeded!'); } } class usertableseeder extends seeder { protected $fillable = array('email'); public function run() { user::create(array('email' => 'jishadp369@gmail.com')); } } ?>

i used next command seed database

php artisan db:seed

however, got next exception:

[illuminate\database\queryexception] sqlstate[42s22]: column not found: 1054 unknown column 'updated_at' in 'field list' (sql: insert `users` (`email`, `updated_at`, `created_at`) values (ji shadp369@gmail.com, 2014-06-25 00:23:48, 2014-06-25 00:23:48))

how can solve this? need model?

thats because user model utilize timestamps fields.

check user model file.

you find $this->timestamps = true in constructor. alter false , seek again. if don't find this, add together attribute class:

public $timestamps = false;

i hope works fine you.

laravel

android - Trouble connecting to LG phone with adb (Mac OS X 10.7.5) -



android - Trouble connecting to LG phone with adb (Mac OS X 10.7.5) -

when run adb devices there no devices showing connected. device lg optimus exceed 2 running 4.4.2 there many of these posts around, here's i've done:

i'm using cord came phone. charges , tries sync photos, isn't issue here. switching usb ports , trying powered usb hub doesn't impact either. i've added vendor id (0x1004) ~/.android/adb_usb.ini restarted , unplugged combination of things can think of usb debugging on. , has been restarted. same unknown sources. i have never used easytether, nor installed anywhere on computer. updated adb, updated sdk. restarted adb server tried installing lg's drivers: http://www.lg.com/us/support-mobile/lg-vs450pp (they don't back upwards mac s/w upgrade, yet have bundle install. no help there) i have nexus s running 4.1 works, , old lg phone running gingerbread connect.

any wizards out there who've struggled have advice?

i tried of connection types (charge, mtp, ptp) perhaps not "internet connnection, modem"? can alter pulling downwards system-wide drop downwards menu , touching "usb connection".

this how fixed it, thought i'd tried already, can't guarantee wasn't in conjunction 1 of things done above.

android osx usb adb lg

compilation - function 'normrnd' in excutable compiled by matlab mcc doesn't work -



compilation - function 'normrnd' in excutable compiled by matlab mcc doesn't work -

i have file named myfunction.m, content is:

function []=myfunction() z = normrnd(0,1)

each time issue comman myfunction in matlab, random result.

then, compile myfunction.m using command:

mcc -m myfunction.m

and obtain excutable named myfunction.

and seek excute in matlab using command:

!myfunction

however results no longer random...instead fixed number, 0.5377..

this wired. why? os linux.

matlab compilation mcc

javascript - replace n with the variable while finding the nth child jquery -



javascript - replace n with the variable while finding the nth child jquery -

i have jquery expression

var splitindex = 9; var melems = $('#columns div:nth-child(n+9)');

here '9' hardcoded, how replace 9 splitindex. wanted dynamic values of n;

try this

$("#columns div:nth-child(n+"+splitindex+")");

javascript jquery

java - Spring and Spring MVC -- are they two different framework? -



java - Spring and Spring MVC -- are they two different framework? -

as trying larn framework j2ee, studying on spring framework.

the thing confused me in tutorial mention spring mvc part of spring framework. @ place mentioned different , independent framework. people compare spring mvc struts (which framework understand ).

now how should take spring mvc in mind different framework struts or part of spring?

spring has incredibly grown in lastly decade, nowadays single word spring means different things depending on context in used. in such context might used next spring projects.

one of these projects spring framework: open source application framework , inversion of command container java platform offers lots of features:

dependency injection aspect-oriented programming including spring's declarative transaction management spring mvc web application , restful web service framework foundational back upwards jdbc, jpa, jms much more...

each 1 of these features designed in spring framework's module grouped in layers, among others, can find:

in core layer the core , beans modules provide fundamental parts of framework, including ioc , dependency injection features. ... ... in web layer ... the web-servlet module contains spring' s model-view-controller (mvc) implementation web applications. spring's mvc framework provides clean separation between domain model code , web forms, , integrates other features of spring framework. ... ..

your question

now how should take spring mvc in mind different framework struts or part of spring?

both right because of summarized above: spring includes spring projects , 1 of them spring framework contains spring's mvc framework.

so if think single word spring both general , spring framework, spring mvc part of spring.

moreover may consider spring mvc struts, because spring's mvc framework application domain extremely closed struts one.

i think confusion comes considering part (spring's mvc framework) different whole (the general single word spring or spring framework) in part may thought included.

java spring spring-mvc frameworks

VBA Copy a Sheet with formatting -



VBA Copy a Sheet with formatting -

i'm running next code re-create , rename worksheet name isn't changing reason. ideas?

thanks in advance.

sub copy()

sheets("tv indicators").copy after:=sheets(sheets.count) sheets(sheets.count).cells.copy sheets(sheets.count).cells.pastespecial xlpastevalues sheets(sheets.count).name = sheets("tv indicators").range("a3").value

end sub

try this:

sub copier() sheets("tv indicators").copy after:=sheets(sheets.count) activesheet .cells.copy .cells.pastespecial xlpastevalues .name = sheets("tv indicators").range("a3").value end application.cutcopymode = false range("a1").select end sub

is okay?

vba

import - How do packages work in golang -



import - How do packages work in golang -

i trying understand how packages work in go improve in terms of golang enforces rather done or considered practice (we can talk practice later too, wish understand go first).

from effective go says:

"another convention bundle name base of operations name of source directory..."

however, description above doesn't seem forced go or required. thus, wondering, if allowed have multiple files different bundle declarations @ top in same directory base. if allowed have multiple bundle declaration in same directory, how import them , utilize each 1 separately in same file? basically, guess 1 of problem have due wording of of go tutorial/documentation. if convention, me, implied not enforced language. because example, go programmers not write keyword func function convention. write func because otherwise go yell @ , not compile. thus, wish clarify illustration bellow (and if possible alter documentation go, because big deal in opinion, how can done?).

for illustration have 3 file a.go, b.go, c.go print print function print() prints a,b,c respectively. on same base of operations directory called maybe base. each has different bundle declaration package apkg, bundle bpkg, bundle cpkg.

how go , import them? follow work?

package main import( namea "github.com/user_me/base/apkg" nameb "github.com/user_me/base/bpkg" namec "github.com/user_me/base/cpkg" ) func main() { namea.print() \\prints nameb.print() \\prints b namec.print() \\prints c }

or maybe don't need specify name if bundle statments top different:

package main import( "github.com/user_me/base" ) func main() { apkg.print() \\prints bpkg.print() \\prints b cpkg.print() \\prints c }

the printing file are:

a.go:

//file @ github.com.user_me/base , name a.go bundle apkg import "fmt" func print(){ fmt.println("a") }

b.go:

//file @ github.com.user_me/base , name b.go bundle bpkg import "fmt" func print(){ fmt.println("b") }

c.go: //file @ github.com.user_me/base , name c.go bundle cpkg

import "fmt" func print(){ fmt.println("c") }

also, if can have name different base, clarify me how import done? if bundle name package apkg in base of operations import have import github.com/user_me/base or import github.com/user_me/base/apkg or github.com/user_me/apkg.

i have not yet tested soon. importing deal in go has been little confusing me , love reply , share world.

no, it's 1 bundle per folder, have have them :

$gopath/src/github.com/user_me/base/apkg/a.go $gopath/src/github.com/user_me/base/bpkg/b.go $gopath/src/github.com/user_me/base/cpkg/c.go

you can't build otherwise:

┌─ oneofone@oa [/t/blah] └──➜ go build can't load package: bundle .: found packages pkga (blah1.go) , pkgb (blah2.go) in /tmp/blah

your bundle name doesn't need have same name directory in, files in 1 directory must have same bundle name.

also, can rename packages on import, example:

import ( cr "crypto/rand" mr "math/rand" )

or library called main (bad thought btw) :

import m "github.com/user_me/base/main"

import go package

java - How to Convert Struts tags into Spring 4.0? -



java - How to Convert Struts tags into Spring 4.0? -

i have custom code using struts library porting spring mvc

i need replace

skintagutils.findinscope("value1",pagecontext) , skintagutils.puttoscope("key", key, "page", pagecontext)

lines spring or jsp..

if have pagecontext object can utilize find variable in scopes.

pagecontext.findattribute("value1");

or set page scope

pagecontext.setattribute("key", key);

note, there's other convenient methods of jspcontext retrieve attribute specified scope , set attribute specified scope.

java spring jsp struts

for loop - Does iterating over returned data call the function every time in Python? -



for loop - Does iterating over returned data call the function every time in Python? -

def some_function(): # homecoming iterable_data datum in some_function(): #

here iterable_data may list, dictionary, etc.

so, for-loop calls some_function() every time looks next element of returned iterable_data?

no, look list executed just once. for compound statement documentation:

the look list evaluated once; should yield iterable object. iterator created result of expression_list. suite executed 1 time each item provided iterator, in order of ascending indices.

emphasis mine.

you can test yourself:

>>> def some_function(): ... print "some_function called" ... homecoming ['foo', 'bar', 'baz'] ... >>> datum in some_function(): ... print datum ... some_function called foo bar baz

the "some_function called" text printed once, not 3 times.

python for-loop

security - Override Spengo Filter in Websphere -



security - Override Spengo Filter in Websphere -

does have thought how can override spengo web filter websphere? have userid has been validated advertisement not match id in out identity management software. need id out of spengo/kerberos token phone call web service other id , override advertisement id one

anyone have pointers on how this? considering right thing when plan on overriding spengo filter this?

thanks

one way it, utilize login module. check sample implementation on page: mapping of client kerberos principal name websphere user registry id

security websphere websphere-7 jaas

python - Random Walk - Parallel processing -



python - Random Walk - Parallel processing -

i'm implementing monte-carlo method solve diffusion equation. solution can expressed mathematical expectation of phi(w) phi function (varies accordingly diffusion equation) , w symmetric random walk stopped @ boundary of domain. evaluate function @ point x, need start every walk in expectation x.

i want evaluate function @ big number of points. do:

i start simultaneously 1 walk every point i utilize same steps every point once each walk has reached boundary, stop i repeat these operations n times, in order approximate mathematical expectation frequency on n simulations.

my code (python) looks :

for k in range(n): #for each "walk" step = 0 while not(every walk has reach boundary): map(update_walk,points) #update walk starting each x in points incr(step)

the problem : extremely long since n can big , number of points also. looking solution help me optimize code.

i have thought of parallel processing (each walk independent) ipython did not succeed because within function (it returned error

"could not launch function 'f' because not found 'file.f' " 'f' define within file.big_f)

launching computation in separate process (which want in order avoid gil) create utilize of multiprocessing module. launching x parallel processes can done next code :

from multiprocessing import process queue import queue queue = queue(maxsize=max_nodes) # number of processes spawn procs = [process(target=f, args=(node, queue) node in nodes] # node node each process , queue mutual of processes [p.start() p in procs] # start them results = [] in range(len(nodes): results.append(queue.get())

all need modify func (target function) take relevant number of args plus queue, , @ end of computation phone call queue.put(result)

hope makes sense

python parallel-processing montecarlo

ajax - Populating Dropdown inside javascript from database through struts2 action class (using jtable) -



ajax - Populating Dropdown inside javascript from database through struts2 action class (using jtable) -

your site had helped me lot in java web development. hindrance populating dropdown within javascript through struts2 action class (using jtable). have used sample code "ajax based crud operation in struts 2 using jtable plugin".

in below code snippet want section dropdown gets value database using list2 method of com.action.jtableaction class.

userdefinedjtable.js

section : { title : 'department', width : '30%', edit : true, options : '/webapplication1/list2action', list: false },

list2 method within jtableaction

public string list2() { jsonobject obj = new jsonobject(); obj.put("name", "foo"); obj.put("num", new integer(100)); obj.put("balance", new double(1000.21)); obj.put("is_vip", new boolean(true)); homecoming obj.tostring(); }

declaration in struts.xml

<action name="getjsonresult" class="com.action.jtableaction" method="list2"> <result type="json" /> </action>

but when accessed

/webapplication1/list2action

i getting error

http status 404 - no result defined action com.action.jtableaction , result {"balance":1000.21,"num":100,"is_vip":true,"name":"foo"}

kindly help me whether doing right thing or not. , required.

edit

struts.xml

<struts> <package name="default" extends="json-default"> <action name="*action" class="com.action.jtableaction" method="{1}"> <result type="json">/jtable.jsp</result> </action> <action name="getjsonresult" class="com.action.jtableaction" method="list"> <result type="json" /> </action> <action name="getjsonresult" class="com.action.jtableaction" method="list2"> <result type="json"> <param name="root">obj</param> </result> </action> </package> </struts>

assuming using struts2-json-plugin,

make object private @ class level, providing getter it:

class="lang-java prettyprint-override">private jsonobject obj; public getjsonobject() { homecoming obj; }

change homecoming type success:

class="lang-java prettyprint-override">public string list2() { obj = new jsonobject(); obj.put("name", "foo"); obj.put("num", new integer(100)); obj.put("balance", new double(1000.21)); obj.put("is_vip", new boolean(true)); homecoming success; }

add root object parameter result definition :

class="lang-xml prettyprint-override"><action name="getjsonresult" class="com.action.jtableaction" method="list2"> <result type="json"> <param name="root">obj</param> </result> </action>

read more how works here.

edit

you have @ to the lowest degree 2 big errors in struts.xml

if returning result of type json, can't homecoming jsp; remove json first result. you can't name 2 action aliases same name in same package: differentiate names create work.

fixed code:

<struts> <package name="default" extends="json-default"> <action name="*action" class="com.action.jtableaction" method="{1}"> <result>/jtable.jsp</result> </action> <action name="getjsonresult1" class="com.action.jtableaction" method="list"> <result type="json" /> </action> <action name="getjsonresult2" class="com.action.jtableaction" method="list2"> <result type="json"> <param name="root">obj</param> </result> </action> </package> </struts>

obviously need alter name of getjsonresult phone call adding 1 or 2 @ end.

p.s: consider using different action classes, smaller actions , more granularity.

ajax database drop-down-menu struts2 jtable

parsing - Why would R use the "L" suffix to denote an integer? -



parsing - Why would R use the "L" suffix to denote an integer? -

in r know convenient times want ensure dealing integer specify using "l" suffix this:

1l # [1] 1

if don't explicitly tell r want integer assume meant utilize numeric info type...

str( 1 * 1 ) # num 1 str( 1l * 1l ) # int 1

why "l" preferred suffix, why not "i" instance? there historical reason?

in addition, why r allow me (with warnings):

str(1.0l) # int 1 # warning message: # integer literal 1.0l contains unnecessary decimal point

but not..

str(1.1l) # num 1.1 #warning message: #integer literal 1.1l contains decimal; using numeric value

i'd expect both either homecoming error.

why "l" used suffix?

i've never seen written down, theorise in short 2 reasons:

beacuse r handles complex numbers may specified using suffix "i" , simillar "i"

because r's integers 32-bit long integers , "l" hence appears sensible shorthand referring info type.

the value long integer can take depends on word size. r not natively back upwards integers word length of 64-bits. integers in r have word length of 32 bits , signed , hence have range of −2,147,483,648 2,147,483,647. larger values stored double.

this wiki page has more info on mutual info types, thier conventional names , ranges.

and ?integer

note current implementations of r utilize 32-bit integers integer vectors, range of representable integers restricted +/-2*10^9: doubles can hold much larger integers exactly.

why 1.0l , 1.1l homecoming different types?

the reason 1.0l , 1.1l homecoming different info types because returning integer 1.1 result in loss of information, whilst 1.0 not (but might want know no longer have floating point numeric). buried deep lexical analyser (/src/main/gram.c:4463-4485) code (part of function numericvalue()) creates int info type double input suffixed ascii "l":

class="lang-c prettyprint-override">/* create things okay. */ if(c == 'l') { double = r_atof(yytext); int b = (int) a; /* asked create integer via l, check double , int values same. if not, problem , not lose info , utilize numeric value. */ if(a != (double) b) { if(generatecode) { if(seendot == 1 && seenexp == 0) warning(_("integer literal %s contains decimal; using numeric value"), yytext); else { /* hide l warning message */ *(yyp-2) = '\0'; warning(_("non-integer value %s qualified l; using numeric value"), yytext); *(yyp-2) = (char)c; } } asnumeric = 1; seenexp = 1; } }

r parsing integer semantics

creating a tag using jquery bootstrap-tagsinput without hitting the enter key -



creating a tag using jquery bootstrap-tagsinput without hitting the enter key -

im using jquery bootstrap-tagsinput , method creating tag hitting come in key after typing in. looking more easy user method of creating tags. thinking onblur somewhere in bootstrap-tagsinput.js file.

can assist?

bootstrap tagsinput

thanks.

you can modify plugin (bootstratp-tagsinput.js) , add together on blur event (i pretty much copied 1 on keydown event):

self.$container.on('blur', 'input', $.proxy(function(event) { var $input = $(event.target); if (self.options.freeinput) { self.add($input.val()); $input.val(''); event.preventdefault(); } // reset internal input's size $input.attr('size', math.max(this.inputsize, $input.val().length)); }, self));

jquery twitter-bootstrap javascript-events tags onblur

Derived Class Properties Getting Passed to SQL Server via Entity Framework -



Derived Class Properties Getting Passed to SQL Server via Entity Framework -

when retrieving list of objects sql server , getting next error:

system.data.sqlclient.sqlexception invalid column name 'accountname' invalid column name 'accountnumber'

i understand database not contain columns, don't believe code should passing columns retrieval.

i have class beingness derived , entity framework code-first class has few properties added it.

for reason, when create database call, passes properties created transactionhistorygrid class sql server, when should passing transactionhistory properties.

here code:

entity framework code-first class:

public partial class transactionhistory : transaction { public string billingaddresscity { get; set; } public string billingaddresscompany { get; set; } public string billingaddresscountry { get; set; } public string billingaddressfax { get; set; } public string billingaddressfirst { get; set; } public string billingaddresslast { get; set; } public string billingaddressphone { get; set; } public string billingaddressstate { get; set; } public string billingaddressstreet { get; set; } public string billingaddresszip { get; set; } [system.componentmodel.dataannotations.schema.notmapped] public address billingaddress { get; set; } [system.componentmodel.dataannotations.schema.notmapped] public address shippingaddress { get; set; } public system.guid id { get; set; } public virtual business relationship account { get; set; } }

class populate kendo grid:

public class transactionhistorygrid : transactionhistory { public string accountname { get; set; } public string accountnumber { get; set; } public static list<transactionhistorygrid> gettransactionhistorygrid() { list<transactionhistorygrid> grids = new list<transactionhistorygrid>(); // problem begins: foreach (transactionhistory t in getalltransactionhistories()) { // doesn't create far. var grid = new transactionhistorygrid() { business relationship = t.account; accountname = t.account.accountname; accountnumber = t.account.accountnumber; }; grids.add(grid); } homecoming grids; } }

method retrieve data:

public static list<transactionhistory> getalltransactionhistories() { using (databasecontext context = new databasecontext()) { // error gets thrown here... why properties beingness read?? homecoming context.set<transactionhistory>().tolist(); } }

usage controller:

public actionresult transactionhistory_read([datasourcerequest]datasourcerequest request = null) { list<transactionhistorygrid> transactionhistory = transactionhistorygrid.gettransactionhistorygrid(); datasourceresult result = transactionhistory.todatasourceresult(request); homecoming json(result, jsonrequestbehavior.allowget); }

thoughts? suggestions?

this sql server profiler returns:

(accountname, accountnumber, , transactionhistorygrid should never sent sql. why it?)

select 1 [c1], [extent1].[discriminator] [discriminator], ... [extent1].[accountname] [accountname], [extent1].[accountnumber] [accountnumber], [extent1].[account_id] [account_id], [extent1].[billingstatement_id] [billingstatement_id] [dbo].[transactionhistories] [extent1] [extent1].[discriminator] in (n'transactionhistorygrid',n'transactionhistory')

reposting comment thread:

type discovery described here @ play. [notmapped] attribute has attributetargets.class, attributetargets.property , attributetargets.field flags, unless ever intend manipulate transactionhistorygrid properties straight via databasecontext, set attribute on entire class.

[notmapped] public class transactionhistorygrid : transactionhistory { ... }

the alternative move transactionhistorygrid class assembly.

sql entity derived

tin can api - Is xAPI designed for common data analytics? -



tin can api - Is xAPI designed for common data analytics? -

i have been consulted if possible create web site google anallytics using tin can api(xapi). seems designed e-learning spec, i'm not sure suitable info analytics on mutual web site. recommended track website visitors xapi?

no, wouldn't consider purpose, given big number of tools out there good. i'd google universal analytics, mixpanel, kissmetrics, or if you're page focused , more little new, heap analytics.

any of more appropriate fine-grained website/webapp analytics experience api, both isn't designed same scenarios , doesn't have anywhere near tooling around it.

that said, i've got several customers using wax learning record store (i'm cto of saltbox) track coarse grained web events, , they're finding useful. key experience api suitable tracking coarse learning-related things, , things happen on websites fit.

i think more mutual model, eventually, channel fine grained web analytic events analytics store, on combinations of trigger experience api statements learning record store integrate richer info other sources experience api about. adds useful level of indirection between details of actions taken in interface , learning-related happenings recorded experience api statements.

tin-can-api

py.test - Is there a way to find out which pytest-xdist gateway is running? -



py.test - Is there a way to find out which pytest-xdist gateway is running? -

i create separate log file each subprocess/gateway spawned pytest-xdist. there elegant way of finding out in subprocess/gateway pytest in? i'm configuring root logger session scoped fixture located in conftest.py, this:

@pytest.fixture(scope='session', autouse=true) def setup_logging(): logger = logging.getlogger(__name__) logger.setlevel(logging.info) fh = logging.filehandler('xdist.log') fh.setlevel(logging.info) formatter = logging.formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') fh.setformatter(formatter) logger.addhandler(fh)

it great if add together prefix log file name based on gateway number, e.g:

fh = logging.filehandler('xdist_gateway_%s.log' % gateway_number)

without each gateway utilize same log , logs messy. know can add together time stamp filename. doesn't allow me distinguish file gateway.

i found out can access gateway id in next way:

slaveinput = getattr(session.config, "slaveinput", none) if slaveinput: gatewayid = slaveinput['slaveid']

of course of study need in place can access session.config object.

py.test

javascript - How does JUMflot redraw points/choose the item? Trying to add items into an array and redraw them without affecting the original item -



javascript - How does JUMflot redraw points/choose the item? Trying to add items into an array and redraw them without affecting the original item -

essentially i'm trying have button .push line array , want jumflot maintain redrawing not impact line beingness pushed in.

what had done have (the generator id button , options defined not relevant question didn't include them):

var genvector=[[0,1],[6,6]]; //line beingness pushed in var info = []; $("#generator").click(function(){ data.push({data: genvector, editable: true}); var p = $.plot($("#graph"),data,options); }); $("#graph").bind("datadrop", function(event,pos,item) { data[item.seriesindex].data[item.dataindex] = [math.round(pos.x1),math.round(pos.y1)]; p = $.plot($("#graph"), data, options); };

what realized end happening, every time chose move point genvector coordinates change. work around did following:

var vectorcounter=0; var genvector=[[0,1],[6,6]]; var info = []; var vectorarray=[]; $("#generator").click(function(){ vectorarray.push(genvector); data.push({data: vectorarray[vectorcounter], editable: true}); vectorcounter++; var p = $.plot($("#graph"),data,options); }); $("#graph").bind("datadrop", function(event,pos,item) { data[item.seriesindex].data[item.dataindex] = [math.round(pos.x1),math.round(pos.y1)]; p = $.plot($("#graph"), data, options); };

i thought adding vector separate array , modifying there leave genvector alone. did not.

i'm assuming has how jumflot code written? if not, how can accomplish i'm doing? in advance!

this has nil jumflot rather question on object references.

when force genvector vectorarray:

vectorarray.push(genvector);

this not create new array within vector array, rather vectorarray holds reference genvector.

so when force vectorarray[0], data getting reference orginal genvector. illustrated by:

> data[0].data[0] = "mark awesome"; "mark awesome" > genvector ["mark awesome", array[2] ]

this whole concept can more shown with:

> x = [1,2,3]; [1, 2, 3] > y = x [1, 2, 3] > y[0] = "mark awesome" "mark awesome" > x ["mark awesome", 2, 3]

so question becomes, how re-create or clone array? easiest using slice trick:

> x = [1,2,3]; [1, 2, 3] > y = x.slice(0); [1, 2, 3] > y[0] = "mark awesome" "mark awesome" > x [1, 2, 3]

this shallow copy, though, if array contains object reference, won't clone it:

> x = [{'a':'b'},2,3]; [object, 2, 3] > y = x.slice(0); [object, 2, 3] > y[0]['a'] = "mark awesome" "mark awesome" > x [object a: "mark awesome" __proto__: object , 2, 3]

if want clone everything, need utilize deep copy. won't go details on i'd duplicating first-class give-and-take here.

javascript jquery arrays logic flot

regex negation - Extract Multiple values from a content using regular expression in perl -



regex negation - Extract Multiple values from a content using regular expression in perl -

i have content like:

"emailaddress":"akashu87@gmail.com","username":"akash udupa","active":true,"emailaddress":"coolrohit@rediffmail.com","username":"rohit hegde","active":true,"emailaddress":"manohar_k@rediffmail.com","username":"manohar karnam","active":true,"emailaddress":"satishgk@hotmail.com","username":"satish gk","active":true

i want display values of username in csv file through perl following:

akash udupa rohit hegde manohar karnam satish gk

i sure guys inquire me have tried. problem new perl. can help me perl code? please.

thanks in advance.

there 2 ways this; right way, , fragile way. since json has braces , brackets stripped away, you've started downwards path fragile way:

my $string = q{"emailaddress":"akashu87@gmail.com","username":"akash udupa","active":true,"emailaddress":"coolrohit@rediffmail.com","username":"rohit hegde","active":true,"emailaddress":"manohar_k@rediffmail.com","username":"manohar karnam","active":true,"emailaddress":"satishgk@hotmail.com","username":"satish gk","active":true}; while ( $string =~ m/"username"\s*:\s*"([^"]+)"/g ) { print "$1\n"; }

this anchors "username" tag, , allows whitespace (but not require it) between tag , value. looks double-quote, , captures until next quote $1.

a brief introduction perl's regexes contained in perlrequick, comes perl. regex solution doesn't utilize constructs not explained in document. matter of fact, perlintro, should considered required reading perl users, provides info sufficient task.

since it's possible logic stripped away json might have broken something, , since json might perchance throw @ our one-off regular look isn't equipped handle, wise revert original un-adulterated json, , parse proper parser, this:

use json; $json = <<'eojson'; [ { "emailaddress": "akashu87@gmail.com", "username": "akashudupa", "active": true }, { "emailaddress": "coolrohit@rediffmail.com", "username": "rohithegde", "active": true }, { "emailaddress": "manohar_k@rediffmail.com", "username": "manoharkarnam", "active": true }, { "emailaddress": "satishgk@hotmail.com", "username": "satishgk", "active": true } ] eojson print "$_->{username}\n" @{decode_json($json)}

if json module heavy-weight you, @ json::tiny, minimal, tested, , free of dependencies.

both regex , parser approach work original json, may find code can simplified eliminating section strips brackets , braces original json. 1 time you've done that, json parser solution can 1 line of code. it's lucky day when removing code can create code more robust without removing features.

perl regex-negation

javascript - Data not getting passed via Ajax to PHP script -



javascript - Data not getting passed via Ajax to PHP script -

i'm trying send value of variable number via ajax php script. php script not printing desired output on opening on browser. tried couldn't find whats wrong here. pointers ?

index.html

<button type="submit" class="btn btn-success" id = 'first' onclick='process();'>submit</button> <script> var number = 0; function process() { number++; var xhr; if (window.xmlhttprequest) { xhr = new xmlhttprequest(); } else if (window.activexobject) { xhr = new activexobject("microsoft.xmlhttp"); } var info = "num=" + number; xhr.open("post", "index.php", true); xhr.send(data); } </script>

index.php

<?php session_start(); $number = $_post['num']; $_session['numb'] = $number; echo $_session['numb'] ; ?>

editing long winded lame reply since fixed close curly bracket... bloodyknuckles right need in 'process' function take response php page , output it... or whatever want do. can utilize method 'onreadystatechange' in xmlhttprequest object , 'readystate' property value of 4 means done. here simple illustration of outputting results console (which can view using developer tools in browser of choice).

<script> var number = 0; function process() { number++; var xhr; if (window.xmlhttprequest) { xhr = new xmlhttprequest(); } else if (window.activexobject) { xhr = new activexobject("microsoft.xmlhttp"); } var info = "num=" + number; xhr.onreadystatechange = function(){ if (xhr.readystate==4 && xhr.status==200){ console.log('xhr.readystate=',xhr.readystate); console.log('xhr.status=',xhr.status); console.log('response=',xhr.responsetext); } else if (xhr.readystate == 1 ){ xhr.send(data) } }; xhr.open("post", "ajax-test.php", true); } </script>

as go farther may want update php page update session when post value there.

<?php //ini_set('display_errors',1); //ini_set('display_startup_errors',1); //error_reporting(-1); if(isset($_post['num'])){ session_start(); $_session['numb'] = $_post['num']; echo $_session['numb']; } ?>

you can uncomment ini_set , error_reporting lines seek figure out going on php script.

javascript php html ajax

javascript - how to know from gmail/fb login form that user has successfully logged in, while log in with gmail/fb? -



javascript - how to know from gmail/fb login form that user has successfully logged in, while log in with gmail/fb? -

rails 4 + twitter bootstrap + jquery + javascript + ominiauth

_header.html.erb

<span class="callno"><%= link_to "sign in", {:controller => "web",:action => "sign_in_user"}, :role => 'button', 'data-toggle' => 'modal', 'data-target' => '#popup_div', :remote => true %></span>

web_controller.rb

def sign_in_user end

sign_in_user.js.erb

$('#popup_div').html("<%= escape_javascript(render 'web/login_form') %>");

_login_form.html.erb

<div style="border-right: 1px solid #c0c0c0; margin-left: -11px; float: left; height: 252px"></div> <h4>sign in with</h4></br> <a><%= link_to image_tag("web/fb_login.png", :alt => "facebook", :style => 'margin: 0 0 10% 20%'), user_omniauth_authorize_path(:facebook), :class => "popup", :"data-width" => 600, :"data-height" => 400, :onclick => "return closeloginform();" %> </a><br/><br/> <a><%= link_to image_tag("web/google_login.png", :alt => "google", :style => 'margin: 0 0 0 20%'), user_omniauth_authorize_path(:google_oauth2), :class => "popup", :"data-width" => 600, :"data-height" => 500, :onclick => "return closeloginform();" %></a><br/><br/> </div> <script type="text/javascript"> function closeloginform(){ $('#popup_div').modal('hide'); } </script> <script type="text/javascript"> function popupcenter(url, width, height, name) { var left = (screen.width/2)-(width/2); var top = (screen.height/2)-(height/2); childwindow = window.open(url, name, "menubar=no,toolbar=no,status=no,width="+width+",height="+height+",toolbar=no,left="+left+",top="+top); homecoming childwindow; } $("a.popup").click(function(e) { popupcenter($(this).attr("href"), $(this).attr("data-width"), $(this).attr("data-height"), "authpopup"); e.stoppropagation(); homecoming false; }); </script>

1) on header sign in link there.

2) when click on sign in open modal popup (twitter bootstrap).

3) there 2 options there google(image logo) , facebook(image logo) sign in.

4) when click on 1 (suppose google image means sign in gmail account) window open gmail login form.

5) there come in login details what should happen after successful login kid window should close reloading parent window. what happening after successful login kid window reloading , getting sign in in kid window.

my question how can know gmail/fb login form user has logged in ??

how reload parent window kid window?

provided kid , parent within same origin, in child's code can this:

opener.location.reload();

if aren't, same origin policy kick in , prevent cross-origin call. in case, can utilize postmessage tell parent window reload:

in parent:

window.addeventlistener("message", function(e) { if (e.origin !== "http://the kid window's url") { // ignore message, don't know sender return; } if (e.data === "reload") { location.reload(); } }, false);

in child:

opener.postmessage("reload", "http://the parent's url");

example:

parent.html:

<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>opener</title> </head> <body> <input type="button" value="open popup"> <script> (function() { // shows when window (re)loaded var p = document.createelement('p'); p.innerhtml = "(re)loaded on " + new date(); document.body.appendchild(p); // hooks button open popup document.queryselector("input").onclick = function() { window.open("popup.html", "_blank", "width=500,height=500,menubar=no,toolbar=no"); }; })(); </script> </body> </html>

popup.html:

<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>popup</title> </head> <body> <input type="button" value="close"> <script> document.queryselector("input").onclick = function() { if (opener) { opener.location.reload(); // <========== } close(); }; </script> </body> </html>

javascript ruby-on-rails facebook twitter-bootstrap omniauth

php - Why composer update updates symfony to 2.5 but it's "symfony/symfony": "~2.4"? -



php - Why composer update updates symfony to 2.5 but it's "symfony/symfony": "~2.4"? -

maybe i'm totally wrong how composer works, given next composer.json (part of symfony, added requirements not shown here):

"require": { "php": ">=5.3.3", "symfony/symfony": "~2.4", "doctrine/orm": "dev-master", "doctrine/dbal": "dev-master", "doctrine/doctrine-bundle": "dev-master", "twig/extensions": "~1.0", "symfony/assetic-bundle": "~2.3", "symfony/swiftmailer-bundle": "~2.3", "symfony/monolog-bundle": "~2.4", "sensio/distribution-bundle": "~2.3", "sensio/framework-extra-bundle": "~3.0", "sensio/generator-bundle": "~2.3", "incenteev/composer-parameter-handler": "~2.0", // requirements here }

when run composer update symfony/symfony 2.5 instead of ~2.4 (that afaik 2.4.1, 2.4.2, etc).

~2.4 equivalent of >=2.4,<3.0. if remain 2.4.x branch have utilize 2.4.*.

you can read more version numbers on composer's documentation pages: https://getcomposer.org/doc/01-basic-usage.md#package-versions

php symfony2 composer-php

playframework - error: cannot find symbol, symbol class With - Play framework java -



playframework - error: cannot find symbol, symbol class With - Play framework java -

i trying utilize play framework's composing actions using java. getting compilation error.

error: cannot find symbol @with(menus.class) ^

can 1 tell me error?

playframework playframework-2.0

android - If-else to control button event -



android - If-else to control button event -

here connected laptop , android through bluetooth.

my question , how can set info when don't force button.

my android application sends +,- when press +button , - button.

if press + button, programme in laptop increment value, , - button gives opposite result.

but need 1 1 alter in value.

that means, 1 click increment value in 1 time, not continuously increasing value.

the code below sends info pushed in lastly when don't force button.

bundle remote.bluetooth; import android.app.activity; import android.content.context; import android.content.intent; import android.graphics.canvas; import android.graphics.color; import android.graphics.paint; import android.graphics.paint.style; import android.os.bundle; import android.view.motionevent; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.textview; public class mouseactivity extends activity implements onclicklistener{ int score = 0; textview value; button plus, minus; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.mouseactivity); plus = (button) findviewbyid(r.id.rclick); minus = (button) findviewbyid(r.id.lclick); value = (textview) findviewbyid(r.id.number); plus.setonclicklistener((onclicklistener) this); minus.setonclicklistener((onclicklistener) this); //왼 클릭 버튼 생성 및 이벤트 연결 } public void onclick(view v) { if(v.getid()==r.id.rclick) { string msg = "+"; main.getinstance().sendmessage(msg); score++; value.settext(string.valueof(score)); } else if (v.getid()==r.id.lclick) { string msg = "-"; main.getinstance().sendmessage(msg); score--; value.settext(string.valueof(score)); } else { string msg = "0"; main.getinstance().sendmessage(msg); }} }

and send message method

public void sendmessage(string mmsg) { // check we're connected before trying if (mconnection.getstate() != bluetoothconnection.state_connected) { toast.maketext(this, r.string.not_connected, toast.length_short).show(); return; } // check there's send if (mmsg.length() > 0) { // message bytes , tell bluetoothchatservice write byte[] send = mmsg.getbytes(); mconnection.write(send); } }

you incrementing , decrementing score variable twice.

here:

case r.id.rclick: score++; showtext = true; break;

and here:

if(v.getid()==r.id.rclick){ string msg = "+"; main.getinstance().sendmessage(msg); score++; value.settext(string.valueof(score)); }

android if-statement

java - Efficient way to implement Likes features in a video application -



java - Efficient way to implement Likes features in a video application -

i have video based project.in project want implement likes features.that there hyperlink on each video total count , when user click on hyperlink after hyperlink hide , show liked text total count of video.

i have write code in javascript ajax main problem in 1 session if user 5 video 5 times db hit.is there efficient way implement it.

<div id="status${video.id}"><a href="javascript:calllike('${video.id}');"> like- </a> </div><a id="like1${video.id}" style="color:#ffffff;">${video.likescount}</a> function calllike(id) { document.getelementbyid("like"+id).innerhtml='300'; var postdata = '?id='+id; var url =protocol+'//'+host+'/xxx/getlike'+postdata; // alert("url:"+url); if (window.xmlhttprequest) { req = new xmlhttprequest(); } else if (window.activexobject) { req = new activexobject("microsoft.xmlhttp"); } req.onreadystatechange = likesres; req.open("post", url, true); req.send(null); } function likesres() { if (req.readystate == 4) { if (req.status == 200){ response = req.responsetext; document.getelementbyid("like1"+id).innerhtml=response; document.getelementbyid("status"+id).innerhtml='liked--'; } }

java javascript ajax like social

php - Adding a class local to another class -



php - Adding a class local to another class -

i have class performs various functions. within class, need create object, so, intention add together class file shown below. concern, however, name of additional class (i.e. mysubclass) might conflict other class name using. since mysubclass used in connection mymainclass, there way create local (analogous local variable) mymainclass?

class mymainclass { public function mymethod() { $obj=new mysubclass(); } } class mysubclass { public $prop1=array(); public $prop2=array(); public $prop3=123; }

use namespaces, set utility class "mymainclasstools/mysubclass.php" , add together according namespace.

php oop

How can I set up a datestamp in Google Sheets for specific rows? -



How can I set up a datestamp in Google Sheets for specific rows? -

i trying set google sheets spreadsheet where, when specific cell edited, date in cell right updates indicate alter has been made. on google sheets forum, directed me here best guidance.

the script working perfectly. however, i'd limit specific cells (or rows--either work) not add together date stamp header rows. need add together script apply specific cells/rows?

here's script now:

function onedit() { var s = spreadsheetapp.getactivesheet(); var r = s.getactivecell(); if( r.getcolumn() != 3 ) { //checks column var row = r.getrow(); var time = new date(); time = utilities.formatdate(time, "gmt-07:00", "mm/dd/yy"); spreadsheetapp.getactivesheet().getrange('c' + row.tostring()).setvalue(time); }; };

hypothetically, let's have sheet 30 active rows. want datestamp appear in rows 9 through 13; 15 through 18; , 20 through 26. other rows headers , want able alter text there without sheets populating adjacent cell datestamp. how go editing script accomplish in google sheets, assuming it's possible? give thanks you!!

just add together more conditions column condition.

for illustration 2 first series of rows :

if( r.getcolumn() != 3 && ((row>8 && row<14)||(row>14 && row<19))){ // go on other , and or conditions

btw, suggest replace hard coded time zone dedicated method :

var tz = session.getscripttimezone(); var time = utilities.formatdate(new date(),tz, "mm/dd/yy");

it match time zone of sheet automatically, if in country has daylight savings.

google-apps-script

c++ - Write to mutiple 3Dtextures in fragment shader OpenGL -



c++ - Write to mutiple 3Dtextures in fragment shader OpenGL -

i have 3d texture write info , utilize voxels in fragment shader in way:

#extension gl_arb_shader_image_size : enable ... layout (binding = 0, rgba8) coherent uniform image3d volumetexture; ... void main(){ vec4 fragmentcolor = ... vec3 coords = ... imagestore(volumetexture, ivec3(coords), fragmentcolor); }

and texture defined in way

glgentextures(1, &volumetexture); glbindtexture(gl_texture_3d, volumetexture); glteximage3d(gl_texture_3d, 0, gl_rgba8, volumedimensions, volumedimensions, volumedimensions, 0, gl_rgba, gl_unsigned_byte, 0);

and when have utilize it

glactivetexture(gl_texture0); glbindtexture(gl_texture_3d, volumetexture);

now issue have mipmapped version of , without using opengl function because noticed extremely slow. thinking of writing in 3d texture @ levels @ same time so, instance, max resolution 512^3 , write 1 voxel value in 3dtex write 0.125*value 256^3 voxel , 0.015625*value 126^3 etc. since using imagestore, uses atomicity values written , using these weights automatically average value (not interpolation might pleasing result anyway). question is, best way have multiple 3dtextures , writing in of them @ same time?

i believe hardware mipmapping fast you'll get. i've assumed attempting custom mipmapping slower given have bind , rasterize each layer manually in turn. atomics give huge contention , it'll amazingly slow. without atomics you'd negating nice o(log n) construction of mipmaps.

you have really careful imagestore regard access order , cache. i'd start here , seek different indexing (eg row/column vs column/row).

you seek drawing texture older way, binding fbo , drawing total screen triangle (big triangle covers viewport) gldrawelementsinstanced. in geometry shader, set gl_layer instance id. rasterizer creates fragments x/y , layer gives z.

lastly, 512^3 huge texture todays standards. maybe find out theoretical max gpu bandwidth thought of how far away are. e.g. lets gpu can 200gb/s. you'll 100 in case anyway. 512^3 texture 512mb might able write in ~5ms (imo seems awfully fast, maybe made mistake). expect overhead , latency rest of pipeline, spawning , executing threads etc. if you're writing complex stuff memory bandwidth isn't bottleneck , estimation goes out window. seek writing zeroes first. seek changing coords xyz order.

update: instead of using fragment shader create threads, vertex shader can used instead, , in theory avoids rasterizer overhead though i've seen cases doesn't perform well. glenable(gl_rasterizer_discard), gldrawarrays(gl_points, 0, numthreads) , utilize gl_vertexid thread index.

c++ opengl voxels 3d-texture image-unit

php - Second form on page is using first form's action attribute -



php - Second form on page is using first form's action attribute -

i have page 2 forms, , sec form using action attribute of first form. code:

<!-- mount sites --> <form name="form" action="shopsite.php" method="post" id="form"> <!-- sites pass alt tag shopsite.php --> <ul id="sites"> <tr> <li><td class="" id="hyland"><div><img id="imghyland" onclick="this.src='radiotower.jpg';clearack('hyland');" src="radiotower.jpg" alt="hyland" class="location" /><br/>hyland</div></td></li> </ul> <div><input type="hidden" name="sitename" id="sitename" value="" /></div> </form><!-- end first form --> <!-- non-mountain sites --> <form name="form-nm" action="shopsite-nm.php" method="post" id="form-nm"> <!-- sites pass alt tag shopsite-nm.php --> <ul id="sites"> <li><td class="" id="kms"><div><img id="imgkms" onclick="this.src='radiotower.jpg';clearack('kms');" src="radiotower.jpg" alt="kms" class="location" /><br/>kms</div></td></li> </tr> <div><input type="hidden" name="sitename" id="sitename" value="" /></div> </form><!-- end sec form -->

when click input on either form (inputs li tags), goes shopsite.php. inputs in sec form should go shopsite-nm.php. researched using multiple forms on page phone call different php pages, , supposedly it's possible, although illustration found did not utilize hidden input. i'm not sure if problem.

thanks in advance help :)

edit: sitename passing correctly both forms.

edit 2: if there's improve way build this, i'm open suggestions. thought each form displays list of sites status, , when user clicks on site, shown page more detailed info particular site. there 1 form sites, new sites have been added require different informational display, i'm trying accommodate sec form.

could utilize jquery here?

$(document).ready(function() { $('#hyland').click(function(e) { $.ajax({ url: 'shopsite.php', type: 'post', data: $('#form').serialize(), success: function(res) { //do here console.log(res); }, error: function(error) { //do here console.log(res); } }); }); });

php html forms

python - Retrieving records from SQL Server with PYODBC and FreeTDS -



python - Retrieving records from SQL Server with PYODBC and FreeTDS -

i have python script connects local sql server (2012, believe?) , runs "select * ..." query. when run script, error saying:

file "/home/mdrouin/dev/redbus/wyndham.py", line 643, in connect cursor.execute("select * [rentaldb].[dbo].[clients]") pyodbc.programmingerror: ('42000', '[42000] [freetds][sql server]unicode info in unicode-only collation or ntext info cannot sent clients using db-library (such isql) or odbc version 3.7 or earlier. (4004) (sqlexecdirectw)')

after reading other posts, tried suggestion thread mentioned adding next script:

os.environ['tdsver'] = '7.0'

however, when this, unicode escape strings (i think that's they're called...) returned, instead of data. illustration of when print row table:

(u'\u00320035\u00380033\u00360033\u00300030\u00300030\u00300030\u00320031\u00320039\u00350039', u'\u00640041\u006d0061\u00520020\u004d0020\u00740061\u00690074\u0067006e\u0079006c\u00280020\u00590057\u0032004e\u00300031', u'\u00640061\u006d0061\u00390073\u006d006d', u'\u006f006a\u006e0068\u00650064\u00720065\u00390065\u00330034', u'\u00330032\u0031002e\u002e0039\u00310035\u0031002e\u00350031')

the thing don't running on vm set same vm, , 1 of vms runs fine while other doesn't. other vm doesn't have either of these issues. checked odbc.ini , odbcinst.ini files on both computers, , same, don't know causing issues. both vms running debian 7.

nevermind... i'm retarded. when set virtualenv in python on vm wasn't working, accidentally used python 2.6 rather python 2.7, in turn allow pyodbc 2.x installed rather pyodbc 3.x. older version of pyodbc causing issues.

python sql sql-server pyodbc freetds

php - MySQL: mysqldump to generate database backup -



php - MySQL: mysqldump to generate database backup -

i have had written next snippet generates mysql database dump , saves on server:

public function save_db_backup() { $dbuser=$this->db->username; $dbpasswd=$this->db->password; $database=$this->db->database; $filename = $database . "-" . date("y-m-d_h-i-s") . ".sql.gz"; $save_path = $_server['document_root'] . '/application/assets/db_backups/' . $filename; $cmd = "mysqldump -u $dbuser --password=$dbpasswd $database | gzip --best > " . $save_path; exec( $cmd ); }

it has been working fine on other server. after moving site new server, has stopped working i.e. database backup file not beingness saved @ path specified. also, have checked exec is enabled on server plus directory readable , writeable:

is_readable($_server['document_root'] . '/application/assets/db_backups/') // true is_writable($_server['document_root'] . '/application/assets/db_backups/') // true

i have checked , database credentials alright. have tried path mysqldump , didn't work either:

$cmd = "/usr/bin/mysqldump -u $dbuser --password=$dbpasswd $database | gzip --best > " . $save_path;

what problem there perchance be?

you should check user launches command, , if dir readable , writeable user. if launching php script, it's probable cause.

php mysql mysqldump

r - How do I simply access the values of an "edge sequence" igraph object? -



r - How do I simply access the values of an "edge sequence" igraph object? -

i want access ids of vertices connected vertex u in graph g.

i utilize command e(g)[from(u)]. generates next output:

edge sequence:

[9814] 122 -> 24

[9815] 122 -> 178

[9816] 122 -> 124

how access values 24, 178, , 124?

i realise may simple command, cannot find out how anywhere in documentation.

maybe simplest utilize neighbors() function in first place:

neighbors(g, u, mode="out")

if want border sequence, then:

v(g)[ to(e(g)[from(u)]) ]

see

http://igraph.org/r/doc/structure.info.html http://igraph.org/r/doc/graph.structure.html http://igraph.org/r/doc/iterators.html

r igraph

java - Spring AOP reentrant aspects -



java - Spring AOP reentrant aspects -

is possible create reentrant aspects spring aop (or aspectj)?

here example:

@log public int calcfibonacci(int n) { if(n <= 1) { homecoming n; } else { homecoming calcfibonacci(n - 1) + calcfibonacci(n - 2); } }

and aspect:

@aspect public class loggingaspect { @around("@annotation(log)") public object measure(proceedingjoinpoint pjp, log log) throws throwable { // log relevant info log annotation , pjp ... homecoming pjp.proceed(); }

}

now i'd know how many times calcfibonacci called (counting in recurrent calls).

is there way accomplish this?

okay, cannot solve elegantly in spring aop - see first remark andrei stefan's answer. if in aop application code needs know aspect's existence or phone call aspect-related code, bad design , anti-aop. thus, here have aspectj solution you.

first of all, in aspectj there more execution() pointcuts, e.g. call(). thus, counting joinpoints annotated @log yield result twice big actual number of recursive calls calcfibonacci(int). because of this, pointcut should not just

class="lang-java prettyprint-override">@annotation(log)

but

class="lang-java prettyprint-override">execution(* *(..)) && @annotation(log)

actually, still not plenty because if multiple methods contain @log annotations? should calls counted? no, calcfibonacci(int)! should restrict "fibonacci phone call counter" more like:

class="lang-java prettyprint-override">execution(* *..application.calcfibonacci(int)) && @annotation(log)

here compileable sample code:

annotation:

package de.scrum_master.app; import java.lang.annotation.retention; import java.lang.annotation.retentionpolicy; @retention(retentionpolicy.runtime) public @interface log {}

application recursive fibonacci method:

package de.scrum_master.app; public class application { public static void main(string[] args) { int fibonaccinumber = 6; system.out.println("fibonacci #" + fibonaccinumber + " = " + new application().calcfibonacci(fibonaccinumber)); } @log public int calcfibonacci(int n) { homecoming n <= 1 ? n : calcfibonacci(n - 1) + calcfibonacci(n - 2); } }

aspect, version 1:

package de.scrum_master.aspect; import org.aspectj.lang.joinpoint; import org.aspectj.lang.annotation.aspect; import org.aspectj.lang.annotation.before; import de.scrum_master.app.log; @aspect public class loggingaspect { int count = 0; @before("execution(* *..application.calcfibonacci(int)) && @annotation(log)") public void measure(joinpoint thisjoinpoint, log log) { system.out.println(thisjoinpoint + " - " + ++count); } }

output, version 1:

class="lang-none prettyprint-override">execution(int de.scrum_master.app.application.calcfibonacci(int)) - 1 execution(int de.scrum_master.app.application.calcfibonacci(int)) - 2 (...) execution(int de.scrum_master.app.application.calcfibonacci(int)) - 24 execution(int de.scrum_master.app.application.calcfibonacci(int)) - 25 fibonacci #6 = 8

now, if phone call fibonacci method twice?

int fibonaccinumber = 6; system.out.println("fibonacci #" + fibonaccinumber + " = " + new application().calcfibonacci(fibonaccinumber)); fibonaccinumber = 4; system.out.println("fibonacci #" + fibonaccinumber + " = " + new application().calcfibonacci(fibonaccinumber)); class="lang-none prettyprint-override">execution(int de.scrum_master.app.application.calcfibonacci(int)) - 1 execution(int de.scrum_master.app.application.calcfibonacci(int)) - 2 (...) execution(int de.scrum_master.app.application.calcfibonacci(int)) - 24 execution(int de.scrum_master.app.application.calcfibonacci(int)) - 25 fibonacci #6 = 8 execution(int de.scrum_master.app.application.calcfibonacci(int)) - 26 execution(int de.scrum_master.app.application.calcfibonacci(int)) - 27 (...) execution(int de.scrum_master.app.application.calcfibonacci(int)) - 33 execution(int de.scrum_master.app.application.calcfibonacci(int)) - 34 fibonacci #4 = 3

uh-oh!!!

we need either reset counter in between calls (and create sure whole thing thread-safe using threadlocal or so) or utilize aspect instantiation per command flow instead of singleton aspect, utilize here fun of it:

aspect, version 2:

class="lang-java prettyprint-override">package de.scrum_master.aspect; import org.aspectj.lang.joinpoint; import org.aspectj.lang.annotation.aspect; import org.aspectj.lang.annotation.before; import de.scrum_master.app.log; @aspect("percflow(execution(* *.calcfibonacci(int)) && !cflowbelow(execution(* *.calcfibonacci(int))))") public class loggingaspect { int count = 0; @before("execution(* *.calcfibonacci(int)) && @annotation(log)") public void measure(joinpoint thisjoinpoint, log log) { system.out.println(thisjoinpoint + " - " + ++count); } }

note:

i have shortened bundle , class specification *in order create source code more readable. can utilize de.scrum_master.app.application or abbreviation of in order avoid collisions similar class/method names. the @aspect annotation had parameter says: "create 1 instance per execution of fibonacci method, exclude recursive ones."

output, version 2:

class="lang-none prettyprint-override">execution(int de.scrum_master.app.application.calcfibonacci(int)) - 1 execution(int de.scrum_master.app.application.calcfibonacci(int)) - 2 (..) execution(int de.scrum_master.app.application.calcfibonacci(int)) - 24 execution(int de.scrum_master.app.application.calcfibonacci(int)) - 25 fibonacci #6 = 8 execution(int de.scrum_master.app.application.calcfibonacci(int)) - 1 execution(int de.scrum_master.app.application.calcfibonacci(int)) - 2 (..) execution(int de.scrum_master.app.application.calcfibonacci(int)) - 8 execution(int de.scrum_master.app.application.calcfibonacci(int)) - 9 fibonacci #4 = 3

now, looks much better. :)))

enjoy!

java spring aspectj spring-aop aspect

php - what is the best way to handle database querying before any page is loaded? -



php - what is the best way to handle database querying before any page is loaded? -

i'm using laravel 4 framework , though i'm open doing non-laravel way, if need be. logged in users maintained in database 'active_users', if record deleted database, want phone call auth::logout(). best way ?

these options have considered : 1. event (not sure how go it) 2. using ajax poll script queries db 3. using (before) filter. 4.using table based sessions <= seems attractive option.

if there improve different way this, please allow me know, give thanks you.

this rather simple. highly assume got server side execution on every page can handle server-side code, including session handling.

you need ajax if you'd storing users in client local storage assume you're handling user session on server.

just create function returns bool value true if user exists, false otherwise. if function returns false destroy user's session session_destroy().

the function either count number of rows fetched when select rows matching current user, if returns 0 know row has been deleted (or never existed in first place, doesn't matter). create more sense add together active column row, can update 0 instead of 1 if wish deactivate user, way history maintained. you'd selecting user active, i.e. 1, (0 rows returned if it's been changed 0).

do before check if users allowed see parts of website, way handled non-logged in users.

edit solution depends on how strict requirements are, if users must logged out during activity performed user need check if user still active every single time perform activity, if activity client-side need utilize ajax check if user still allowed he's do. if user given permission log-in in first place overload that's not mine tell.

edit

it doesn't matter framework you're using, okay, you're using laravel. know can utilize auth::logout() function, utilize it! :)

function userisactive(){...} $active = userisactive(); if(!$active) { auth::logout(); }

no ajax needed unless want do javascript activity, if users can perform javascript activity requires logged-in permissions , need utilize ajax check if they're still active.

using ajax not if it's matter of security , authendication, if user turns off javascript (or has disabled reason, perhaps unknown user) you're pretty much ... i'm not going finish sentence :)

php laravel laravel-4

executorservice - How is an executor terminated in my Java program? -



executorservice - How is an executor terminated in my Java program? -

this question related previous question : why speed of java process within multiple loops slows downwards goes?

in order find problem of question, looked closely @ code , found executors in app not terminated, since i'm in process of learning how utilize executors, copied online sample codes , used them in app, , i'm not sure if i'm using them correctly.

what's difference between next 2 approaches of using executors ?

[1]

executor executor=executors.newfixedthreadpool(30); countdownlatch donesignal=new countdownlatch(280); (int n=0;n<280;n++) { ... executor.execute(new samplecountrunner(donesignal,...)); } seek { donesignal.await(); } grab (exception e) { e.printstacktrace(); }

[2]

executorservice executor=executors.newfixedthreadpool(30); (int i=0;i<60;i++) { ... executor.execute(new xyzrunner(...)); } executor.shutdown(); while (!executor.isterminated()) { }

it seems me after 1st 1 done, executor still has active pool of threads running , waiting more tasks, consume cpu time , memory.

the 2nd 1 terminate active threads in pool after shutdown() method run, , active threads won't take more cpu time or memory after point.

so questions :

[1] right ?

[2] how terminate pool of threads in 1st case ? there no "executor.shutdown()" executor

edit :

problem solved, changed executor in [1] executorservice, , added :

executor.shutdown(); while (!executor.isterminated()) { }

now when programme ends, won't have lot of threads active more.

it seems me after 1st 1 done, executor still has active pool of threads running , waiting more tasks, consume cpu time , memory.

not exactly. in first approach , after tasks done ( signalled latch ) , executor not shutdown - threads in executor not consume cpu ( consume minimum memory needed thier structures yes ).

in approach - explicitly in command of knowing when , how tasks completed. can know if tasks have succeeded or failed , , can decide resubmit tasks if needed.

the 2nd 1 terminate active threads in pool after shutdown() method run, , active threads won't take more cpu time or memory after point.

again ,not .in approach , executorservice not shutdown after phone call shutdown(). waits submitted tasks finish , here not straight know if these tasks completed or failed ( throwing exception ).

and until submitted tasks completed - isshutdown() tight loop ( spike cpu near 100% ) .

java executorservice executor

c# - WPF drawing performance -



c# - WPF drawing performance -

i've been doing lot of reading wpf drawing , performance , it's apparent methods of drawing improve others. have gotten confused different people's terminology of things , want clarify 1 issue.

the scheme i'm working on has lots of gauges on screen (exactly speedometer in car). scale , range indicators can alter , different on each gauge. best draw these in xaml or in .cs file behind it. reason i'm asking starting see performance issues in scheme when lot of gauges on display , i'm trying isolate cause.

currently it's drawn behind each individual segment added children.add(uielement).

i'm not sure if placing them in xaml or code behind makes difference - @ end of day these objects pushed onto visual layer 1 way or another.

your issue more because you're using blown uielement instances.

for performance enhancements, seek using more light-weight objects, i.e. drawingvisual

these objects not powerful uielements, may lose functionality want utilize you'll need reimplement way.

this documentation should set on right track.

c# wpf xaml

asp.net - Show error message on webpage if there trying to add duplicate value into database? -



asp.net - Show error message on webpage if there trying to add duplicate value into database? -

i have interface create new client both client code , client name insert client table. code not duplicate in table. want show error message on webpage if there duplicate code beingness typed client code area , submit. how this? next code, thanks!

protected void btnok_click(object sender, eventargs e) { sqlconnection conn = new sqlconnection(getconnectionstring()); sqlcommand cmd = new sqlcommand(); cmd.commandtype = commandtype.storedprocedure; cmd.connection = conn; cmd.commandtext = "dbo.insertcustomer"; cmd.parameters.addwithvalue("@ccode", txtcustomercode.text); cmd.parameters.addwithvalue("@cname", txtremark.text); seek { conn.open(); cmd.executenonquery(); string message = "new client created!"; system.text.stringbuilder sb = new system.text.stringbuilder(); sb.append("<script type = 'text/javascript'>"); sb.append("window.onload=function(){"); sb.append("alert('"); sb.append(message); sb.append("')};"); sb.append("</script>"); clientscript.registerclientscriptblock(this.gettype(), "alert", sb.tostring()); } grab (system.data.sqlclient.sqlexception ex) { string msg = "insert error:"; msg += ex.message; throw new exception(msg); } { conn.close(); conn.dispose(); } }

you set label message. like.

if(ex.message.tostring().contains("duplicate")) this.lblmessage.text = "code "+txtcustomercode.text+" taken." else this.lblmessage.text = msg;

not sure of exact text for. not rethrow exception.

asp.net

security - JMX: How can I support both secure and insecure access at the same time (different URLs) -



security - JMX: How can I support both secure and insecure access at the same time (different URLs) -

i've been asked back upwards 2 urls jmx access our server:

a secure 1 (service:jmx:rmi://localhost/jndi/rmi://localhost:2020/jmxrmi) insecure one: (service:jmx:rmi://localhost/jndi/rmi://localhost:2020/insecure-jmxrmi)

the insecure 1 demo purposes - no won't used during production.

i can create custom connectorserver /jmxrmi , provide interceptor utilize our security mechanism verify credentials. if create vanilla sec connectorserver (no 'env' properties), however, using jconsole -debug access tries secure access, , puts dialog failing, asking if want seek insecurely.

the docs i've read oracle/sun indicate can disable password auth , ssl using couple of command-line -d switches. not mess /jmxrmi secure access?

how back upwards both secure , non-secure connections @ same time? note don't need them using same url, of course.

thanks!

this tough one. when disable auth , ssl per jvm.

the jmxrmp protocol can not distinguish between secured , non-secured connection. either set security , used or not. think best shot using custom connectorserver , set messages jconsole produces.

security rmi jmx

haskell - Why does flooring infinity not throw some error? -



haskell - Why does flooring infinity not throw some error? -

found myself having case equivalent of floor $ 1/0 beingness executed.

class="lang-hs prettyprint-override">λ> 1/0 infinity

this normal behavior far understand but, when infinity floor'd or ceiling'd

class="lang-hs prettyprint-override">λ> floor $ 1/0 179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216

instead of failing, big number produced. why?

maybe more importantly, how can distinguish non faulty result without using filter before applying function?

the first question perhaps not important, i'll seek reply sec question first.

once have number, if know came floor x, can't know whether x valid representation of 2^1024 or if infinity. can assume outside of range of double invalid , produced infinity, negative infinity, nan or like. quite simple check if value valid using one/many of functions in realfloat, isnan, isinfinite, etc.

you utilize data number = n | posinf | neginf. write:

instance realfrac => realfrac (number a) ... floor (n n) = floor n floor posinf = error "floor of positive infinity" floor neginf = error "floor of negative infinity" ..

which approach best based on utilize case.

maybe right floor (1/0) error. value garbage anyways. improve deal garbage or error?

but why 2^1024? took @ source ghc.float:

properfraction (f# x#) = case decodefloat_int# x# of (# m#, n# #) -> allow m = i# m# n = i# n# in if n >= 0 (fromintegral m * (2 ^ n), 0.0) else allow = if m >= 0 m `shiftr` negate n else negate (negate m `shiftr` negate n) f = m - (i `shiftl` negate n) in (fromintegral i, encodefloat (fromintegral f) n) floor x = case properfraction x of (n,r) -> if r < 0.0 n - 1 else n

note decodefloat_int# returns mantissa , exponent. according wikipedia:

positive , negative infinity represented thus: sign = 0 positive infinity, 1 negative infinity. biased exponent = 1 bits. fraction = 0 bits.

for float, means base of operations of 2^23, since there 23 bits in base, , exponent of 105 (why 105? have no idea. think should 255 - 127 = 128, seems 128 - 23). value of floor fromintegral m * (2 ^ n) or base*(2^exponent) == 2^23 * 2^105 == 2^128. double value 1024.

haskell floating-point infinity floor

arduino - Best way to make a project with multiple files -



arduino - Best way to make a project with multiple files -

i developing arduino based scheme enlarge on time. @ moment has humidity , temperature read functionality. door control, sound recording , gsm web client back upwards added. want these included libraries , used in main part. i'm thinking of 1 ino file includes other modules , calls functions. question best , clean way it?

i recommend sticking libraries , library directories examples. library each component interfaced with. help in many ways. such debugging , reuse.

c:\users\myself\google drive\arduino\libraries\componentx\componentx.h c:\users\myself\google drive\arduino\libraries\componentx\componentx.cpp c:\users\myself\google drive\arduino\libraries\componenty\componenty.h c:\users\myself\google drive\arduino\libraries\componenty\componenty.cpp etc...

this keeps modular , compartmentalized.

notice have changed arduino's ide preferences google drive. (cloud backup , portability)

then rather 1 big ino file in sketch folder

c:\users\myself\google drive\arduino\somethingbig\somethingbig.ino

implement ino files in

c:\users\mflaga\google drive\arduino\libraries\component\examples.

directories. makes quick publish components on github or google drive share between systems.

then can have sketch file ties components main project.

c:\users\myself\google drive\arduino\somethingtoplevel\somethingtoplevel.ino

arduino arduino-ide

database - Not All variables Bound Error in SQL prepaired statment in Tibco -



database - Not All variables Bound Error in SQL prepaired statment in Tibco -

i using tibco bw jdbc query activity. blow statment running fine in sql developer not getting compiled gives error "ora-01008: not variables bound"

select (cast(fech2 timestamp) - cast(fech1 timestamp) )total ( select min(case when message ='abc' time_stamp end) fech1, min(case when message ='efg' time_stamp end) fech2 log application = 'mnc' , tid=? grouping tid)

please help? said, there no alter required in sql developer run statement.

sql database oracle oracle-sqldeveloper tibco

php - Drupal 7 Default Node "View" Template -



php - Drupal 7 Default Node "View" Template -

i working on drupal 7.23. know if there way modify node template when viewed. not trying alter on main page or when searched tags or other means. trying alter view or display when node selected.

usually there 2 tabs node or content_type i.e "view" , "edit". need alter template "view". give thanks you.

zain

by default, drupal provides 2 display modes nodes: default , teaser. both these view modes rendered using node.tpl.php. either modify file fit needs or utilize hook_theme_suggestions() create separate tpl files different views.

php drupal-7

sorting - Does Python have a built in function for string natural sort? -



sorting - Does Python have a built in function for string natural sort? -

using python 3.x, have list of strings perform natural alphabetical sort.

natural sort: order files in windows sorted.

for instance, next list naturally sorted (what want):

['elm0', 'elm1', 'elm2', 'elm9', 'elm10', 'elm11', 'elm12', 'elm13']

and here's "sorted" version of above list (what have):

['elm11', 'elm12', 'elm2', 'elm0', 'elm1', 'elm10', 'elm13', 'elm9']

i'm looking sort function behaves first one.

there 3rd party library on pypi called natsort (full disclosure, package's author). case, can either of following:

>>> natsort import natsorted, ns >>> x = ['elm11', 'elm12', 'elm2', 'elm0', 'elm1', 'elm10', 'elm13', 'elm9'] >>> natsorted(x, key=lambda y: y.lower()) ['elm0', 'elm1', 'elm2', 'elm9', 'elm10', 'elm11', 'elm12', 'elm13'] >>> natsorted(x, alg=ns.ignorecase) # or alg=ns.ic ['elm0', 'elm1', 'elm2', 'elm9', 'elm10', 'elm11', 'elm12', 'elm13']

you should note natsort uses general algorithm should work input throw @ it.

if need sorting key instead of sorting function, utilize either of below formulas.

>>> natsort import natsort_keygen, ns >>> l1 = ['elm0', 'elm1', 'elm2', 'elm9', 'elm10', 'elm11', 'elm12', 'elm13'] >>> l2 = l1[:] >>> natsort_key1 = natsort_keygen(key=lambda y: y.lower()) >>> l1.sort(key=natsort_key1) >>> l1 ['elm0', 'elm1', 'elm2', 'elm9', 'elm10', 'elm11', 'elm12', 'elm13'] >>> natsort_key2 = natsort_keygen(alg=ns.ignorecase) >>> l2.sort(key=natsort_key2) >>> l2 ['elm0', 'elm1', 'elm2', 'elm9', 'elm10', 'elm11', 'elm12', 'elm13']

python sorting python-3.x

productivity power tools - Can you turn off Peek Definition in Visual Studio 2013? -



productivity power tools - Can you turn off Peek Definition in Visual Studio 2013? -

in visual studio 2013, there new peek definition feature when ctrl + click. @ first thought cool, have found bulk of time, need click promote document button, since create lots of changes files ctrl + click on. after googling how turn off peek definition, can't find details on if possible. ctrl + click functionality go opening definition in own tab, in previous versions of vs. possible?

tools→options→productivity powerfulness tools→other extensions→control click shows definitions in peek

visual-studio-2013 productivity-power-tools

go - failed to json.marshal map with non string keys -



go - failed to json.marshal map with non string keys -

i want convert map[int]string json, thought json.marshal() trick, fails saying unsupported type map[int]string. whereas if utilize map key string works fine.

http://play.golang.org/p/qhls9nt8qq

later on inspection of marshaller code, there explicit check see if key not string , returns unsupportedtypeerror...

why can't utilize primitives keys? if json standard doesn't allow non string keys, shouldn't json.marshal convert primitives string , utilize them keys ?

it's not because of go, because of json: json not back upwards else strings keys.

have grammar of json:

pair string : value string "" " chars "

the total grammar available on json website.

unfortunately, utilize integers keys, must convert them string beforehand, instance using strconv.itoa: not json bundle work.

json go

unix - How to merge two directorys in Clearcase? -



unix - How to merge two directorys in Clearcase? -

1 directory has 2 files: test1.c, test2.c 2 directory has 0 files

how can re-create test1.c sec directory, using "merge".

first, directory need same, in 2 different branches (or wouldn't talk of merging in case, duplicating files)

second, if merge directory between 2 version of said directory between 2 branches, end test1.c , test2.c... empty. because merging folder isn't enough: update list of files, not content of files within folder.

the easiest way recursively merge (the folder , inside) utilize command cleartool findmerge (for clearcase 7.x, before clearteam 8.x). see "clearcase: findmerge usage".

a merge always performed in destination view, go view select folder in right destination branch (and folder still empty):

cd /path/to/view/avob/yourfolder cleartool findmerge . -nc -fver .../sourcebranch/latest -merge

note: if using clearcase ucm, have set activity first, before launching merge.

before completing merge (ie before checking in everything), able remove (cleartool rmname test2.c) file don't want.

unix version-control clearcase

java - Creating >= 3 generation deep Test Folders -



java - Creating >= 3 generation deep Test Folders -

i drawing code user nickm's github located @ https://github.com/nmusaelian-rally/rally-java-rest-apps/blob/master/addtctotf.java

i needing create test folder hierarchy >= 3 generations deep(grandparent, parent, kid etc. example). code have additions below.

the java code works additions made code. still not creating 3 generation deep test folder set want(still creating 2 deep). can help point out , give examples of corrections can create code accomplish this? thanks

import java.io.ioexception; import java.net.uri; import java.net.urisyntaxexception; import com.google.gson.jsonobject; import com.rallydev.rest.rallyrestapi; import com.rallydev.rest.request.createrequest; import com.rallydev.rest.request.getrequest; import com.rallydev.rest.response.createresponse; import com.rallydev.rest.util.ref; import com.google.gson.jsonarray; import com.google.gson.jsonelement; import com.google.gson.jsonobject; import com.rallydev.rest.rallyrestapi; import com.rallydev.rest.request.createrequest; import com.rallydev.rest.request.getrequest; import com.rallydev.rest.request.queryrequest; import com.rallydev.rest.response.createresponse; import com.rallydev.rest.response.getresponse; import com.rallydev.rest.response.queryresponse; import com.rallydev.rest.util.fetch; import com.rallydev.rest.util.queryfilter; import com.rallydev.rest.util.ref; import java.io.ioexception; import java.net.uri; import java.net.urisyntaxexception; import java.text.simpledateformat; import java.util.date; public class testfoldertestcasecreation { // todo auto-generated constructor stub public static void main(string[] args) throws urisyntaxexception, ioexception { string host = "https://rally1.rallydev.com"; string username = "user@company.com"; string password = "secret"; string wsapiversion = "v2.0"; string projectref = "/project/xxxxx"; //string myworkspace = "/workspace/xxxxx"; string applicationname = "restexample_createtfandtc"; rallyrestapi restapi = new rallyrestapi( new uri(host), username, password); restapi.setwsapiversion(wsapiversion); restapi.setapplicationname(applicationname); seek { (int i=0; i<1; i++) { system.out.println("creating test folder..."); jsonobject newtf = new jsonobject(); newtf.addproperty("name", "grandparent"); newtf.addproperty("project", projectref); //created grandparent createrequest createrequest = new createrequest("testfolder", newtf); createresponse createresponse = restapi.create(createrequest); if (createresponse.wassuccessful()) { system.out.println(string.format("created %s", createresponse.getobject().get("_ref").getasstring())); string folderref = ref.getrelativeref(createresponse.getobject().get("_ref").getasstring()); system.out.println(string.format("\nreading testfolder %s...",folderref)); system.out.println("creating kid test folder..."); jsonobject newchildtf = new jsonobject(); newchildtf.addproperty("name", "parent"); newchildtf.addproperty("project", projectref); //newchildtf.addproperty("workspace", myworkspace); newchildtf.addproperty("parent", folderref); string folderref2 = ref.getrelativeref(createresponse.getobject().get("_ref").getasstring()); system.out.println(string.format("\nreading testfolder %s...",folderref2)); jsonobject newchildtf2 = new jsonobject(); newchildtf2.addproperty("name", "child"); newchildtf2.addproperty("project", projectref); newchildtf2.addproperty("parent", folderref2); //test folder2 createrequest createrequest2 = new createrequest("testfolder", newchildtf); createresponse createresponse2 = restapi.create(createrequest2); if (createresponse.wassuccessful()) { system.out.println(string.format("created %s", createresponse.getobject().get("_ref").getasstring())); string childfolderref = ref.getrelativeref(createresponse2.getobject().get("_ref").getasstring()); system.out.println(string.format("\nreading kid testfolder %s...",childfolderref)); //testcase system.out.println("creating test case..."); jsonobject newtc = new jsonobject(); newtc.addproperty("name", "tc via java"); newtc.addproperty("project", projectref); //newchildtf.addproperty("workspace", myworkspace); newtc.addproperty("testfolder", childfolderref); newtc.addproperty("method", "manual"); createrequest createrequest3 = new createrequest("testcase", newtc); createresponse createresponse3 = restapi.create(createrequest3); if (createresponse.wassuccessful()) { system.out.println(string.format("created %s", createresponse3.getobject().get("_ref").getasstring())); string testcaseref = ref.getrelativeref(createresponse3.getobject().get("_ref").getasstring()); system.out.println(string.format("\nreading testcase %s...",testcaseref)); } } } else { string[] createerrors; createerrors = createresponse.geterrors(); system.out.println("error!"); (int j=0; i<createerrors.length;j++) { system.out.println(createerrors[j]); } } } } { restapi.close(); } } }

i modified code create grandchild level test folder , add together test case it. see code in this github repo.

seek { //-----creating parent folder system.out.println("creating test folder..."); jsonobject newtf = new jsonobject(); newtf.addproperty("name", "parent tf via java"); newtf.addproperty("project", projectref); createrequest createrequest = new createrequest("testfolder", newtf); createresponse createresponse = restapi.create(createrequest); if (createresponse.wassuccessful()) { system.out.println(string.format("created %s", createresponse.getobject().get("_ref").getasstring())); //read test folder string folderref = ref.getrelativeref(createresponse.getobject().get("_ref").getasstring()); system.out.println(string.format("\nreading testfolder %s...",folderref)); system.out.println("creating kid test folder..."); jsonobject newchildtf = new jsonobject(); newchildtf.addproperty("name", "child tf via java"); newchildtf.addproperty("project", projectref); newchildtf.addproperty("parent", folderref); createrequest createrequest2 = new createrequest("testfolder", newchildtf); createresponse createresponse2 = restapi.create(createrequest2); if (createresponse2.wassuccessful()) { //----------------creating grandchild folder system.out.println(string.format("created %s", createresponse2.getobject().get("_ref").getasstring())); //read test folder string childfolderref = ref.getrelativeref(createresponse2.getobject().get("_ref").getasstring()); system.out.println(string.format("\nreading testfolder %s...",childfolderref)); system.out.println("creating grandchild test folder..."); jsonobject newgrandchildtf = new jsonobject(); newgrandchildtf.addproperty("name", "grandchild tf via java"); newgrandchildtf.addproperty("project", projectref); newgrandchildtf.addproperty("parent", childfolderref); createrequest createrequest3 = new createrequest("testfolder", newgrandchildtf); createresponse createresponse3 = restapi.create(createrequest3); //----------------creating test case if (createresponse.wassuccessful()) { system.out.println(string.format("created %s", createresponse.getobject().get("_ref").getasstring())); //read test folder string grandchildfolderref = ref.getrelativeref(createresponse3.getobject().get("_ref").getasstring()); system.out.println(string.format("\nreading kid testfolder %s...",grandchildfolderref)); system.out.println("creating test case..."); jsonobject newtc = new jsonobject(); newtc.addproperty("name", "tc via java"); newtc.addproperty("project", projectref); newtc.addproperty("testfolder", grandchildfolderref); newtc.addproperty("method", "manual"); createrequest createrequest4 = new createrequest("testcase", newtc); createresponse createresponse4 = restapi.create(createrequest4); if (createresponse.wassuccessful()) { system.out.println(string.format("created %s", createresponse4.getobject().get("_ref").getasstring())); //read test folder string testcaseref = ref.getrelativeref(createresponse4.getobject().get("_ref").getasstring()); system.out.println(string.format("\nreading testcase %s...",testcaseref)); } } } } else { string[] createerrors; createerrors = createresponse.geterrors(); system.out.println("error!"); (int j=0; j<createerrors.length;j++) { system.out.println(createerrors[j]); } } } { //release resources restapi.close(); }

java web-services rally