Sunday, 15 September 2013

jetty - Solaris KSSL and a Java web server -



jetty - Solaris KSSL and a Java web server -

i'm trying setup solaris kssl proxy (http://www.c0t0d0s0.org/archives/5575-less-known-solaris-features-kssl.html) frontend jetty web server.

i'm able create kssl work apache web server kssl redirects incoming ssl traffic port 443 apache web server listening on port 28080.

however same configuration not work when jetty listening on port 28080. verified kssl requests not reach jetty or @ to the lowest degree cannot see them in access log. furthermore if set simple java class listens on server socket, kssl cannot redirect requests it.

my question pre-requisites web server in order able requests kssl ?

best regards, lior

there 2 mutual gotchas when working kssl.

the first apache listening ip has same ksslcfg command. if have hear 123.123.123.123:28080 in httpd.conf file, must utilize ksslcfg command same ip. cannot have listening on (*) , list ip in ksslcfg, or hear on ip , leave out ip on ksslcfg. whatever netstat shows listening on port 28080 must match ip used in ksslcfg (or don't utilize ip listening on *)

the sec must operations in order:

ksslcfg restart apache

it doesn't not work if ksslcfg run without restarting apache afterward.

i've seen many people on web testing localhost in ksslcfg command. won't work unless had localhost hear ip in apache configuration.

java jetty solaris

deployment - Symfony2 + GitFlow + Capifony + Capistrano-ext -



deployment - Symfony2 + GitFlow + Capifony + Capistrano-ext -

i'm developing website using symfony2 , gitflow. have 2 external servers called 'development', 'staging' , 'production' , central git repository on github.

i'm looking utilize capifony to:

deploy 'develop' branch changes development server. deploy releases/hotfixes etc staging test deploy 'master' branch live 'production' server

i've been reading this page multistage deployment , far have installed capifony capistrano extension.

within /app/config/deploy.rb file have following:

set :stage_dir, 'app/config/deploy' # needed symfony2 require 'capistrano/ext/multistage' set :stages, %w(production staging development) set :application, "myapp" set :repository, "git@github.com:mycompany/#{application}.git" set :scm, :git set :keep_releases, 3

i've got separate /app/config/development.rb file following:

server 'server_ip - port number', :app, :web, :primary => true set :deploy_to, "/var/www/myapp/" #directory on server set :symfony_env_prod, "test"

however, if run cap development deploy error

the task `development' not exist

can explain 'task' refers to?

thanks

move require 'capistrano/ext/multistage' lastly line of deploy.rb or @ to the lowest degree move set :stages, %w(production staging development) before it.

symfony2 deployment capistrano git-flow capifony

sql - how to find employee who is absent continuously more than 10 days? -



sql - how to find employee who is absent continuously more than 10 days? -

i have table name att. has 2 columns: empid , date. date column contains dates employee present. need write query find if employee continuously absent more 10 days.

empid | date 101 | 1/1/2012 101 | 2/1/2012 101 | 7/1/2012 101 | 18/1/2012 101 | 21/1/2012 101 | 25/1/2012 101 | 30/1/2012 102 | 1/1/2012 102 | 2/1/2012 102 | 5/1/2012 102 | 9/1/2012 102 | 14/1/2012 102 | 19/1/2012 102 | 24/1/2012 102 | 25/1/2012 102 | 28/1/2012 102 | 29/1/2012 102 | 30/1/2012

the result should 101 here. how can done? please help.

if working sql server 2012, can utilize lead analytical function

with recordlist ( select empid, date fromdate, lead(date) on (partition empid order date asc) todate tablename ) select distinct empid recordlist datediff(d, fromdate ,todate) >= 10 sqlfiddle demo sqlfiddle demo (others)

other link(s)

datediff lead

update 1

with firstlist ( select empid, date, row_number() on (partition empid order date asc) rn tablename ) select distinct a.empid firstlist inner bring together firstlist b on a.rn + 1 = b.rn datediff (d, a.date , b.date ) >= 10 sqlfiddle demo

sql sql-server tsql sql-server-2005

security - SocketException in a Signed Java Applet -



security - SocketException in a Signed Java Applet -

i have java applet using apache commons.net api ftp. ran applet without signing it, , threw

socketexception : software caused connection abort

i looked online , found firewall blocking applet. so, confirm this, disabled firewall , ran applet. worked fine.

then, followed instructions given in site self-sign applet using nnetbeans:

project properties -> enable web start -> self-sign using generated key

still, same error persists. can't find explains particular error.

java security ftp firewall signed-applet

Using gcc -c to generate .o files -



Using gcc -c to generate .o files -

so had create bit of code create list , various things it. print it, sort it, , see if value in it. did that, ran fine. i've got take functions , split them separate files, utilize gcc -c (which i'm not super sure i'm using correctly) .o files, plus .o test program. have utilize gcc link .o files executable. prompt says recognize .o's , realize how link them.

so here questions: why below code returning errors( in ways defined below)? , supposed writing command line link these guys?

so code follows: (first .h files, main .c file)

node.h

typedef struct node{ int data; struct node *next; struct node *prev; }node;

print.h

#include<stdio.h> #include"node.h" void print(node *pointer){ if (pointer == null){ return; } printf("%d ",pointer->data); print(pointer->next); }

init.h

#include<stdio.h> #include"node.h" int init(node *pointer,int find){ pointer = pointer->next; while (pointer != null){ if (pointer->data == find)//found find { printf("the info in list."); homecoming 1; } pointer = pointer->next;// search in next node. } //find not found printf("the info not in list."); homecoming 0; }

sort.h

#include<stdio.h> #include"node.h" void swap (node *x, node *y){ int temp = x->data; x->data = y->data; y->data = temp; } void sort(node*pointer){ int i; while (pointer->next != null){ if (pointer->data>pointer->next->data){ swap(pointer,pointer->next); } pointer = pointer->next; sort(pointer); } }

list.c

#include<stdio.h> #include<stdlib.h> #include"node.h" #lnclude"print.h" #include"sort.h" #include"init.h" int i; node *p; node *n; void insert(node *pointer, int data){ //go through list till ya find lastly node while (pointer->next != null){ pointer = pointer->next; } //allocate memory new node , set info in pointer->next = (node *)malloc(sizeof(node)); (pointer->next)->prev = pointer; pointer = pointer->next; pointer->data = data; pointer->next = null; } int main(){ //start used point first node //temp lastly node node *start, *temp; int z; start = (node *)malloc(sizeof(node)); temp = new; temp->next = null; temp->prev = null; (z = 0; z < 10; z++){ insert(start,(3*10) - z); } init(start,12); init(start,3); init(start,27); init(start,7); print(start); sort(start); print(start); }

now code ran fine when together, exception of node.h (that separate file). .h files compile perfectly, when seek compile .c file returns errors claiming trying redefine node in each .h file. because including in each .h file?

i getting errors trying pass inappropriate arguments init function, not seem case. might on looking things.

thank in advance help.

edit: changed variable in main new start errors when typing "gcc list.c"

in file included init.h:2:0, list.c:4: node.h:1:16 error: redefinition of'struct node' node.h:1:16 note: defined here node.h:5:2 error: conflicting types 'node' node.h:5:2 note: previous declaration of 'node' here in file included sort.h:2:0; list.c:5: node.h:1:16 error: redefinition of'struct node' node.h:1:16 note: defined here node.h:5:2 error: conflicting types 'node' node.h:5:2 note: previous declaration of 'node' here list.c: in function 'main': list.c:41:1: warning: passing argument 1 of 'init' incompatible pointer type[enabled default] init.h:4:5: note: expected 'struct node *' argument of type 'struct node *'

(and there errors each of separate init calls in main)

list.c:45:1: warning:passing argument 1 of 'print' incompatible pointer type [enabled default] print.h:3:6: note expected 'struct node *' argument of type 'struct node *'

(and there 1 sec print function)

put inclusion barriers in .h files. eg, sort.h

#ifndef include_sort_h #define include_sort_h // contents of file #endif

edit

actually looked @ code more closely. have defined functions in .h files not thing do. see no reason separate separate files @ all.

so combine them single file , compile with:

gcc -o list -wall list.c

if want separate files, set functions c files , construction , prototypes .h file (which include each c file). compile , link using like:

gcc -o list -wall list.c node.c main.c

c gcc linked-list

how to store a byte [] into a single variable in android/java -



how to store a byte [] into a single variable in android/java -

i have string str = "admin:admin"

i want convert in ascii.

i have tried str.getbyte("us-ascii"); returning me byte[] array (i.e [97, 100, 109, 105, 110, 58, 97, 100, 109, 105, 110]). want ascii value in single string variable. how can this.

simple want string strascii = "971001091051105897100109105110"

is possible?

i tried this

stringbuilder builder = new stringbuilder(); (int i=0; i<=b.length; i++) { builder.append(b); } string result = builder.tostring();

but returning me this

[b@405666e0[b@405666e0[b@405666e0[b@405666e0[b@405666e0[b@405666e0[b@405666e0[b@405666e0[b@405666e0[b@405666e0[b@405666e0[b@405666e0

what this?

try looping stringbuilder:

stringbuilder builder = new stringbuilder(); (byte b : arr) { builder.append(b); } string result = builder.tostring();

you could, of course, same thing string concatenation, using stringbuilder explicitly faster lots of little appends.

java android type-conversion bytearray

ASP.Net MVC4 with Razor - Best and correct way to acces controler methods in views -



ASP.Net MVC4 with Razor - Best and correct way to acces controler methods in views -

i have been working asp.net new asp.net mvc 4 razor concept. question might basic appreciate every help couldn't find definite reply days (or looking wrong things). question is: how access controller method within view without using index method?

the scenario:

i have database store values date, cost etc ... (variables defined in model.

i have controller thats sets view index

i have view shows indexpage values of info base.

i want sum values of cost colum dont want store result in db. in understanding access db via method in controller class , phone call method in view.

to larn step step defined fixed value in controller see how show value in view.

the code:

model: [range(1, 100)] [datatype(datatype.currency)] public decimal cost { get; set; } // amount of entry controller: public actionresult index() { homecoming view(db.amounts.tolist()); } public actionresult showsumofallprices() { //for testing db not called yet. query must defined , result written variable within mehod viewbag.price = 2; homecoming view(); } view: @*testmethod displaying sumprize (first wit test result) via controler*@ <table> <tr> <td>hallo @viewbag.price</td> </tr> </table>

the result not shown long don't define method content of showsumofallprices() (in controller class) in index() method.

the question is: result of method in view visible if define within index() method in controller or can write method did , phone call in view? working if c&p logic of showsumofallprices() index(). don't think need define in index method. if so, big , fat method. far see there 3 possible ways not might "nice" or working:

define in index() method. define other methods phone call them in index method because way display within view , not using model because dont want store info in db i can define other methods , straight phone call them in view without having new page result of method shown under content of currend index page.

i hope question understandable , question not asked mine before.

define in index() method.

controllers not meant hold logic.

define other methods phone call them in index method because way display within view , not using model because dont want store info in db

don't define other methods in controller itself. create other classes , phone call methods in index() or suitable controller method. , if want display info in view , model best choice, can store info in viewbag

i can define other methods , straight phone call them in view without having new page result of method shown under content of current index page.

if want fetch result of methods in same view can case[might using same kind of ajax] if want render other page , might bad idea.

the best thing can declare class required function single responsibility principle , utilize class operation in method want have results in.you can access controller methods using ajax , jquery, google out bit , own.

hope helps.

razor asp.net-mvc-4

What does this x86 assembly language code with IO ports 0x61 and 0x20 do? -



What does this x86 assembly language code with IO ports 0x61 and 0x20 do? -

this code:

push ax in al, 0x61 or al, 0x80 ; 10000000b out 0x61, al , al, 0x7f ; 01111111b out 0x61, al mov al, 0x20 out 0x20, al pop ax

what do? know connected timer interrupt. what's on 0x61 , 0x20?

there in al, 0x60 instruction close by.

ports 0x60 , 0x61 talk keyboard controller in pc. port 0x60 contains key pressed, , 0x61 has status bits.

toggling high bit of status port signals have gotten key , want next one.

port 0x20 interrupt controller, acknowledge have processed interrupt.

assembly x86 interrupt

c# - Gridview in Modal Popup Extender- Postback Issues? -



c# - Gridview in Modal Popup Extender- Postback Issues? -

i have c# .net application gridview within ajax modal popup (vs2008). have grid view set homecoming 10 records per page paging enabled.

when user clicks alter page within gridview there postback closes modal window , opens 1 time again using modalpopup.show();

is there way avoid postback of whole page , postback gridview whilst keeping modal window active? @ moment postback of whole page gives impression of flicker...

<asp:panel id="panel1" runat="server" font-italic="true" font-names="times new roman" font-size="small" forecolor="#82b8de"> <asp:gridview id="gridview1" runat="server" autogeneratecolumns="false" cellpadding="4" forecolor="#333333" gridlines="none" onpageindexchanging="gridview1_pageindexchanging" onrowdatabound="gridview1_rowdatabound" onselectedindexchanged="gridview1_selectedindexchanged" selectedindex="0" showheader="false" width="700px" controlid="gridview1" eventname="pageindexchanging" font-italic="true" font-names="times new roman" font-size="medium"> <pagersettings pagebuttoncount="12" /> <rowstyle cssclass="rowstyle" backcolor="#eff3fb" font-italic="true" font-names="times new roman" font-size="small" forecolor="#82b8de" /> <columns> <asp:boundfield datafield="address" readonly="true"> <itemstyle width="385px" /> </asp:boundfield> <asp:boundfield datafield="xcoord" readonly="true" showheader="false" > <itemstyle cssclass="hidden" /> </asp:boundfield> <asp:boundfield datafield="ycoord" readonly="true" showheader="false" > <itemstyle cssclass="hidden" /> </asp:boundfield> </columns> <footerstyle cssclass="footerstyle" backcolor="#507cd1" font-bold="true" forecolor="white" /> <pagerstyle backcolor="#2461bf" forecolor="white" horizontalalign="center" /> <selectedrowstyle cssclass="selectedrowstyle" backcolor="#d1ddf1" font-bold="true" forecolor="#333333" /> <headerstyle cssclass="headerstyle" backcolor="#507cd1" font-bold="true" forecolor="white" /> <editrowstyle backcolor="#2461bf" font-italic="true" font-names="times new roman" font-size="medium" /> <alternatingrowstyle backcolor="white" /> </asp:gridview> </asp:panel> <ajax:modalpopupextender id="modalpopupextender1" runat="server" popupcontrolid="panel1" targetcontrolid="dummy" backgroundcssclass="modalbackgroundgrid" behaviorid="modalgrid"> </ajax:modalpopupextender>

and code behind...

public void page_load(object sender, eventargs e) { seek { if (!(page.ispostback)) { gridview1.enableviewstate = true; gridview1.allowpaging = true; gridview1.pagesize = 10; gridview1.pagersettings.mode = pagerbuttons.numeric; gridview1.visible = true; } if (!m_bdisclaimershown) { m_bdisclaimershown = true; mpe1.show(); tabcontainer.visible = true; scalebar1.visible = true; } } grab (exception ex) { showmsg("error - " + ex.message); } } protected void btnhide_click(object sender, eventargs e) { mpe1.hide(); tabcontainer.visible = true; scalebar1.visible = true; } protected void cmdzoomaddress_click(object sender, eventargs e) { seek { if (txtpostcode.text.length >= 7 && opendb()) { string strpostcode = txtpostcode.text; strpostcode = strpostcode.substring(0, 4) + strpostcode.substring(strpostcode.length - 3, 3); sqlcommand sqlcmd = new sqlcommand(); sqlcmd.connection = m_sqlconn; sqlcmd.commandtype = system.data.commandtype.storedprocedure; sqlcmd.commandtext = "sde.dbo.sp_seladdressbypostcode"; sqlcmd.parameters.add("@postcode", sqldbtype.varchar); sqlcmd.parameters["@postcode"].value = strpostcode; sqldataadapter sqladapter = new sqldataadapter(sqlcmd); m_sqldatatable = new datatable(); sqladapter.fill(m_sqldatatable); gridview1.datasource = m_sqldatatable; gridview1.databind(); gridview1.visible = true; modalpopupextender1.show(); } else { showmsg("error - no postal addresses returned"); } } grab (exception ex) { showmsg("error - " + ex.message); } { closedb(); } } protected void gridview1_pageindexchanging(object sender, gridviewpageeventargs e) { if (sender != null) { gridview1.pageindex = e.newpageindex; gridview1.datasource = m_sqldatatable; gridview1.databind(); modalpopupextender1.show(); } } protected void gridview1_selectedindexchanged(object sender, eventargs e) { gridviewrow gvrow = gridview1.selectedrow; int ix = (int)convert.tosingle(gvrow.cells[1].text); int iy = (int)convert.tosingle(gvrow.cells[2].text); gridview1.visible = false; movemap(ix, iy); } public void gridview1_rowdatabound(object sender, gridviewroweventargs e) { if (e.row.dataitemindex >= 0) { e.row.attributes["style"] = "cursor:pointer"; e.row.attributes.add("onmouseover", "this.style.cursor='hand';"); e.row.attributes.add("onclick", clientscript.getpostbackeventreference(gridview1, "select$" + e.row.rowindex.tostring())); } } protected override void render(htmltextwriter writer) { foreach (gridviewrow r in gridview1.rows) { if (r.rowtype == datacontrolrowtype.datarow) { page.clientscript.registerforeventvalidation(gridview1.uniqueid, "select$" + r.rowindex); } } base.render(writer); }

thanks suggestion. i've set gridview a...

<asp:updatepanel> <contenttemplate>

the modal stays when click record in grid view doesn't close!

c# asp.net html ajax

java - Clojure Performance For Expensive Algorithms -



java - Clojure Performance For Expensive Algorithms -

i have implemented algorithm calculate longest contiguous mutual subsequence (not confused longest mutual subsequence, though not of import questions). need squeeze maximum performance because i'll calling lot. have implemented same algorithm in clojure , java in order compare performance. java version runs faster. my question whether there can clojure version speed level of java.

here's java code:

public static int lcs(string[] a1, string[] a2) { if (a1 == null || a2 == null) { homecoming 0; } int matchlen = 0; int maxlen = 0; int a1len = a1.length; int a2len = a2.length; int[] prev = new int[a2len + 1]; // holds info previous iteration of inner loop int[] curr = new int[a2len + 1]; // used 'current' iteration of inner loop (int = 0; < a1len; ++i) { (int j = 0; j < a2len; ++j) { if (a1[i].equals(a2[j])) { matchlen = prev[j] + 1; // curr , prev padded 1 allow assignment when j=0 } else { matchlen = 0; } curr[j+1] = matchlen; if (matchlen > maxlen) { maxlen = matchlen; } } int[] swap = prev; prev = curr; curr = swap; } homecoming maxlen; }

here clojure version of same:

(defn lcs [#^"[ljava.lang.string;" a1 #^"[ljava.lang.string;" a2] (let [a1-len (alength a1) a2-len (alength a2) prev (int-array (inc a2-len)) curr (int-array (inc a2-len))] (loop [i 0 max-len 0 prev prev curr curr] (if (< a1-len) (recur (inc i) (loop [j 0 max-len max-len] (if (< j a2-len) (if (= (aget a1 i) (aget a2 j)) (let [match-len (inc (aget prev j))] (do (aset-int curr (inc j) match-len) (recur (inc j) (max max-len match-len)))) (do (aset-int curr (inc j) 0) (recur (inc j) max-len))) max-len)) curr prev) max-len))))

now let's test these on machine:

(def pool "abc") (defn get-random-id [n] (apply str (repeatedly n #(rand-nth pool)))) (def a1 (into-array (take 10000 (repeatedly #(get-random-id 5))))) (def a2 (into-array (take 10000 (repeatedly #(get-random-id 5)))))

java:

(time (ratcliff/lcs a1 a2)) "elapsed time: 1521.455 msecs"

clojure:

(time (lcs a1 a2)) "elapsed time: 19863.633 msecs"

clojure quick still order of magnitude slower java. there can close gap? or have maxed out , 1 order of magnitude "minimal clojure overhead."

as can see using "low level" build of loop, using native java arrays , have type-hinted parameters avoid reflection.

there algorithm optimizations possible, don't want go there right now. curious how close java performance can get. if can't close gap i'll go java code. rest of project in clojure, perhaps dropping downwards java performance necessary.

edit: added faster uglier version below first one.

here take:

(defn my-lcs [^objects a1 ^objects a2] (first (let [n (inc (alength a1))] (areduce a1 [max-len ^ints prev ^ints curr] [0 (int-array n) (int-array n)] [(areduce a2 j max-len (unchecked-long max-len) (let [match-len (if (.equals (aget a1 i) (aget a2 j)) (unchecked-inc (aget prev j)) 0)] (aset curr (unchecked-inc j) match-len) (if (> match-len max-len) match-len max-len))) curr prev]))))

main differences yours: a[gs]et vs a[gs]et-int, utilize of unchecked- ops (implicitly through areduce), utilize of vector homecoming value (and "swap" mechanism) , max-len coerced primitive before inner loop (primitive-valued loops problematic, less since 1.5rc2 back upwards isn't perfect yet, *warn-on-reflection* not silent).

and switched .equals instead of = avoid logic in clojure's equiv.

edit: let's ugly , restore arrays swap trick:

(deftype f [^:unsynchronized-mutable ^ints curr ^:unsynchronized-mutable ^ints prev] clojure.lang.ifn (invoke [_ a1 a2] (let [^objects a1 a1 ^objects a2 a2] (areduce a1 max-len 0 (let [m (areduce a2 j max-len (unchecked-long max-len) (let [match-len (if (.equals (aget a1 i) (aget a2 j)) (unchecked-inc (aget prev j)) 0)] (aset curr (unchecked-inc j) (unchecked-int match-len)) (if (> match-len max-len) match-len max-len))) bak curr] (set! curr prev) (set! prev bak) m))))) (defn my-lcs2 [^objects a1 a2] (let [n (inc (alength a1)) f (f. (int-array n) (int-array n))] (f a1 a2)))

on box, it's 30% faster.

java performance clojure

jQuery: Selecting the inner html of an elemnt with a specific value and assign it to a variable? -



jQuery: Selecting the inner html of an elemnt with a specific value and assign it to a variable? -

i have code:

<dl class="item-options"> <dt>dt1</dt> <dd>dd1</dd> <dt>dt2</dt> <dd>ss2</dd> </dl>

now want access dt1 content , assign value dd1 it. iterating on dds in each loop, each dd access, want content matching dt.

any ideas how that?

thanks!

try:

var = $(".item-options dt").first().text());

http://jsfiddle.net/hyskp/

if dt1 isn't first element, loop on each dt:

$("dt").each(function(e) { var dt = $(this).text(); if (dt == "dt1") { // logic } });

http://jsfiddle.net/xerbm/

jquery

javascript - Template engine for node.js -



javascript - Template engine for node.js -

i know best template engine node.js. i'm using jade engine node.js.

the confusion arise after reading

https://github.com/baryshev/template-benchmark

please suggest me best

thanks.

there no best view engine. criteria best view engine based on actual needs template engine has realize , person(s) using it. lot of people love jade view engine, example, there many not consider because not syntax. priorities should follow simple:

syntax: syntax view engine has you? features: view engine have want (e.g. includes, variables, filters)? learning: hard learn? if have designers, understand it? tooling? community: there community, or reachable, can help problems? performance: view engine compile , cache? if not, really matter?

note view engines automatically fall compilation , caching when run node in production mode (node_env=production) should check out different flavours of view engines , decide on best according criteria of project (e.g. jade, handlebars, ejs, gaikan).

update: looked @ benchmarks , decided merge own view engine (gaikan). fork can seen @ address https://github.com/deathspike/template-benchmark including results. if performance, adds valuable option, recommend stick priorities listed above.

javascript performance node.js

java - Sending POST to servlet with data -



java - Sending POST to servlet with data -

i have used curl submit post request web application written in java using gwt/smartgwt , smartclient. curl command follows:

`curl -v --header "content-type: application/x-www-form-urlencoded; charset=utf-8" --header "custom-userid: ghettosamson-curl1" -d respheaders1.txt -o response-1.txt --data _transaction=%3ctransaction%20xmlns%3axsi%3d%22http%3a%2f%2fwww.w3.org%2f2000%2f10%2fxmlschema-instance%22%20xsi%3atype%3d%22xsd%3aobject%22%3e%3ctransactionnum%20xsi%3atype%3d%22xsd%3along%22%3e16%3c%2ftransactionnum%3e%3coperations%20xsi%3atype%3d%22xsd%3alist%22%3e%3celem%20xsi%3atype%3d%22xsd%3aobject%22%3e%3cappid%3emyapplication%3c%2fappid%3e%3cclassname%3emyservlet%3c%2fclassname%3e%3cmethodname%3emymethodname%3c%2fmethodname%3e%3carguments%20xsi%3atype%3d%22xsd%3alist%22%3e%3celem%3emydatasource%3c%2felem%3e%3celem%3ebirttemplate.rptdesign%3c%2felem%3e%3celem%3ereporttype%3c%2felem%3e%3celem%3ereporttype%20data%20set%3c%2felem%3e%3celem%3e1%3c%2felem%3e%3celem%3e%3c%2felem%3e%3celem%3eghettosamson%20curl%20report%3c%2felem%3e%3celem%3estart_timestamp%20is%20not%20null%20and%20\(start_timestamp%20%26lt%3b%3d%20to_date\(%26apos%3b2013-01-04%2023%3a59%3a00%26apos%3b%2c%26apos%3byyyy-mm-dd%20hh24%3ami%3ass%26apos%3b\)%20or%20start_timestamp%20is%20null\)\)\)\)%0a%20%20%20%20%09%09%3c%2felem%3e%3celem%3e%3c%2felem%3e%3c%2farguments%3e%3cis_isc_rpc_dmi%20xsi%3atype%3d%22xsd%3aboolean%22%3etrue%3c%2fis_isc_rpc_dmi%3e%3c%2felem%3e%3c%2foperations%3e%3c%2ftransaction%3e --data isc_tnum=10 --data protocolversion=1.0 myipaddress:myport/myapplication/myapplication/sc/idacall?isc_rpc=1&isc_v=v8.2p_2012-08-28&isc_xhr=1 &`

the response received written file , follows:

`<html> <body onload='var results = document.formresults.results.value;null'><br> <br><br><br> <br><br><br><br><br><br><br><br><br><br><br><br><br><br> <form name='formresults'><textarea readonly name='results'> //isc_rpcresponsestart-->[{status:0,data:"http://myipaddress:myport/myapplication /reports/ghettosamson-curl1.pdf"}]//isc_rpcresponseend</textarea></form> </body></html>`

i trying duplicate request java , have run testng test. have tried several different examples here , nil works. here code examples try:

`@autowired @qualifier("contentheader") private header thecontentheader; @autowired @qualifier("userheader") private header theuserheader; @autowired @qualifier("transactionpair") private namevaluepair thetransactionpair; @autowired @qualifier("iscpair") private namevaluepair theiscpair; @autowired @qualifier("protocolpair") private namevaluepair theprotocolpair; @test public void testconcurrentcreateandopenreportrequests() throws clientprotocolexception, ioexception { assert.notnull(thetestpost); assert.notnull(thecontentheader); assert.notnull(theuserheader); assert.notnull(thetransactionpair); httpclient httpclient = new defaulthttpclient(); thetestpost.addheader(thecontentheader); thetestpost.addheader(theuserheader); arraylist<basicnamevaluepair> parameters = new arraylist<basicnamevaluepair>(); parameters.add(thetransactionpair); parameters.add(new basicnamevaluepair("isc_tnum", "10")); parameters.add(new basicnamevaluepair("protocolversion", "1.0")); thetestpost.setentity(new urlencodedformentity(parameters, "utf-8")); httpresponse response = httpclient.execute(thetestpost); httpentity entity = response.getentity(); assert.notnull(entity); inputstream instream = entity.getcontent(); system.out.println(instream.tostring()); instream.close(); } @test public void testsimplepost() throws httpexception, ioexception { httpclient client = new httpclient(); postmethod method = new postmethod("http://myipaddress:myport/ myapplication/myapplication/sc/idacall?isc_rpc=1&isc_v=v8.2p_2012-08-28& isc_xhr=1"); method.addrequestheader(thecontentheader); method.addrequestheader(theuserheader); method.addparameter(thetransactionpair); method.addparameter("isc_tnum", "10"); method.addparameter("protocolversion", "1.0"); int statuscode = client.executemethod(method); if (statuscode != -1) { inputstream instream = method.getresponsebodyasstream(); system.out.println(instream); } } @test public void testanomalypost() throws ioexception { string urlparameters = string.format("%s=%s&%s=%s&%s=%s", thetransactionpair.getname(), thetransactionpair.getvalue(), theiscpair.getname(), theiscpair.getvalue(), theprotocolpair.getname(), theprotocolpair.getvalue()); string request = "http://myipaddress:myport/myapplication/ myapplication/sc/idacall?isc_rpc=1&isc_v=v8.2p_2012-08-28&isc_xhr=1"; url url = new url(request); httpurlconnection connection = (httpurlconnection) url.openconnection(); connection.setdooutput(true); connection.setdoinput(true); connection.setinstancefollowredirects(false); connection.setrequestmethod("post"); connection.setrequestproperty("content-type", "application/x-www-form-urlencoded; charset=utf-8"); connection.setrequestproperty("custom-userid", "ghettosamson-testng"); connection.setusecaches (false); dataoutputstream wr = new dataoutputstream(connection.getoutputstream ()); wr.writebytes(urlparameters); wr.flush(); wr.close(); connection.disconnect(); }`

java servlets testng smartgwt smartclient

c# - How to connect a Button to the Checkboxes in a GridView, and delete the selected rows from the GridView(ticked via CheckBoxes integrated in GridView)? -



c# - How to connect a Button to the Checkboxes in a GridView, and delete the selected rows from the GridView(ticked via CheckBoxes integrated in GridView)? -

i have created gridview containing info extracted textbox. have "delete link" on gridview delete row gridview if required.

now want create changes it. instead of "delete link" on gridview, want checkboxes on each row of gridview. outside gridview, there should button. on clicking button, rows selected via checkbox on gridview should deleted.

what changes has made below code implement functionality? please specify changes clearly.

default.aspx

<%@ page language="c#" autoeventwireup="true" codefile="default.aspx.cs" inherits="_default" %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <br /> employee id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:textbox id="textbox1" runat="server"></asp:textbox> <br /> <br /> employee name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:textbox id="textbox2" runat="server"></asp:textbox> <br /> <br /> salary&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:textbox id="textbox3" runat="server"></asp:textbox> <br /> <br /> <br /> <asp:button id="button1" runat="server" text="add grid" onclick="button1_click" /> <br /> <br /> <br /> <br /> <br /> <asp:button id="button2" runat="server" text="export info database" onclick="button2_click" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> <br /> <asp:label id="label1" runat="server"></asp:label> <br /> <br /> <asp:gridview id="gridview1" runat="server" datakeynames="empid" autogeneratecolumns="false" onrowediting="gridview1_rowediting" onrowcancelingedit="gridview1_rowcancelingedit" onrowdeleting="gridview1_rowdeleting" onpageindexchanging="gridview1_pageindexchanging" pagesize="5" allowpaging="true" onrowupdating="gridview1_rowupdating" width="800"> <columns> <asp:templatefield headertext="employee id"> <itemtemplate> <%#eval("empid")%> </itemtemplate> </asp:templatefield> <asp:templatefield headertext="employee name"> <itemtemplate> <%#eval("empname")%> </itemtemplate> <edititemtemplate> <asp:textbox id="txtempname" runat="server" text='<%#eval("empname") %>'></asp:textbox> </edititemtemplate> </asp:templatefield> <asp:templatefield headertext="salary"> <itemtemplate> <%#eval("empsalary")%> </itemtemplate> <edititemtemplate> <asp:textbox id="txtempsalary" runat="server" text='<%#eval("empsalary") %>'></asp:textbox> </edititemtemplate> </asp:templatefield> <asp:commandfield headertext="modify" showeditbutton="true" edittext="edit"> <controlstyle width="50" /> </asp:commandfield> <asp:templatefield headertext="delete"> <itemtemplate> <asp:linkbutton id="lnkdelete" commandname="delete" runat="server" onclientclick="return confirm('are sure want delete these records?');">delete</asp:linkbutton> </itemtemplate> </asp:templatefield> </columns> </asp:gridview> </div> <p style="width: 799px"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:button id="button3" runat="server" onclick="button3_click" text="delete checked items" width="162px" /> </p> <p> &nbsp;</p> <p> &nbsp;</p> <p> <asp:gridview id="gridview2" runat="server" backcolor="white" bordercolor="black" borderstyle="solid" borderwidth="1px" cellpadding="3" width="580px"> <pagerstyle horizontalalign="left" /> </asp:gridview> </p> </form> <p> &nbsp;</p> </body> </html>

sample.aspx.cs

using system; using system.collections; using system.collections.generic; using system.configuration; using system.web; using system.web.security; using system.web.ui; using system.web.ui.htmlcontrols; using system.web.ui.webcontrols; using system.web.ui.webcontrols.webparts; using system.linq; using system.xml.linq; using system.data; using system.data.sqlclient; public partial class _default : system.web.ui.page { sqlconnection sqlcon = new sqlconnection(configurationmanager.appsettings["constring"]); sqlcommand sqlcmd = new sqlcommand(); sqldataadapter da = new sqldataadapter(); datatable dt = new datatable(); datatable dt1 = new datatable(); datarow dr; datarow dr1; dataset ds = new dataset(); protected void page_load(object sender, eventargs e) { label1.text = ""; //lbldbmsg.text = ""; if (!page.ispostback) { dt.columns.add("empid"); dt.columns.add("empname"); dt.columns.add("empsalary"); session["reptable"] = dt; griddata(); } } protected void gridview1_rowediting(object sender, gridviewediteventargs e) { gridview1.editindex = e.neweditindex; griddata(); } void griddata() { gridview1.datasource = (datatable)session["reptable"]; gridview1.databind(); } protected void gridview1_rowcancelingedit(object sender, gridviewcancelediteventargs e) { gridview1.editindex = -1; griddata(); } protected void gridview1_rowupdating(object sender, gridviewupdateeventargs e) { gridviewrow row = gridview1.rows[e.rowindex]; string empid; empid = gridview1.datakeys[e.rowindex].value.tostring(); textbox empname = (textbox)row.findcontrol("txtempname"); textbox empsalary = (textbox)row.findcontrol("txtempsalary"); if (session["reptable"] != null) { datatable dt1 = new datatable(); dt1.clear(); dt1 = session["reptable"] datatable; (int = 0; <= dt1.rows.count - 1; i++) { datarow dr; if (dt1.rows[i][0].tostring() == empid) { dr = dt1.rows[i]; dt1.rows[i].delete(); } } session.remove("reptable"); session["reptable"] = dt1; //add updated row here dt = (datatable)session["reptable"]; dr1 = dt.newrow(); dr1["empid"] = empid; dr1["empname"] = empname.text; dr1["empsalary"] = empsalary.text; dt.rows.add(dr1); session.remove("reptable"); session["reptable"] = dt; } gridview1.editindex = -1; griddata(); } protected void gridview1_rowdeleting(object sender, gridviewdeleteeventargs e) { string empid; empid = gridview1.datakeys[e.rowindex].value.tostring(); if (session["reptable"] != null) { datatable dt1 = new datatable(); dt1.clear(); dt1 = session["reptable"] datatable; (int = 0; <= dt1.rows.count - 1; i++) { datarow dr; if (dt1.rows[i][0].tostring() == empid) { dr = dt1.rows[i]; dt1.rows[i].delete(); //dt1.rows.remove(dr); } } session.remove("reptable"); session["reptable"] = dt1; } griddata(); } protected void gridview1_pageindexchanging(object sender, gridviewpageeventargs e) { gridview1.pageindex = e.newpageindex; griddata(); } protected void button1_click(object sender, eventargs e) { dt = (datatable)session["reptable"]; dr = dt.newrow(); dr["empid"] = textbox1.text; dr["empname"] = textbox2.text; dr["empsalary"] = textbox3.text; dt.rows.add(dr); session.remove("reptable"); session["reptable"] = dt; griddata(); textbox1.text = ""; textbox2.text = ""; textbox3.text = ""; } //bulk insert info sql server database protected void button2_click(object sender, eventargs e) { dt = (datatable)session["reptable"]; //upload info database using mass re-create sqlbulkcopy sqlbulk = new sqlbulkcopy(configurationmanager.appsettings["constring"]); sqlbulk.destinationtablename = "emp"; //table name sqlbulk.writetoserver(dt); //remove info after insert dt.clear(); session["reptable"] = dt; griddata(); label1.text = "all records inserted database"; } protected void button3_click(object sender, eventargs e) { } }

try this..

aspx code:

add checkbox command in item template of gridview..

<asp:templatefield> <itemtemplate> <asp:checkbox id="chkdelete" runat="server" /> </itemtemplate> </asp:templatefield>

c# code:

protected void button3_click(object sender, eventargs e) { foreach (gridviewrow gvrow in gridview1.rows) { //finiding checkbox command in gridview particular row checkbox chkdelete = (checkbox)gvrow.findcontrol("chkdelete"); //condition check checkbox selected or not if (chkdelete.checked) { if (session["reptable"] != null) { string empid = gridview1.datakeys[gvrow.rowindex].value.tostring(); datatable dt1 = new datatable(); dt1.clear(); dt1 = session["reptable"] datatable; (int = 0; <= dt1.rows.count - 1; i++) { datarow dr; if (dt1.rows[i][0].tostring() == empid) { dr = dt1.rows[i]; dt1.rows[i].delete(); //dt1.rows.remove(dr); } } //session.remove("reptable"); session["reptable"] = dt1; } } } griddata(); }

c# asp.net button gridview datatable

restricting sed command -



restricting sed command -

i have variables needs modified minutes %m added. know sed command , working expected.

# cat mysed.txt myfirstfile="comany$mydb`date +'%d-%b-%y-%h'`.sql" # sed -i 's/\%h/\%h-\%m/' mysed.txt # cat mysed.txt myfirstfile="company$mydb`date +'%d-%b-%y-%h-%m'`.sql"

but if run same sed command again, add together %m 1 time again follows.

# sed -i 's/\%h/\%h-\%m/' mysed.txt # cat mysed.txt myfirstfile="company$mydb`date +'%d-%b-%y-%h-%m-%m'`.sql"

i need sed command should add together minutes %m 1 time if sed command executed twice (by mistake)

# sed -i "s/%h'/%h-%m'/" mysed.txt

this should work. way replacement if there quote mark next %h.

sed

C# change formatting for a single DateTime -



C# change formatting for a single DateTime -

i creating datetimes used 3rd party library (on have of course of study no control). using 3rd party library write files, including datetimes creating.

i print dates in different format have no command on how datetime converted 3rd party , cannot alter civilization info between conversion of each datetime, neither can inherit datetime override tostring (like no 1 can).

is there way bind specific formatting datetime each phone call tostring method utilize formatting ?

datetime firstdate = new datetime(2013, 02, 07); //i datetime printed way: 2013-02-07 datetime seconddate = new datetime(2013, 02, 07); //i datetime printed way: thursday, feb 07, 2013 thirdpartylib.setfirstdate(firstdate); thirdpartylib.setseconddate(seconddate); thirdpartylib.printbothdate(); //this method convert both datetime in strings

with info given in question, way solve implementing own printing library.

or if 3rd party library extendable (i uncertainty since mentioned have no command on it) override printbothdate() suit needs.

c# datetime formatting

Using Ruby to replace numeric data using simple hashmap -



Using Ruby to replace numeric data using simple hashmap -

i'm trying come simple way using ruby scramble (or mask) numeric data, in order create dummy info set live data. want maintain info close original format possible (that is, preserve non-numeric characters). numbers in info correspond individual identification numbers, (sometimes) keys used in relational database. so, if numeric string occurs more once, want map consistently same (ideally unique) value. 1 time info has been scrambled, don't need able reverse scrambling.

i've created scramble function takes string , generates simple hash map numbers new values (the function maps numeric digits , leaves else is). added security, each time function called, key regenerated. thus, same phrase produce 2 different results each time function called.

module hashmodule def self.scramble(str) numhash ={} 0.upto(9) |i| numhash[i.to_s]=rand(10).to_s end output= string.new(str) output.gsub!(/\d/) do|d| d.replace numhash[d] end puts "input: " + str puts "hash key: " + numhash.to_s puts "output: " + output end end hashmodule.scramble("56609-8 no pct 001") hashmodule.scramble("56609-8 no pct 001")

this produces next output:

input: 56609-8 no pct 001 hash key: {"0"=>"9", "1"=>"4", "2"=>"8", "3"=>"9", "4"=>"4", "5"=>"8", "6"=>"4", "7"=>"0", "8"=>"2", "9"=>"1"} output: 84491-2 no pct 994 input: 56609-8 no pct 001 hash key: {"0"=>"2", "1"=>"0", "2"=>"9", "3"=>"8", "4"=>"4", "5"=>"5", "6"=>"7", "7"=>"4", "8"=>"2", "9"=>"0"} output: 57720-2 no pct 220

given info set:

pto no pc r5632893423 ip r566788882-001 no pct amb pto no amb/call ip a566788882 1655543aachm ip 56664320000000 00566333-1

i first extract numbers array. utilize scramble function created create replacement hash map, e.g.

{"5632893423"=>"5467106076", "566788882"=>"888299995", "001"=>"225", "1655543"=>"2466605", "56664320000000"=>"70007629999999", "00566333"=>"00699999", "1"=>"3"}

[incidentally, in example, haven't found way insist hash values unique, relevant in event string beingness mapped corresponds unique id in relationship database, described above.]

i utilize gsub on original string , replace hash keys scrambled value. code have works, i'm curious larn how can create more concise. realize regenerating key each time function called, create work. (otherwise, create 1 key replace digits).

does have suggestions how can accomplish way? (i'm new ruby, suggestions improving code received).

input = <<eos pto no pc r5632893423 ip r566788882-001 no pct amb pto no amb/call ip a566788882 1655543aachm ip 56664320000000 00566333-1 eos module hashmodule def self.scramble(str) numhash ={} 0.upto(9) |i| numhash[i.to_s]=rand(10).to_s end output= string.new(str) output.gsub!(/\d/) do|d| d.replace numhash[d] end homecoming output end end # extract unique non-null numbers input file numbers = input.split(/[^\d]/).uniq.reject{ |e| e.empty? } # create hash maps each number scrambled value # using function defined above mapper ={} numbers.map(&:to_s).each {|x| mapper[x]=hashmodule.scramble(x)} # create regexp find numbers in input file re = regexp.new(mapper.keys.map { |x| regexp.escape(x) }.join('|')) # replace numbers scrambled values puts input.gsub(re, mapper)

the above code produces next output:

pto no pc r7834913043 ip r799922223-772 no pct amb pto no amb/call ip a799922223 6955509aachm ip 13330271111111 66166777-6

maybe this:

module hashmodule scramblekey = hash[(0..9).map(&:to_s).zip((0..9).to_a.shuffle)] def self.scramble(str); str.gsub(/\d/){scramblekey[$&]} end end puts hashmodule.scramble(input)

which gives:

pto no pc r6907580170 ip r699455557-223 no pct amb pto no amb/call ip a699455557 3966610aachm ip 69991072222222 22699000-3

ruby hashmap scramble

html - iframe not resizing along with it's parent window -



html - iframe not resizing along with it's parent window -

see here: http://jsfiddle.net/5hyve/

<div style="position: fixed; top:0; right:0; width:300px; height: 100%; text-align:justify; overflow:hidden;" class="chat-container"> <iframe id="chat_1" style="width:300px;height:100%;" scrolling="no" frameborder="0" src="http://www.twitch.tv/chat/embed?channel=riotgames&amp;hide_chat=myspace,facebook,twitter&amp;default_chat=jtv"></iframe> </div>

try , resize result quadrant, , you'll see content within iframe not resize based on it's parent's size. not have access code in iframe. there way this, or bound poorly written css within iframe?

it looks using js observe available window size. best come refreshing iframe contents on page resize. here's snippet jquery that.

var iframe = $('#chat_1'), url = iframe.attr('src'); $(window).on('resize',function(){ iframe.attr('src',url); })

you might want utilize debounce plugin http://benalman.com/projects/jquery-throttle-debounce-plugin/ minimize number of refreshes.

update: http://jsfiddle.net/tyyj3/5/ here's illustration snippet.

html css iframe resize

kineticjs - Drag two overlapping shapes -



kineticjs - Drag two overlapping shapes -

i have 2 shapes overlapping, , want drag both when click in overlap. there easy way this?

http://jsfiddle.net/jpejf/1/

this little buggy, can spruce up, inquire for, needs more logic/polish.

the main code need @ is:

shapeslayer.on('mousedown', function(){ var userpos = stage.getuserposition(); var intersected = shapeslayer.getintersections(userpos); //gets shapes intersecting @ click position for(var = 0; < intersected.length; i++) { intersected[i].moveto(group2); // moves intersected shapes new grouping , need add together code when item moved new grouping keeps it's position } group2.simulate('dragstart'); //simulate dragging shapeslayer.draw(); }); shapeslayer.on('mouseup', function(){ //when mouse released var kids = group2.getchildren(); for(var = 0; < kids.length; i++) { kids[i].moveto(shapeslayer); //place in original container } shapeslayer.draw(); });

drag-and-drop kineticjs overlap

ruby on rails - Listing out searches in index -



ruby on rails - Listing out searches in index -

i'm having issues showing out of drinks in index.html.haml. have moved start using thinking sphinx searching after watching ryan bates' (thinking sphinx railscast. part of move sphinx changed @drinks = drink.all @drinks = drink.search(params[:search]) , not showing drink names on index page

drink model

class drink < activerecord::base attr_accessible :name, :detail, :recipe_steps_attributes has_many :recipe_steps, :dependent => :destroy has_many :ingredients, through: :recipe_steps has_one :glass validates_uniqueness_of :name, case_sensitive: false accepts_nested_attributes_for :recipe_steps, :reject_if => lambda { |a| a[:amount].blank? }, :allow_destroy => true define_index indexes :name indexes ingredients.name as: :ingredient_name end end

drink controller index

def index @drinks = drink.search(params[:search]) if current_user @cabinet = cabinet.find(current_user.id) end end

drink index.haml

= form_tag drinks_path, method: :get .field = text_field_tag :search, params[:search] = submit_tag "search", name: nil - @drinks.each |drink| = drink.name

i able reply own question. problem hadn't re-indexed after added records database. not showing when trying print them out in block.

as toml suggested, best way of dealing have cron job periodically run

rake ts:rebuild

ruby-on-rails ruby-on-rails-3 thinking-sphinx

java - MyBatis+Redis caching. Is it possible? -



java - MyBatis+Redis caching. Is it possible? -

i have little project check how works. i've implemented usage of mybatis , project works, able retrieve info database. right need result cached 2nd time. i've tested redis embedded cache manager in spring(cache abstraction: http://static.springsource.org/spring-data/data-redis/docs/current/reference/html/redis.html , liker here: http://static.springsource.org/spring/docs/3.1.0.m1/spring-framework-reference/html/cache.html). i've implemented , cached 1 method. but!!! can't understand cached or not. first time when marked method, redis said, there changes db , saved it.. changed key, , nil changed... how understand, method cached or not?? set code here understand i'm doing.

spring context:

<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:cache="http://www.springframework.org/schema/cache" xmlns:c="http://www.springframework.org/schema/c" xmlns:p="http://www.springframework.org/schema/p" xmlns:redis="http://www.springframework.org/schema/redis" xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/redis http://www.springframework.org/schema/redis/spring-redis.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd "> <jdbc:embedded-database id="datasource" type="h2"> <jdbc:script location="file:src/main/java/schema.sql" /> <jdbc:script location="file:src/main/java/test-data.sql" /> </jdbc:embedded-database> <bean id="transactionmanager" class="org.springframework.jdbc.datasource.datasourcetransactionmanager"> <property name="datasource" ref="datasource" /> </bean> <tx:annotation-driven /> <context:component-scan base-package="com.mycompany.mybatisproject.serviceimpl" /> <!-- define sqlsessionfactory --> <bean id="sqlsessionfactory" class="org.mybatis.spring.sqlsessionfactorybean"> <property name="datasource" ref="datasource" /> <property name="mapperlocations" value="file:src/main/java/com/mycompany/mybatisproject/persistence/contactmapper.xml" /> <property name="typealiasespackage" value="com.mycompany.mybatisproject.data" /> </bean> <!-- classpath*:com/mycompany/mybatisproject/persistence/*.xml --> <!-- scan mappers , allow them autowired --> <bean class="org.mybatis.spring.mapper.mapperscannerconfigurer"> <property name="basepackage" value="com.mycompany.mybatisproject.persistence" /> <property name="sqlsessionfactory" ref="sqlsessionfactory" /> </bean> <bean id="jedisconnectionfactory" class="org.springframework.data.redis.connection.jedis.jedisconnectionfactory" p:host-name="localhost" p:port="6379" /> <bean id="redistemplate" class="org.springframework.data.redis.core.redistemplate"> <property name="connectionfactory" ref="jedisconnectionfactory" /> </bean> <cache:annotation-driven /> <bean id="cachemanager" class="org.springframework.data.redis.cache.rediscachemanager" c:template-ref="redistemplate" /> </beans>

implementation of service:

@service("contactservice") @repository @transactional public class contactserviceimpl implements contactservice { private log log = logfactory.getlog(contactserviceimpl.class); @autowired private contactmapper contactmapper; @cacheable("pacan") @transactional(readonly=true) public list<contact> findall() { list<contact> contacts = contactmapper.findall(); homecoming contacts; } }

contactmapper.xml :

<?xml version="1.0" encoding="utf-8"?> <!doctype mapper public "-//mybatis.org//dtd mapper 3.0//en" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.mycompany.mybatisproject.persistence.contactmapper"> <resultmap id="contactresultmap" type="contact"> <id property="id" column="id" /> <result property="firstname" column="first_name" /> <result property="lastname" column="last_name" /> <result property="birthdate" column="birth_date" /> </resultmap> <select id="findall" resultmap="contactresultmap"> select id, first_name, last_name, birth_date contact </select>

and main class:

public class app { private static void listcontacts(list<contact> contacts) { system.out.println(""); system.out.println("listing contacts without details: "); (contact contact : contacts) { system.out.println(contact); system.out.println(); } } public static void main( string[] args ) { genericxmlapplicationcontext ctx = new genericxmlapplicationcontext(); ctx.load("file:src/main/java/app-context.xml"); ctx.refresh(); contactservice contactservice = ctx.getbean("contactservice", contactservice.class); list<contact> contacts; contacts = contactservice.findall(); listcontacts(contacts); } }

thanks in advance.

you're caching invocation of contactserviceimpl.findall method. test purpose can add together system.out.println("method invoked") in findall method. if cache works body of findall method should invoked once, next invocations should read value (result) cache shouldn't see "method invoked" on console.

don't utilize spring 3.1.0.m1 documentation different 3.1.0.release: http://static.springsource.org/spring/docs/3.1.0.release/spring-framework-reference/html/cache.html.

java spring caching redis mybatis

xsd - Allow variable element attributes in xml schema -



xsd - Allow variable element attributes in xml schema -

how element complextype if want have variable attribute names, count , values ?

<mtd:attributes icon="remove" security="d" variable1="f" variable2="d"/>

i tried :

<xsd:element name="attributes"> <xsd:complextype> <xsd:anyattribute/> </xsd:complextype> </xsd:element>

but doesn't it.

i made :

<xsd:anyattribute processcontents="skip"/>

xml xsd

How to make jQuery equal column script run on window resize? -



How to make jQuery equal column script run on window resize? -

i'm running jquery script set equal height divs in row across multiple rows.

here's link extract of code i'm using http://jsfiddle.net/f8qhd/2/

for script i've used technique in post @ css tricks http://css-tricks.com/equal-height-blocks-in-rows/

can tell me how amend script window resized still works? @ moment, works on page load don't know how trigger based on window resize. script uses $(window).resize(function() {} ); i'm not sure why doesn't work?

any help apprecitated!

thanks.

i can't see doesn't work. set resize trigger works on load without duplicating instruction.

$(window).resize(function() { columnconform(); }).trigger('resize');

just 1 note - equalising elements causes window alter size , you're going nail problems when recurses few times before settles. solved adding timeout on equal heights function.

i wrote similar extension jquery. if you're interested it's here equal height rows fluid width elements

jquery resize window-resize equal-heights

Split string in PLSQL -



Split string in PLSQL -

following should homecoming y

casisa#y invopt#lumreg#lumsum#2000#regsum#8000 lumsum#2000#regsum#8000

i.e hash separates code , value , separates code, value pairs (earlier semicolon used separate code, value pairs)

following should homecoming n (as these wrong input string formats)

casisa# invopt#lumreg#lumsum lumsum#2000#regsum#8000#

case when regexp_like(your_string||'#', '^(\w+#\w+#)+$') 'y' else 'n' end

sql fiddle

plsql

how to add attachments programatically to email in a windows phone 8 app? -



how to add attachments programatically to email in a windows phone 8 app? -

i developing windows phone 8 app , in want add together attachments email in windows phone 8 app.

1)how can add together attachments(attaching files) email , send ??

2)is emailcomposetask doesn't back upwards attachments ?? ,if alternative ??

2)what various ways in can attach files in windows phone 8 app??

thanks in advance.

i'm asking myself these questions , found demo library ahmed mentioned. however, wanted solution without buying libraries.

if not using binary files, can set files content body of emailcomposetask. other possibility utilize skydrive , upload file , set link file in emails body.

windows-phone-7 windows-phone-7.1 windows-phone-8

graphics - How to display part of an image using a for loop from a picturebox array -



graphics - How to display part of an image using a for loop from a picturebox array -

there may simple reply have tried quite few things , nil seems work unless manually display images want utilize sub other pictures prepare later 1 time display these images. code follows

private sub updatestandardtoolbar() 'draws sprites pictureboxes dim bit new bitmap(gridsize, gridsize) dim dest_rect rectangle = new rectangle(0, 0, gridsize, gridsize) dim integer = 0 ' associate graphics object bitmap dim gr graphics = graphics.fromimage(bit) y integer = 0 standardnum.y x integer = 0 standardnum.x phone call getsrcrect(x, y) 'copy part of image. gr.drawimage(bmpstandardtile, dest_rect, src_rect, graphicsunit.pixel) 'display result. pb(i).image = bit += 1 next next end sub

the problem code pictureboxes (pb()) displays same image lastly 1 on image. standardnum.x , standardnum.y variables hold 3 , 1 respectively. bmpstandardtile image want re-create , dest_rect , src_rect self explanatory =). helps appreciated.

oh. found reply own problem after looking @ why pictureboxes displays same image. here code , how fixed if else has similar or same problem.

private sub updatestandardtoolbar() 'draws sprites pictureboxes dim bit bitmap dim dest_rect rectangle = new rectangle(0, 0, gridsize, gridsize) dim integer = 0 ' associate graphics object bitmap 'dim gr graphics 'for u integer = 0 maxpics ' bit = new bitmap(gridsize, gridsize) 'next y integer = 0 standardnum.y x integer = 0 standardnum.x bit = new bitmap(gridsize, gridsize) dim gr graphics = graphics.fromimage(bit) phone call getsrcrect(x, y) 'copy part of image. gr.drawimage(bmpstandardtile, dest_rect, src_rect, graphicsunit.pixel) 'display result. pb(i).image = bit += 1 next next end sub

the reply simple. silly me. forgot clear bitmap image not alter image lastly picturebox using.

bit = new bitmap(gridsize, gridsize)

anyway learnt mistakes =)

arrays graphics vb.net-2010 picturebox

How do I design database for an application to deal with peculier needs of multiple countries -



How do I design database for an application to deal with peculier needs of multiple countries -

when developing multi-regional application, best practises handling things differences in currencies, working days , time differences when comes database design.

do create separate database each different region/country? have database mutual tables not affected country or regional peculiarity , create separate databases each peculiar region? put them in single database , have relational parent-child references countries table, currencies table, charges table etc.

there issue of business day varies every country , every year. agent charged penalties each business day have not banked collections, since different each country, how 1 deal when designing database.

i may have muddled question bit hope essence clear enough.

unless have other requirements dictate otherwise (e.g. scalability/redundancy), best way maintain in single db instance, define table collects countries interested in (along country-specific properties).

e.g.:

country-cd |country-name | currency | language | time-zone | region-cd italy eur met emea ... ... ... ... ... ... jp state of japan jpy jp jst far-east

and utilize country code part of key each other table may have country-specific content... prices:

item-id | country-cd | valid-from | valid-to | amount x unit 950595 | | 03-may-2013 | 31-dec-2099| 23.56 950595 | jp | 01-feb-2013 | 12-aug-2013| 2643.00 950595 | jp | 13-aug-2013 | 31-dec-2099| 2810.00

so same item priced @ 23.56 euros in italy, , instead sold 2643 yen in jp, feb.1st aug.12th, , increment in cost 2810 yen.

couple of caveats

i have used iso codes country , money. should robust plenty avoid problems in future. love of god not utilize application-specific codes things states or currencies. if designing little portion of world, like, dunno... "german speaking countries" (germany, austria, part of switzerland) resist temptation utilize things ger/aus/swi or not standard. time zones horribly hairy manage. set in same table country illustrate kind of info should associated country entry, in reality countries span more 1 time zone (ru, us) , hence need more sophisticated schema. on top of point (2) above, if application lives in single-instance db have decide rule how time displayed users , stick it. consistently. see below.

the problem world-spanning applications may have server in bangalore users in rome. have 2 choices - either timestamp every operation time zone of actual server "resides" , allow users adjust mentally discrepancies, or still timestamp specific time zone (you can of course of study utilize utc instead of local time, , applies other method, too) , automagically translate user local timezone while displaying.

so may have "record created @ utc 12-may-2014 00:34" stored in db , show me "record created @ 12-may-2014 01:34 met" because using application italy.

(this prove easier users if application allows them create entries time input - illustration booking room meeting - cost more in terms of development, , may become bit complex manage when same record can updated different time zones).

these basics, really... have read i18n, of course, , decide if want error messages , ui labels multilingual. i18n cares (i.e. how manage input , output in different languages) gives guidelines more esoteric stuff culturally-appropriated icons suggest bit of research on it.

design database-design architecture

objective c - releasing a NSURLConnection? -



objective c - releasing a NSURLConnection? -

i have connection server , , want release queue, don't how.

[nsurlconnection sendasynchronousrequest:request queue:[[nsoperationqueue alloc] init] completionhandler:^(nsurlresponse *response, nsdata *data, nserror *error) //some if else statements }];

i dont how release queue argument between 2 connections ?

if using arc, not have anything.

if not, can include autorelease.

objective-c

performance - Delphi 7, Windows NT Service, Console App -



performance - Delphi 7, Windows NT Service, Console App -

i have delphi 7 32bit application. windows 7 64bit.

everything runs fine. have been investigation performance issues i've noticed.

a brief overview of application -->

has command-line / console app executable, written in delphi. creates multi-threaded set of connections , database work. nt service, written in delphi (which calls command-line application), based on schedules of jobs finds. done via phone call our dll, finds , executes createprocess commandline application, , waitforsingleobject finish. effectively, service responsible finding when work needs done, , callin executable/console app it.

here's problem, cannot seem figure out.

if run command-line application, 4x faster result if nt service phone call via createprocess. identical code. 1 dos prompt issuance of exe, other nt service, loads dll, calls createprocess same executable.

i going bananas. cannot see reason this.

i can reproduce on scheme configuration far.

what i've noticed far (not scientific, relevant imo).

if monitor cpu cores cpu time , kernel time, console app has fraction of kernel time during life-time of execution. when scheduler service runs this, kernel time represents 50-70%% or more of whatever cpu % utilize getting.

some actual results (everything else irrelevant believe) - console app, run through commandline: 26 seconds - console app, run through service via createprocess: 113 seconds

what gives?

i've looked perhaps fastmm isnt beingness shared properly. believe is. remoed it. same anomalies. i've looked perhaps fastcode, fastmove stuff isnt working under service (since @ startup, trying dynamically hook/replace core rtl functions. removed them equation, same anomalies. i've looked removing our patched rtl (system.dcu/sysinit.dcu) files. no joy.

all no avail.

so, questions (and solicitation possible reasons), ...

does nt service preclude ability perform automation/hook replacement features? delphi services create cause this? there sort of inherent overhead -- (and huge amount) services? there alternatives using fastmm, fastcode, fastmove others have used because of of nature?

thanks in advance guidances/helpers here.

here's snippet of code used launch app nt service.

fillchar(si, sizeof(si), 0); si.dwflags := sw_hide; fillchar(pi, sizeof(pi), 0); scommandline := format('"%s" "%d"', [extractfilepath(paramstr(0)) + 'myapp.exe', ajobid]); if createprocess(pchar(sfilename), pchar(scommandline), nil, nil, false, 0, nil, nil, si, pi) begin waitforsingleobject(pi.hprocess, infinite); getexitcodeprocess(pi.hprocess, exitcode); result := (exitcode = 0); end else begin addeventlogmessage(syserrormessage(getlasterror)); end;

it turns out issue related utilize of connections, , sharing connection.

once took approach of destroying connection on scheduler before launching createprocess, kernel usage inline seeing when running straight console.

very surprising, given connection not shared commandline doing.

future reference: sure eliminate variables before saying 2 approaches identical. in this, not. scheduler had connection, console app did not. , difference.

performance delphi delphi-7

unix - How to decrypt an encrypted file in java with openssl with AES? -



unix - How to decrypt an encrypted file in java with openssl with AES? -

i need decrypt in java file encrypted in unix next command:

openssl aes-256-cbc -a -salt -in password.txt -out password.txt.enc mypass mypass

i have decrypt in java here in unix

openssl aes-256-cbc -d -a -in password.txt.enc -out password.txt.new mypass

someone can give me java code this?

openssl uses own password based key derivation method, specified in evp_bytestokey, please see code below. in general should forcefulness openssl utilize nist approved pbkdf2 algorithm though.

import java.io.file; import java.io.ioexception; import java.nio.charset.charset; import java.nio.file.files; import java.security.generalsecurityexception; import java.security.messagedigest; import java.util.arrays; import java.util.list; import javax.crypto.badpaddingexception; import javax.crypto.cipher; import javax.crypto.illegalblocksizeexception; import javax.crypto.spec.ivparameterspec; import javax.crypto.spec.secretkeyspec; import org.bouncycastle.util.encoders.base64; /** * class created stackoverflow owlstead. * open source, free re-create , utilize purpose. */ public class openssldecryptor { private static final charset ascii = charset.forname("ascii"); private static final int index_key = 0; private static final int index_iv = 1; private static final int iterations = 1; private static final int arg_index_filename = 0; private static final int arg_index_password = 1; private static final int salt_offset = 8; private static final int salt_size = 8; private static final int ciphertext_offset = salt_offset + salt_size; private static final int key_size_bits = 256; /** * go ola bini releasing source on blog. * source obtained <a href="http://olabini.com/blog/tag/evp_bytestokey/">here</a> . */ public static byte[][] evp_bytestokey(int key_len, int iv_len, messagedigest md, byte[] salt, byte[] data, int count) { byte[][] both = new byte[2][]; byte[] key = new byte[key_len]; int key_ix = 0; byte[] iv = new byte[iv_len]; int iv_ix = 0; both[0] = key; both[1] = iv; byte[] md_buf = null; int nkey = key_len; int niv = iv_len; int = 0; if (data == null) { homecoming both; } int addmd = 0; (;;) { md.reset(); if (addmd++ > 0) { md.update(md_buf); } md.update(data); if (null != salt) { md.update(salt, 0, 8); } md_buf = md.digest(); (i = 1; < count; i++) { md.reset(); md.update(md_buf); md_buf = md.digest(); } = 0; if (nkey > 0) { (;;) { if (nkey == 0) break; if (i == md_buf.length) break; key[key_ix++] = md_buf[i]; nkey--; i++; } } if (niv > 0 && != md_buf.length) { (;;) { if (niv == 0) break; if (i == md_buf.length) break; iv[iv_ix++] = md_buf[i]; niv--; i++; } } if (nkey == 0 && niv == 0) { break; } } (i = 0; < md_buf.length; i++) { md_buf[i] = 0; } homecoming both; } public static void main(string[] args) { seek { // --- read base of operations 64 encoded file --- file f = new file(args[arg_index_filename]); list<string> lines = files.readalllines(f.topath(), ascii); stringbuilder sb = new stringbuilder(); (string line : lines) { sb.append(line.trim()); } string database64 = sb.tostring(); byte[] headersaltandciphertext = base64.decode(database64); // --- extract salt & encrypted --- // header "salted__", ascii encoded, if salt beingness used (the default) byte[] salt = arrays.copyofrange( headersaltandciphertext, salt_offset, salt_offset + salt_size); byte[] encrypted = arrays.copyofrange( headersaltandciphertext, ciphertext_offset, headersaltandciphertext.length); // --- specify cipher , digest evp_bytestokey method --- cipher aescbc = cipher.getinstance("aes/cbc/pkcs5padding"); messagedigest md5 = messagedigest.getinstance("md5"); // --- create key , iv --- // iv useless, openssl might have utilize zero's final byte[][] keyandiv = evp_bytestokey( key_size_bits / byte.size, aescbc.getblocksize(), md5, salt, args[arg_index_password].getbytes(ascii), iterations); secretkeyspec key = new secretkeyspec(keyandiv[index_key], "aes"); ivparameterspec iv = new ivparameterspec(keyandiv[index_iv]); // --- initialize cipher instance , decrypt --- aescbc.init(cipher.decrypt_mode, key, iv); byte[] decrypted = aescbc.dofinal(encrypted); string reply = new string(decrypted, ascii); system.out.println(answer); } grab (badpaddingexception e) { // aka "something went wrong" throw new illegalstateexception( "bad password, algorithm, mode or padding;" + " no salt, wrong number of iterations or corrupted ciphertext."); } grab (illegalblocksizeexception e) { throw new illegalstateexception( "bad algorithm, mode or corrupted (resized) ciphertext."); } grab (generalsecurityexception e) { throw new illegalstateexception(e); } grab (ioexception e) { throw new illegalstateexception(e); } } }

java unix openssl aes

jQuery ui dialog overlay and ajax injected html -



jQuery ui dialog overlay and ajax injected html -

i have problem site (unfortunately can't provide link because it's on staging environment).

i have jqueryui dialog opens when page loads, if scroll downwards overlay covers of it. part of page updated ajax calls , height of page increment , that's issue, overlay don't covers page more , bottom content accessible.

i can see overlay adapts changes, resize of page.. there way update when scrolling downwards example? could solve issue

i'm sorry can't provide link shows issue..

regards, gianpiero

in similar situation found successful workaround triggering window resize event after each asynchronous dom change:

$(window).resize();

ajax jquery-ui dialog overlay

html - Apache not receiving a referal_url? -



html - Apache not receiving a referal_url? -

i have apache server receives around 7000 visits per day, 1300 of 7000 receive referal_url user agent.

is there can this?

i'd know these clicks coming fraud purposes.

you cannot forcefulness user agent send anything. obeys it's own rules. note if user types in url directly, no referral header ever generated.

however, ip address can check.

html apache url tracking

sql - MySQL if pagename then run statment -



sql - MySQL if pagename then run statment -

hi wondering if help me out mysql. i'm building blog , have 2 tables articles , categories , i'm joining these tables, want display categories if click categories link. i'm passing categories_id in link can't figure out how display categories if page link blog.php?=category_id. i'll have categories_id number in url cant figure out how display category, know sql statement display categories can't figure out how run statement if url contains the ?=category_id , not run original sql statement displaying articles date. tried if , else conditions depending on page name wasn't working. hope makes sense , help much appreciated, in advance,

mitchell layzell

heres code code $url = $_server['script_name']; $pos = strrpos($url,"/"); $pagename = substr($url,$pos+1); if($pagename == ("blog.php")) { $sql = "select article_id, title, body, date, categories.category, author articles left bring together categories on articles.category = categories.category_id order article_id desc limit 4"; } elseif($pagename == ("blog.php?=1")) { $sql = "select article_id, title, body, date, categories.category, author articles left bring together categories on articles.category = categories.category_id category_id = 1"; } $result = query($sql); if($result===false) { echo "query failed"; } else { while( $data = mysqli_fetch_array($result)) { ?> <article> <h3 class="title-medium"><?php echo $data['title']; ?></h3> <p class="caption-medium"><?php echo $data['author']; ?> <?php echo $data['date']; ?> <?php echo $data['category']; ?></p> <img src="img/blog-post-1.jpg" alt=""> <p><?php echo substr($data['body'],0,450)." ..." ?></p> <a href="blog-post.php?id=<?php echo $data['article_id']; ?>"><p class="caption-medium highlight">read more</p></a> <hr> </article> <?php } } ?>

code

as you've been told in comments, have utilize parameter, not whole request.

connect_to_db(); $where = ''; if (isset($_get['cat_id'])) { $where = "where category_id = ".intval($_get['cat_id']); } $sql = "select article_id, title, body, date, categories.category, author articles left bring together categories on articles.category = categories.category_id $where order article_id desc limit 4"; $result = query($sql);

mysql sql if-statement mysqli

node.js - Node Pass Hidden Data To Other Route -



node.js - Node Pass Hidden Data To Other Route -

i have route in express(item/update/), , after happens want send them /, want create / show alert 'success' or 'failure'. don't want utilize query string or hash because want hidden user. don't want render / @ items/update seems bad idea. also, have tried javascript history api, seems hack history api else.

please allow me know if there more info need.

you can couple of ways,

1.you can redirect "/" url query string. since don't add together info in query string, alternate alternative session.

for example,

function itempupdatehandler(request,response){ //do stuff request.session.displaymsg = "update done successfully"; response.setheader("location: http://yourdomain.com/"); response.end(); } function homepagehandler(request,response){ //display message here read session. if(request.session.displaymsg){ console.log(request.session.displaymsg); delete request.session.displaymsg; } //do regular suff here. }

2.you have take care more in next method, here aren't going redirect need modify handler function follows,

function itempupdatehandler(request,response){ //do stuff //response.setheader("location: http://yourdomain.com/"); //no need here homepagehandler(request,response, {display:true, msg: "update done successfully"}); } function homepagehandler(request,response, moreargs){ //display message here read session. if(moreargs.display){ console.log(moreargs.msg); } //do regular suff here. }

note: assumed using express

node.js express routes hidden

c++ - Getting an "error LNK2019: unresolved external symbol" -



c++ - Getting an "error LNK2019: unresolved external symbol" -

this code. it's practice using templates.

header

#ifndef h_rectangletype #define h_rectangletype #include <iostream> using namespace std; namespace rectangle{ template <class mytype> class rectangletype { //overload stream insertion , extraction operators friend ostream& operator << (ostream&, const rectangletype &); friend istream& operator >> (istream&, rectangletype &); public: void setdimension(mytype l, mytype w); mytype getlength() const; mytype getwidth() const; mytype area() const; mytype perimeter() const; void print() const; rectangletype<mytype> operator+(const rectangletype<mytype>&) const; //overload operator + rectangletype<mytype> operator*(const rectangletype<mytype>&) const; //overload operator * bool operator==(const mytype&) const; //overload operator == bool operator!=(const mytype&) const; //overload operator != rectangletype(); rectangletype(mytype l, mytype w); private: mytype length; mytype width; }; } #endif

member definitions

#include <iostream> #include "rectangletype.h" using namespace std; namespace rectangle{ template <class mytype> void rectangletype<mytype>::setdimension(mytype l, mytype w) { if (l >= 0) length = l; else length = 0; if (w >= 0) width = w; else width = 0; } template <class mytype> mytype rectangletype<mytype>::getlength() const { homecoming length; } template <class mytype> mytype rectangletype<mytype>::getwidth()const { homecoming width; } template <class mytype> mytype rectangletype<mytype>::area() const { homecoming length * width; } template <class mytype> mytype rectangletype<mytype>::perimeter() const { homecoming 2 * (length + width); } template <class mytype> void rectangletype<mytype>::print() const { cout << "length = " << length << "; width = " << width; } template <class mytype> rectangletype<mytype>::rectangletype(mytype l, mytype w) { setdimension(l, w); } template <class mytype> rectangletype<mytype>::rectangletype() { length = 0; width = 0; } template <class mytype> rectangletype<mytype> rectangletype<mytype>::operator+ (const rectangletype<mytype>& rectangle) const { rectangletype<mytype> temprect; temprect.length = length + rectangle.length; temprect.width = width + rectangle.width; homecoming temprect; } template <class mytype> rectangletype<mytype> rectangletype<mytype>::operator* (const rectangletype<mytype>& rectangle) const { rectangletype<mytype> temprect; temprect.length = length * rectangle.length; temprect.width = width * rectangle.width; homecoming temprect; } template <class mytype> bool rectangletype<mytype>::operator== (const mytype& rectangle) const { homecoming (length == rectangle.length && width == rectangle.width); } template <class mytype> bool rectangletype<mytype>::operator!= (const mytype& rectangle) const { homecoming (length != rectangle.length || width != rectangle.width); } template <class mytype2> ostream& operator << (ostream& osobject, const rectangletype<mytype2>& rectangle) { osobject << "length = " << rectangle.length << "; width = " << rectangle.width; homecoming osobject; } template <class mytype2> istream& operator >> (istream& isobject, rectangletype<mytype2>& rectangle) { isobject >> rectangle.length >> rectangle.width; homecoming isobject; } }

main

#include <iostream> //line 1 #include "rectangletype.h" //line 2 using namespace std; //line 3 using namespace rectangle; int main() //line 4 { //line 5 cout << "enter type of rectangle.\n1. int\n2. double\n3. float"; rectangletype<double> myrectangle(23, 45); //line 6 int int1 = 1; int double1 = 2; int float1 = 3; int temp= 0; cin >> temp; //line 7 if(temp == int1) { rectangletype<int> myrectangle(23, 45); rectangletype<int> yourrectangle; cout << "line 8: myrectangle: " << myrectangle << endl; cout << "line 9: come in length , width " <<"of rectangle: "; cin >> yourrectangle; cout << endl; cout << "line 12: yourrectangle: " << yourrectangle << endl; cout << "line 13: myrectangle + yourrectangle: " << myrectangle + yourrectangle << endl; cout << "line 14: myrectangle * yourrectangle: " << myrectangle * yourrectangle << endl; } if(temp == double1) { rectangletype<double> myrectangle(23, 45); rectangletype<double> yourrectangle; cout << "line 8: myrectangle: " << myrectangle << endl; cout << "line 9: come in length , width " <<"of rectangle: "; cin >> yourrectangle; cout << endl; cout << "line 12: yourrectangle: " << yourrectangle << endl; cout << "line 13: myrectangle + yourrectangle: " << myrectangle + yourrectangle << endl; cout << "line 14: myrectangle * yourrectangle: " << myrectangle * yourrectangle << endl; } if(temp == float1) { rectangletype<float> myrectangle(23, 45); rectangletype<float> yourrectangle; cout << "line 8: myrectangle: " << myrectangle << endl; cout << "line 9: come in length , width " <<"of rectangle: "; cin >> yourrectangle; cout << endl; cout << "line 12: yourrectangle: " << yourrectangle << endl; cout << "line 13: myrectangle + yourrectangle: " << myrectangle + yourrectangle << endl; cout << "line 14: myrectangle * yourrectangle: " << myrectangle * yourrectangle << endl; } homecoming 0;

}

here,i'm getting these errors

1>testopoverloadclass.obj : error lnk2019: unresolved external symbol "public: class rectangle::rectangletype<float> __thiscall rectangle::rectangletype<float>::operator*(class rectangle::rectangletype<float> const &)const " (??d?$rectangletype@m@rectangle@@qbe?av01@abv01@@z) referenced in function _main 1>testopoverloadclass.obj : error lnk2019: unresolved external symbol "public: class rectangle::rectangletype<float> __thiscall rectangle::rectangletype<float>::operator+(class rectangle::rectangletype<float> const &)const " (??h?$rectangletype@m@rectangle@@qbe?av01@abv01@@z) referenced in function _main 1>testopoverloadclass.obj : error lnk2019: unresolved external symbol "class std::basic_istream<char,struct std::char_traits<char> > & __cdecl rectangle::operator>>(class std::basic_istream<char,struct std::char_traits<char> > &,class rectangle::rectangletype<float> &)" (??5rectangle@@yaaav?$basic_istream@du?$char_traits@d@std@@@std@@aav12@aav?$rectangletype@m@0@@z) referenced in function _main 1>testopoverloadclass.obj : error lnk2019: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl rectangle::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class rectangle::rectangletype<float> const &)" (??6rectangle@@yaaav?$basic_ostream@du?$char_traits@d@std@@@std@@aav12@abv?$rectangletype@m@0@@z) referenced in function _main 1>testopoverloadclass.obj : error lnk2019: unresolved external symbol "public: __thiscall rectangle::rectangletype<float>::rectangletype<float>(void)" (??0?$rectangletype@m@rectangle@@qae@xz) referenced in function _main 1>testopoverloadclass.obj : error lnk2019: unresolved external symbol "public: __thiscall rectangle::rectangletype<float>::rectangletype<float>(float,float)" (??0?$rectangletype@m@rectangle@@qae@mm@z) referenced in function _main 1>testopoverloadclass.obj : error lnk2019: unresolved external symbol "public: class rectangle::rectangletype<double> __thiscall rectangle::rectangletype<double>::operator*(class rectangle::rectangletype<double> const &)const " (??d?$rectangletype@n@rectangle@@qbe?av01@abv01@@z) referenced in function _main 1>testopoverloadclass.obj : error lnk2019: unresolved external symbol "public: class rectangle::rectangletype<double> __thiscall rectangle::rectangletype<double>::operator+(class rectangle::rectangletype<double> const &)const " (??h?$rectangletype@n@rectangle@@qbe?av01@abv01@@z) referenced in function _main 1>testopoverloadclass.obj : error lnk2019: unresolved external symbol "class std::basic_istream<char,struct std::char_traits<char> > & __cdecl rectangle::operator>>(class std::basic_istream<char,struct std::char_traits<char> > &,class rectangle::rectangletype<double> &)" (??5rectangle@@yaaav?$basic_istream@du?$char_traits@d@std@@@std@@aav12@aav?$rectangletype@n@0@@z) referenced in function _main 1>testopoverloadclass.obj : error lnk2019: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl rectangle::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class rectangle::rectangletype<double> const &)" (??6rectangle@@yaaav?$basic_ostream@du?$char_traits@d@std@@@std@@aav12@abv?$rectangletype@n@0@@z) referenced in function _main 1>testopoverloadclass.obj : error lnk2019: unresolved external symbol "public: __thiscall rectangle::rectangletype<double>::rectangletype<double>(void)" (??0?$rectangletype@n@rectangle@@qae@xz) referenced in function _main 1>testopoverloadclass.obj : error lnk2019: unresolved external symbol "public: class rectangle::rectangletype<int> __thiscall rectangle::rectangletype<int>::operator*(class rectangle::rectangletype<int> const &)const " (??d?$rectangletype@h@rectangle@@qbe?av01@abv01@@z) referenced in function _main 1>testopoverloadclass.obj : error lnk2019: unresolved external symbol "public: class rectangle::rectangletype<int> __thiscall rectangle::rectangletype<int>::operator+(class rectangle::rectangletype<int> const &)const " (??h?$rectangletype@h@rectangle@@qbe?av01@abv01@@z) referenced in function _main 1>testopoverloadclass.obj : error lnk2019: unresolved external symbol "class std::basic_istream<char,struct std::char_traits<char> > & __cdecl rectangle::operator>>(class std::basic_istream<char,struct std::char_traits<char> > &,class rectangle::rectangletype<int> &)" (??5rectangle@@yaaav?$basic_istream@du?$char_traits@d@std@@@std@@aav12@aav?$rectangletype@h@0@@z) referenced in function _main 1>testopoverloadclass.obj : error lnk2019: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl rectangle::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class rectangle::rectangletype<int> const &)" (??6rectangle@@yaaav?$basic_ostream@du?$char_traits@d@std@@@std@@aav12@abv?$rectangletype@h@0@@z) referenced in function _main 1>testopoverloadclass.obj : error lnk2019: unresolved external symbol "public: __thiscall rectangle::rectangletype<int>::rectangletype<int>(void)" (??0?$rectangletype@h@rectangle@@qae@xz) referenced in function _main 1>testopoverloadclass.obj : error lnk2019: unresolved external symbol "public: __thiscall rectangle::rectangletype<int>::rectangletype<int>(int,int)" (??0?$rectangletype@h@rectangle@@qae@hh@z) referenced in function _main 1>testopoverloadclass.obj : error lnk2019: unresolved external symbol "public: __thiscall rectangle::rectangletype<double>::rectangletype<double>(double,double)" (??0?$rectangletype@n@rectangle@@qae@nn@z) referenced in function _main 1>c:\users\jr\documents\visual studio 2010\projects\cmpe 126\lab 2\debug\lab 2.exe : fatal error lnk1120: 18 unresolved externals

i cant seem create these errors mean. inadvance

you can't separate definition , implementation templated classes. have set functions in header file well.

c++