Monday 15 February 2010

Invalid 8086 assembly statement -



Invalid 8086 assembly statement -

i have seen sentence in assembly language , don't know why wrong. here is:

mov cx, ch

.why wrong?

your instruction wrong because cx 16 bit , ch 8 bit (it's higher 8 bits in cx

assembly 8086

sql - Group by, Subquery and Nested group by function in the Having clause -



sql - Group by, Subquery and Nested group by function in the Having clause -

trying display details of staff fellow member amount of orders, in oracle there error stating grouping function 'nested deeply'.

select c.staff_no, s.first_name, s.last_name, max(count(*)) "number of orders" cust_order c, staff s c.staff_no = s.staff_no grouping c.staff_no, s.first_name, s.last_name having max(count(*)) > (select max((count(*)) cust_order c, staff s c.staff_no = s.staff_no);

instead, utilize analytic functions:

select staff_no, first_name, last_name, "number of orders" (select c.staff_no, s.first_name, s.last_name, count(*) "number of orders", max(count(*)) on () maxcount cust_order c bring together staff s on c.staff_no = s.staff_no grouping c.staff_no, s.first_name, s.last_name ) cs "number of orders" = maxcount;

this should have improve performance.

sql oracle nested having clause

javascript - FineUploader S3 Compatible support -



javascript - FineUploader S3 Compatible support -

i know fineuploader works amazon s3 there many s3 compatible servers , evaluate fineuploader used s3 compatible server.

has done ? if there configuration tips ?

i'm not sure got right here, s3 service offered aws. there "one" s3.

using fineuploader s3 requires 3 parties: - browser (end-user) - server (hosted language of choice: nodejs, php, python etc.) - amazon s3

if you'd seek this, advise visit www.fineuploader.com, , grab re-create of jquery s3 fineuploader. it's offered without paying money.

you can create work first, , pay commercial license later if need commercial use.

in terms of configuration, have server-side demos in various languages here: https://github.com/fineuploader/server-examples

client-side demos in website: http://fineuploader.com/demos.html

javascript amazon-s3 fine-uploader

php - Not Picking Up Image If False -



php - Not Picking Up Image If False -

in codeigniter form, trying set else if info image. picks if when image exists. need pick no_image.png, if no image exist using same code below.

<?php class users extends mx_controller { public function index() { $this->getform(); } protected function getform($user_id = 0) { $this->load->model('admin/user/users_model'); $user_info = $this->users_model->getuser($user_id); if (trim($this->input->post('image'))) { $data['image'] = $this->input->post('image'); } elseif (!empty($user_info)) { // location image works fine. $data['image'] = config_item('base_url') . 'image/catalog/' . $user_info['image']; } else { // should display if no image nowadays in database not work. $data['image'] = config_item('base_url') . 'image/'. 'no_image.png'; } } $this->load->view('user/users_form', $data); }

view page :

<div class="form-group"> <label for="input-image" class="col-lg-2 col-md-12 col-sm-2 col-xs-12"><?php echo $entry_image; ?></label> <div class="col-lg-10 col-md-10 col-sm-10 col-xs-12"> <a href="" id="thumb-image" data-toggle="image" class="img-thumbnail"> <img src="<?php echo $image; ?>"/> </a> </div> </div>

make sure in image folder no_image.png exists. , accessible directly.like , can seek straight open link in browser http://www.yoursiteurl/image/no_image.png.

if opens there 2 possibilities

in config file there no end slash baseurl.

the code never executes else block

if dierct link not open htaccess problem may exists.

hope help you.

or elseif status may this

elseif(!empty($user_info) && $user_info['image'] && file_exists(config_item('base_url') . 'image/catalog/' . $user_info['image'])){ ... } // + user info valid user image not available

php codeigniter

java - JSON response is not working in PHP version 5.3.24 -



java - JSON response is not working in PHP version 5.3.24 -

i developing java application have pass values server , receive response php file (version 5.3.24).the code running fine in localhost , other live servers php version greater 5.3.24.

this java code.

public static void send() { seek { // create json string, seek hamburger string json = "{\"name\":\"frank\",\"food\":\"pizza\",\"quantity\":3}"; // send http request url url = new url("http://www.matjazcerkvenik.si/php/json/pizzaservice.php?order="+json); urlconnection conn = url.openconnection(); // response bufferedreader rd = new bufferedreader(new inputstreamreader(conn.getinputstream())); string line; while ((line = rd.readline()) != null) { system.out.println(line); } rd.close(); } grab (exception e) { e.printstacktrace(); } } public static void main(string[] args) { send(); }

this php code.

<?php $order = $_get["order"]; $obj = json_decode($order); $name = $obj -> {"name"}; $food = $obj -> {"food"}; $quty = $obj -> {"quantity"}; if ($food == "pizza") { $price = 4000; } else if ($food == "hamburger") { $price = 5000; } else { $price = 0; } $price = $price * $quty; if ($price == 0) { $status = "not-accepted"; } else { $status = "accepted"; } $array = array("name" => $name, "food" => $food, "quantity" => $quty, "price" => $price, "status" => $status); echo json_encode($array); ?>

change php script bit:

<?php $order = get_magic_quotes_gpc() ? stripslashes($_get["order"]) : $_get["order"]; $obj = json_decode($order); $name = $obj -> {"name"}; $food = $obj -> {"food"}; $quty = $obj -> {"quantity"}; if ($food == "pizza") { $price = 4000; } else if ($food == "hamburger") { $price = 5000; } else { $price = 0; } $price = $price * $quty; if ($price == 0) { $status = "not-accepted"; } else { $status = "accepted"; } $array = array("name" => $name, "food" => $food, "quantity" => $quty, "price" => $price, "status" => $status); echo json_encode($array); ?>

java php json

object - Making a class act as string in Python when you have both str and unicode -



object - Making a class act as string in Python when you have both str and unicode -

disclaimer: using python 2.6 lot of weird reasons. is.

i'm trying create object deed string properties this:

class setting(str): def __new__(cls, value, source): homecoming super(setting, cls).__new__(cls, value) def __init__(self, value, source): self.value = value self.source = source

this works rather nicely. scarily nice. ;)

but: need back upwards both unicode , str objects. ideally extend basestring. unfortunately, logical reasons; changing super class basestring not work , gives error:

typeerror: basestring type cannot instantiated

anyone have thought how go fixing this? thanks. :)

ok, sorry code horrible, hard understand, subclassing builtin (like str, file) bad idea, in production code.

what recommend generic approach, create class 2 variables , override special operators desired result (ie create deed str):

class setting: def __init__(self, value, source): self.value = value self.source = source def __add__(self, rhs): #keeping object immutable homecoming setting(self.value + rhs, self.source)

however in interests of extreme python code, cannot think of single utilize case (there improve way), here workaround:

class setting(object): def __new__(cls, value, source): #pick right base of operations class base_class = str if isinstance(value, str) else unicode #construct new setting class right base of operations new_type = type(cls.__name__, (base_class,), dict(cls.__dict__)) homecoming base_class.__new__(new_type, value) def __init__(self, value, source): self.value = value self.source = source

the thought dynamically create class right base of operations based on type of value given. yes, should more scary , shouldn't utilize it. alter base of operations became whatever class type 'value' was, thought more readable.

the reason couldn't utilize basestring abstract class, or @ to the lowest degree acts one. when did:

return super(setting, cls).__new__(cls, value)

it tried create current instance of setting new instance of basestring, since abstract means has no implementation, nil call.

python object unicode subclass

c++ - wstringstream to LPCWSTR -



c++ - wstringstream to LPCWSTR -

there open source code using , created new string class can have syntax's :

openevent(event_all_access, false, string() << l"sometext" << uint(123));

i wondering if can create same thing conciseness wstringstream or similar.

openevent window api function 3rd argument lpcwstr can phone call like

openevent(event_all_access, false, l"some text");

assuming have wstringstream variable named wss, calling "wss.str().c_str()" trick.

this relies on str fellow member of basic_stringstream class , c_str fellow member of basic_string class. calling str on basic_stringstream object obtains string representation of object , calling c_str on basic_string object obtains c-style string representation of object.

c++ windows winapi stl

angularjs - Scroll to selection in Angular ui-grid (not ng-grid) -



angularjs - Scroll to selection in Angular ui-grid (not ng-grid) -

for angular js grid work, i'm using ui-grid rather ng-grid ui-grid meant new version purer angular.

i've got grid i'm populating http response, , i'm able select row (based on finding record matching $scope variable value) using api.selection.selectrow method call.

what need next scroll grid record.

there's existing stack overflow question along same lines ng-grid , reply refers undocumented features not nowadays in ui-grid can't utilize approach.

the closest i've got finding $scope.gridapi.grid reference actual grid looking through properties , methods in chrome debugger doesn't show sounds work.

you can utilize cellnav plugin. should have reference row entity selection. documentation here.

gridapi.cellnav.scrollto(grid, $scope, rowentity, null);

angularjs grid scroll

java - QuickSort Random Pivot Not Sorting -



java - QuickSort Random Pivot Not Sorting -

as title implies, working on java implementation of quicksort. read in algorithms textbook (sedgewick text), choosing random pivot reduces chance worse case performance when array sorted. when used first element(all way left) pivot, consistently received sorted array. however, when chose random pivot, began unsorted nonsense. can tell me mistakes making? give thanks in advance.

static void quicksort(string arr[], int left, int right) { if (left < right) { int index = partition(arr, left, right); quicksort(arr, left, index - 1); quicksort(arr, index + 1, right); } } static int partition(string[] a, int p, int r) { random rand = new random(); int randomnumber = rand.nextint(a.length); string pivot = a[randomnumber]; int left = p - 1; // index left side // next loop maintains these conditions // 1. every element of a[p..i] less or equal pivot. // 2. every element of a[i+1..j-1] greater pivot. // 3. a[r] equals pivot. (int j = p; j < r; j++) { // j index right side // find out side a[j] goes into. if left side, // have // increment size of left side , a[j] // position i. // if right side, a[j] want it, // incrementing // j in loop header suffices. if (a[j].compareto(pivot) <= 0) { left++; // a[j] belongs in left side, create 1 // larger swap(a, left, j); } } // dropped out of loop because j == r. every element of a[p..i] // less or equal pivot, , every element of a[i+1..r-1] // // greater pivot. if set pivot position i+1, // // have want: a[p..i] less or equal pivot, a[i+1] // equals pivot, , a[i+2..r] greater pivot. swap(a, left + 1, r); // homecoming index of pivot ended up. homecoming left + 1; } // swap elements @ 2 indices , j in array a. static void swap(string[] a, int i, int j) { string t = a[i]; a[i] = a[j]; a[j] = t; }

you choosing pivot randomly entire array, when should element of sublist on called partition:

int randomnumber = p+rand.nextint(r-p); string pivot = a[randomnumber];

once have chosen pivot should swap first or lastly element of sublist. makes easier write partition algorithm.

java arrays sorting quicksort partitioning

java - Generating emirps stop when a user enters a zero or negative integer. -



java - Generating emirps stop when a user enters a zero or negative integer. -

i have created programme using java generates emirps user input, need help on stopping user when entering 0 or negative integer. have tried many things when run programme 0 or negative number go crazy , give me infinite amount of numbers. appreciate if help me on this.

here got far...

import java.util.scanner; public class generateemirps { public static void main(string[] args) { scanner scanner = new scanner (system.in); system.out.print("enter number of desired emirps: "); int emrips = scanner.nextint(); int count = 1; for( int = 2; ; i++){ if ((isprime(i)) && (isprime(reverseit(i))) && (!ispalindrome(i))) { system.out.print(i + " "); if (count % 10 == 0) { system.out.println(); } if (count == emrips){ break; } count++; } } } public static boolean isprime(int num){ (int = 2; <=num / 2; i++){ if (num % == 0) { homecoming false; } } homecoming true; } public static int reverseit(int num){ int result = 0; while (num != 0) { int lastdigit = num % 10; result = result * 10 + lastdigit; num /= 10; } homecoming result; } public static boolean ispalindrome(int num){ homecoming num == reverseit(num); } }

solution:

you need test input before process it.

int emrips = scanner.nextint(); if (emrips <= 0) { system.exit(0); }

java primes

All combinations from data frame in R -



All combinations from data frame in R -

i'm trying find combinations (not permutations, order doesn't matter) list various restrictions on construction of each combination. know combn() trick simple list , i've tried using sample(), need more complex.

i have info frame has 3 columns, name, type, cost. want find possible combinations of names in sets of 7 (so 7 names) 1 of type 1, 3 of type 2 , rest of type 3 , total cost less set variable.

i'm @ total loss how , i'm not r right language in. should seek loop nested if statements?

> dput(head(sample)) structure(list(name = structure(c(6l, 8l, 4l, 9l, 2l, 5l), .label = c("amber", "cyndi", "e", "eric", "hannah", "jason", "jesse", "jim ", "lisa", "lucy", "matt", "ryan", "tat"), class = "factor"), type = c(2l, 3l, 3l, 1l, 3l, 3l), cost = c(6000l, 6200l, 9000l, 2000l, 8000l, 4500l)), .names = c("name", "type", "cost"), row.names = c(na, 6l), class = "data.frame")

and sessioninfo()

> sessioninfo() r version 3.1.1 (2014-07-10) platform: x86_64-apple-darwin10.8.0 (64-bit) locale: [1] en_us.utf-8/en_us.utf-8/en_us.utf-8/c/en_us.utf-8/en_us.utf-8 attached base of operations packages: [1] stats graphics grdevices utils datasets methods base of operations other attached packages: [1] plyr_1.8.1 ggplot2_1.0.0 dplyr_0.2 loaded via namespace (and not attached): [1] assertthat_0.1 colorspace_1.2-4 digest_0.6.4 grid_3.1.1 gtable_0.1.2 mass_7.3-33 [7] munsell_0.4.2 parallel_3.1.1 proto_0.3-10 rcpp_0.11.2 reshape2_1.4 scales_0.2.4 [13] stringr_0.6.2 tools_3.1.1

example data:

name type cost jason 2 6000 jim 3 6200 eric 3 9000 lisa 1 2000 cyndi 3 8000 hannah 3 4500 e 2 7200 matt 1 3200 jesse 3 1200 tat 3 3200 ryan 1 5600 amber 2 5222 lucy 2 1000

one possible combination if total cost set 60k:

lisa, jason, amber, lucy, tat, jesse, hannah

that's 1 possible combination, lisa type 1, jason, amber , lucy type 2 , remaining 3 type 3 , total cost of 7 below 60k. possible combination be:

ryan, jason, amber, lucy, tat, jesse, hannah

ryan has replaced lisa type 1 first combination. cost still below 60k.

i'm trying possible combinations conditions above true.

one possible solution using loops (maybe not efficient):

# illustration info name <- c('jason', 'jim','eric', 'lisa', 'cyndi', 'hanna','jon','matt', 'jerry','emily','mary','cynthia') type <- c(2, 1, 3, 3, 2, 3, 3, 1, 2, 2, 3, 2) cost <- c(9200, 8200, 9000, 8700, 9100, 8900, 9800, 7800, 9600, 9300, 8100, 7800) df <- data.frame(name, type,cost) v1 <- subset(df, type==1) v2 <- subset(df, type==2) v3 <- subset(df, type==3) # combinations of desired size of subsets m1 <- v1$name m2 <- combn(v2$name, 3) m3 <- combn(v3$name, 3) n1 <- length(m1) n2 <- ncol(m2) n3 <- ncol(m3) # set combinations of subsets all.combs <- as.list(rep(na, n1*n2*n3)) idx <- 1 (i in 1:n1) { (j in 1:n2) { (k in 1:n3) { all.combs[[idx]] <- c(as.character(m1[i]), as.character(m2[,j]), as.character(m3[,k])) idx <- idx + 1 } } } # check total cost < 60k cond <- rep(na, length(all.combs)) (i in 1:length(all.combs)) { sum <- 0 (j in 1:7) { sum <- sum + df$cost[df$name==all.combs[[i]][j]] } cond[i] <- sum < 60000 } res <- all.combs[cond] res

r combinations

c - How to allocate memory dynamically when array is declared with 1 element -



c - How to allocate memory dynamically when array is declared with 1 element -

consider construction following:

typedef struct { int arrcount; int arr[1]; } samplestruct, *psamplestruct;

i know arr int array needs dynamic memory allocation @ runtime , arrcount needs hold count of element. when seek allocate memory of, allow say, 10 elements using malloc, compiler throws error arr must modifiable value. cant create how allocate memory such array. also, have seen such examples in lot of windows headers, when trying implement it, totally lost.

while arr[1] not pointer, psamplestruct is. you'd this:

psamplestruct ss10arr = malloc(sizeof (*ss10arr) + (sizeof(ss10arr->arr) * 9)) create arr[0] through arr[9] valid.

note works because arr @ end of structure.

also note compiler options (like -d_fortify_source glibc , gcc) complain if seek access subsequent elements because observe overrun.

c windows visual-c++ dynamic-memory-allocation

ruby - Modeling a Subscription in Rails -



ruby - Modeling a Subscription in Rails -

so, after thinking on while, have no thought proper way model is.

i have website focused on sharing images. in order create users happy, want them able subscribe many different collections of images.

so far, there's 2 types of collections. 1 "creator" relationship, defines people worked on specific image. looks this:

class image < activerecord::base has_many :creations has_and_belongs_to_many :locations has_many :creators, through: :creations end class creator < activerecord::base has_many :images, ->{uniq}, through: :creations has_many :creations belongs_to :user end class creation < activerecord::base belongs_to :image belongs_to :creator end

users may tag image subjective tag, not objectively nowadays in image. typical subjective tags include "funny" or "sad," kind of stuff. that's implemented this:

class subjectivetag < activerecord::base # has "name" field. reason why names of tags first-class db model # can display how many times given image has been tagged specific tag end class subjectivecollection < activerecord::base # basically, "user x tagged image y tag z" belongs_to :subjective_tag belongs_to :user has_many :images, through: :subjective_collection_member end class subjectivecollectionmember < activerecord::base belongs_to :subjective_collection belongs_to :image end

i want users able subscribe both creators , subjectivetags, , display images in collections, sequentially, on home page when log in.

what best way this? should have bunch of different subscription types - example, 1 called subjectivetagsubscription , 1 called creatorsubscription? if go route, efficient way retrieve images in each collection?

what want utilize polymorphic association.

in case, this:

class subscription < activerecord::base belongs_to :user belongs_to :subscribeable, polymorphic: true end

the subscriptions table need include next fields:

user_id (integer) subscribeable_id (integer) subscribeable_type (string)

this setup allow subscription refer instance of other model, activerecord utilize subscribeable_type field record class name of thing beingness subscribed to.

to produce list of images logged in user, this:

subscription.where(user_id: current_user.id).map |subscription| subscription.subscribeable.images.all end.flatten

if performance implications of above approach intolerable (one query per subscription), collapse 2 types of subscribeables single table via sti (which doesn't seem thought here, 2 tables aren't similar) or go initial suggestion of having 2 different types of subscription models/tables, querying each 1 separately subscriptions.

ruby-on-rails ruby database rails-activerecord

c - Function deque to array not working -



c - Function deque to array not working -

hello have problem. made function:

void* deque2array(tdeque * d){ void *arr = null; int i; tnodo * aux = d->ppio; for(i=0; < d->cant; i++){ arr = aux->elem; arr++; aux=aux->sig; } homecoming arr; }

then made tester sure function works right.

tdeque * queue = createdeque(); int x=5; int y=2; int z=3; insertindeque(queue, &x); insertindeque(queue, &y); insertindeque(queue, &z); int* pointer = deque2array(queue); int i; for(i=0; i<numberofelements(queue); i++){ pointer = pointer + i; printf(" %d ", *pointer); }

but memory address , don't know doing wrong.

you doing several things wrong. first, posting incomplete code example. don't know d->ppio, d->cant, aux->sig, or aux->elem are, nor know whether setting them in insertindeque.

in deque2array:

arr = aux->elem

you want:

*arr = aux->elem

otherwise, function returning value stored in lastly aux->elem + 1. it's hard fathom how run without exception if it's supposed homecoming void*.

in tester:

pointer = pointer +

you modifying pointer on every iteration of loop. pointer on nth iteration of loop original value of pointer plus sum of integers 0 n, not original value of pointer plus i appears intended. again, miracle if code runs without exception, since reading memory beyond bounds of array. given big plenty homecoming value of numberofelements(queue), guaranteed produce error.

once you've fixed these problems, if assume aux->elem think is, , insertindeque think does, new problem inserting addresses of x, y, , z structure, not values, create sense corrected test code print addresses of variables. of now, since reading undefined memory locations, results not going create sense regardless of in info structure.

c arrays void-pointers

parsing - Handling nullable productions in LR(0) grammars -



parsing - Handling nullable productions in LR(0) grammars -

i think it's pretty straightforward question, couldn't find reply anywhere.

if have grammar non-terminal derivates null, this:

s -> b$ b -> idp p -> (e) p -> e -> b

how handle production #3 diagram lr(0) states of it? have include column corresponding transition empty set in lr(0) parsing table?

the item p -> · not different other item · @ right-hand end; fact nil precedes · not create special. closure of item

b -> id · p

will state q:

b -> id · p p -> · ( e ) p -> ·

from goto(q, p) indicate transition b -> id p · , goto(q, () indicate transition p -> ( · e ). goto on $ , ) not defined on state, action is; indicate p should reduced using p -> rule, after goto(q, p) used.

parsing syntax grammar

jquery - Using two var as comparison operators for if -



jquery - Using two var as comparison operators for if -

i'm scripting multi level force menu i've nail wall.

structure:

menu link 1 -> opens menu b

menu link 2 -> opens menu c

etc

when click link 1 opens menu b, when click link 2 closes menu b , opens menu c. ok

when click link 1 opens menu b, when click link 1 1 time again want close said menu , not open again.

so i'm storing opened menu level (the div stored in global var $2real) , storing target menu open same level (div stored in global var $2target) , added if ($2target != $2real) before calling function open menu (so doesn't open same menu again).

using console.log can see $2target $2real indeed same if anyway. tested using (1 != 1) , works, guess problem ($2target != $2real).

i can post code it's getting big. (and not pretty since don't have much experience)

because comparing jquery objects, not elements

if ($2target.get(0) != $2real.get(0))

or utilize is()

if ($2target.is($2real))

jquery html

spring-boot application displaying html code for view when executed in the browser -



spring-boot application displaying html code for view when executed in the browser -

i start work spring-boot in spring projects, , right facing problem:

i have 1 spring-boot application main class:

@configuration @enableautoconfiguration @componentscan public class application { public static void main(string[] args) { springapplication.run(application.class, args); } }

and controller:

@controller public class acessocontroller { @requestmapping(value = "/signin") public string signin(model model) { homecoming "acesso/signin"; } @requestmapping(value = "/admin") public string admin(model model) { homecoming "private/admin"; } @requestmapping(value = "/index") public string index(model model) { homecoming "public/index"; } }

when run application , seek access url mapping /signin, example, browser display html code view, instead of actual content.

what doing wrong here?

are trying render view using template engine, or homecoming static html file?

if trying render template, not have right dependency in place pull in template engine. (per code, believe trying do.) if don't intend utilize template engine templates, want 1 render html you. depending on spring-boot setup, seek starting spring-boot-starter-web, or pull in thymeleaf (spring-boot-starter-thymeleaf) or freemarker (spring-boot-starter-freemarker) specifically.

if want homecoming static content , not want custom configuration, you'll need place files in location , not need specific controller request mappings.

http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-spring-mvc-static-content

spring spring-mvc spring-boot

sql server - SQL identify whether a word in nvarchar variable is listed in lookup table -



sql server - SQL identify whether a word in nvarchar variable is listed in lookup table -

i writing procedure automatically overwrite profane words entered user on form , replace text asterisks if word in question in lookup database.

for sake of example, let's assume flubber rude word in our profanity table , need flag when it's entered word on own. 'flubber' needs flagged inappropriate, 'flubbermost' fine.

user enters: watching flubber.

what want update info in field with: watching *******. or variation of that, perhaps f****r.

i've tried using contains (and i'm trying identify whether have profane word @ stage)

declare @string nvarchar(4000) set @string = n'i watching flubber' select myword mylookup contains(myword,@string)

but next message

msg 7630, level 15, state 3, line 4 syntax error near 'really' in full-text search status 'i watching flubber'.

any help gratefully received.

edit:

following help ahiggins i've added total text index , next code works well:

declare @string nvarchar(4000) declare @matchedword nvarchar(100) declare @returnstring nvarchar(4000) set varstring = 'i watching flubber' select varmatchedword = myword mylookup freetext (descr,@string) print convert(varchar(4000),@matchedword)

and returns info when whole word found - perfect.

onto sec part of question: what's best way of substituting word 'flubber' '*******' please?

given new requirements, i'm going point towards this answer suggests (strongly) utilize total text search functionality in sql server. if unavailable, though, can take performance nail of doing , utilize next code:

select myword, @string searchphrase mylookup '.' + @string + '.' '%[^a-z]'+myword+'[^a-z]%'

full illustration sample data:

declare @mylookup table (myword varchar(20)) insert @mylookup (myword) values ('flubber') declare @string nvarchar(4000) set @string = n'i watching flubbers' select myword, @string searchphrase @mylookup '.' + @string + '.' '%[^a-z]'+myword+'[^a-z]%' set @string = n'i watching flubber.' select myword, @string searchphrase @mylookup '.' + @string + '.' '%[^a-z]'+myword+'[^a-z]%' set @string = n'i watching flubber, weird?' select myword, @string searchphrase @mylookup '.' + @string + '.' '%[^a-z]'+myword+'[^a-z]%' set @string = n'i watching flubber movie' select myword, @string searchphrase @mylookup '.' + @string + '.' '%[^a-z]'+myword+'[^a-z]%' set @string = n'i watching flubber!' select myword, @string searchphrase @mylookup '.' + @string + '.' '%[^a-z]'+myword+'[^a-z]%' set @string = n'i watchingflubber' select myword, @string searchphrase @mylookup '.' + @string + '.' '%[^a-z]'+myword+'[^a-z]%'

edit: talk moving target ... i've taken code comment (using total text search) , printed off homecoming string replace word asterisks.

note if word shows multiple times in same search string, replace instances. don't have access instance total text search enabled, you'll have confirm working expected.

declare @string nvarchar(4000) declare @matchedword nvarchar(100) declare @returnstring nvarchar(4000) set @string = 'i watching flubber' select @matchedword = myword, @returnstring = replace(@string, myword, replicate('*', len(myword))) mylookup freetext (descr,@string) print convert(varchar(4000), @matchedword) print convert(varchar(4000), @returnstring)

sql sql-server

java - Prevent file channel from closing after reading xml file -



java - Prevent file channel from closing after reading xml file -

for more detailed info regarding motivation behind goal (and efforts solve it) view previous question. decided inquire new question exclusively thought had evolved sufficiently merit doing so. summary, intend utilize jdom in combination nio in order to:

gain exclusive file lock on xml file. read file document object. make arbitrary changes (with lock still active!). write changes xml file. release file lock.

the issue getting built-in code read xml file document object closes channel (and hence releases lock), seen below:

import java.io.*; import java.nio.channels.channels; import java.nio.channels.filechannel; import javax.xml.parsers.*; import org.w3c.dom.document; import org.xml.sax.saxexception; public class test4{ string path = "test 2.xml"; private documentbuilderfactory dbfactory; private documentbuilder dbuilder; private document doc; public test4(){ seek (final filechannel channel = new randomaccessfile(new file(path), "rw").getchannel()) { dbfactory = documentbuilderfactory.newinstance(); dbuilder = dbfactory.newdocumentbuilder(); system.out.println(channel.isopen()); doc = dbuilder.parse(channels.newinputstream(channel)); system.out.println(channel.isopen()); channel.close(); } grab (ioexception | parserconfigurationexception | saxexception e) { e.printstacktrace(); } } public static void main(string[] args){ new test4(); } }

output:

true false

having looked through documentation , trawled built in java libraries, struggling find channel closed, allow lone how prevent closing. pointers great! thanks.

one clean way create filterinputstream , override close nothing:

public test() { seek { channel = new randomaccessfile(new file(path), "rw").getchannel(); dbfactory = documentbuilderfactory.newinstance(); dbuilder = dbfactory.newdocumentbuilder(); system.out.println(channel.isopen()); nonclosinginputstream ncis = new nonclosinginputstream(channels.newinputstream(channel)); doc = dbuilder.parse(ncis); system.out.println(channel.isopen()); // closes here. ncis.reallyclose(); channel.close(); //redundant } grab (ioexception | parserconfigurationexception | saxexception e) { e.printstacktrace(); } } class nonclosinginputstream extends filterinputstream { public nonclosinginputstream(inputstream it) { super(it); } @override public void close() throws ioexception { // nothing. } public void reallyclose() throws ioexception { // close. in.close(); } }

java xml concurrency io channel

html - How to Get My Header Set Up Using Bootstrap? -



html - How to Get My Header Set Up Using Bootstrap? -

i finish noob when comes using bootstrap, or html. made simple banner using photoshop , simple nav-bar high school robotics team, having problem comprehending bootstrap's grid system. reason, navbar cutting off banner. want banner below navbar, how using bootstrap?

<!doctype html> <html> <head> <title>robotics team 3774 home</title> <!-- link stylesheet --> <link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css"> <link rel="stylesheet" type="text/css" href="css/index1.css"> <!-- mobile scaling --> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <!-- navbar --> <div class="navbar navbar-inverse navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header"> <a class="navbar-brand" href="#">team 3774</a> </div> <div class="navbar-collapse collapse" style="height: 0.866667px;"> <ul class="nav navbar-nav"> <li><a href="#">team bio</a></li> <li><a href="#">our robot</a></li> <li><a href="#">our coach</a></li> <li><a href="#">gallery</a></li> <li><a href="#">outreach</a></li> <li><a href="#">youtube</a></li> </ul> </div> </div> </div> <!-- banner --> <div class="banner"> <img src="banner.png" class="img-responsive" alt="responsive image"> </div> </body>

bootstrap doesn't have banner element, , grid scheme isn't related placing item page. if want banner spans page navbar does, want @ jumbotron element. have replace "banner" class "jumbotron" so:

<!-- banner --> <div class="jumbotron"> <img src="banner.png" class="img-responsive" alt="reponsive image" /> </div>

then need add together little custom styling hide grayness background , have banner image take width of screen:

.jumbotron { padding-left:0; padding-right:0; padding-bottom:0; }

that should it. had edit reply 1 time saw had posted link website.

demo here

html css twitter-bootstrap

web - Ubuntu nginx 404 error -



web - Ubuntu nginx 404 error -

cryptopals site

can access webpage? says me

404 not found

nginx/1.4.6 (ubuntu)

i using ubuntu 14.1, newest version. searched on google didn't find help me solve problem.. don't know if problem related website or computer..

this server side error, can nil else contact webmaster notify page here not anymore.

this classical error, , never fixed since page removed due reowrk or because content not anymore considered accurate.

https://en.wikipedia.org/wiki/list_of_http_status_codes

ubuntu web

java - Search for a string in a htm file -



java - Search for a string in a htm file -

i want school app , hence want automatic notification service. have our school called "deputy plan" (im german.. dont know, if understand mean, doesnt matter) , it's online htm file. in file written courses canceled or represented teacher. want create service recognizes if written in plan concerns user of app.. hence want search string in htm file. possible? or recommend method?

get page's source

url url = new url("http://www.example.com/"); bufferedreader in = new bufferedreader(new inputstreamreader(url.openstream())); string row = ""; string text = ""; while ((row = in.readline()) != null) { text += row; } in.close();

then find string in text

if (text.contains("yourstring")) { system.out.print("found!"); }

you should seek homework way

java android html

How to detect JPA mapped fields with Java Reflection -



How to detect JPA mapped fields with Java Reflection -

i need iterate on class , figure out fields jpa mapped , not transient. don't want check every annotation on fields, shortcut that?

thanks

java jpa reflection

Parse URL (ActionScript 3.0) -



Parse URL (ActionScript 3.0) -

i know how 1 parse url.

protocol://mydomain.com/something/morethings/this_is_what_i_want/even_if_it_has_slashes

i need "this_is_what_i_want/even_if_it_has_slashes"

how should this?

thanks!

try :

var u:string = 'protocol://mydomain.com/something/morethings/this_is_what_i_want/even_if_it_has_slashes', a:array = u.split('/'), s:string = '' for(var i=0; i<a.length; i++){ if(i > 3){ s += '/'+a[i] } } trace(s) // gives : /morethings/this_is_what_i_want/even_if_it_has_slashes

actionscript-3 url

ios - why does swift dictionary with function work outside of a class but produces error inside of a class? -



ios - why does swift dictionary with function work outside of a class but produces error inside of a class? -

i came across issue (and playground able locate it)

i seek utilize dictionary, has numbers keys , functions values. works fine outside of class:

private func hello1(x: double) { println("hello1") } private func hello2(x: double) { println("hello2") } private allow contacts: [int: double -> ()] = [ 0 : hello1, 1 : hello2 ] contacts[1]?(1.0) // works fine :-)

when set identical code within class, compiler error

'double' not subtype of 'someclass'

with identical code:

internal class someclass { private func hello1(x: double) { println("hello1") } private func hello2(x: double) { println("hello2") } private allow contacts: [int: double -> ()] = [ // *** here error *** 0 : hello1, 1 : hello2 ] internal func runit() { contacts[1]?(1.0) } } allow someclass = someclass() someclass.runit()

i tried several ways of brackets. no improvements.

what did missed when learning swift? did misunderstand or misinterpret?

hello1 , hello2 instance method. if referenced someclass.hello1, type someclass -> (double) -> (). can phone call this:

var foo = someclass() someclass.hello1(foo)(1.0)

it's curried function. , why got error 'double' not subtype of 'someclass'.

if want want, should this:

internal class someclass { private func hello1(x: double) { println("hello1") } private func hello2(x: double) { println("hello2") } lazy private var contacts: [int: double -> ()] = [ 0 : self.hello1, 1 : self.hello2 ] internal func runit() { contacts[1]?(1.0) } }

you have utilize lazy var instead of let, or cannot reference self.

added:

above code makes strong reference cycles. should utilize closures [unowned self].

lazy private var contacts: [int: double -> ()] = [ 0 : {[unowned self] in self.hello1($0) }, 1 : {[unowned self] in self.hello2($0) } ]

ios xcode osx swift

bash - substr in awk statement from xml parse -



bash - substr in awk statement from xml parse -

link original question: bash script extract xml info column format , modification , explanation ->

something within line of code not right , believe substr portion , because don't have total understanding , larn how improve understand it. yes have looked @ documentation , not clicking. couple examples reply helpful.

awk -f'[<>]' 'begin{a["stkpr"]="prod";a["stksvblku"]="prod";a["stksvblock"]="prod";a["stksvblk2"]="test";} /name/{name=$3; type=a[substr(name,length(name))]; if (length(type)==0) type="test";} /sessionhost/+/host/{print type, name, $3;}'|sort -u

this bit here:

type=a[substr(name,length(name))]; if (length(type)==0) type="test";

here xml format each bit block each host contains hostname , ip.

<?xml version="1.0"?> <connection> <connectiontype>putty</connectiontype> <createdby>someone</createdby> <creationdatetime>2014-10-27t11:53:32.0157492-04:00</creationdatetime> <credentialconnectionid>9f3c3bcf-068a-4927-b996-ca52154cae3b</credentialconnectionid> <description>red hat enterprise linux 5 (64-bit)</description> <events> <opencommentprompt>true</opencommentprompt> <warnifalreadyopened>true</warnifalreadyopened> </events> <group>path/to/group/name</group> <id>f2007f03-3b33-47d3-8335-ffd84ccc0e6b</id> <metainformation /> <name>stksprdapp01111</name> <openembedded>true</openembedded> <pinembeddedmode>false</pinembeddedmode> <putty> <alwaysaskforpassword>true</alwaysaskforpassword> <domain>domain</domain> <fontsize>12</fontsize> <host>10.0.0.111</host> <port>22</port> <portfowardingarray /> <telnetencoding>ibm437</telnetencoding> </putty> <stamp>85407098-127d-4d3c-b7fa-8f174cb1e3bd</stamp> <submode>2</submode> <templatename>ssh-perusercreds</templatename> </connection>

what want similar referenced link above. here want match -->

begin{a["stkpr"]="prod";a["stksvblku"]="prod";a["stksvblock"]="prod";a["stksvblk2"]="test";

and of rest test. best read previous post help create 1 more understandable. give thanks you.

because keys here of different length, substr approach less optimal. try:

awk -f'[<>]' '/name/{n=$3;t="test"; if(n ~ /^stkpr/) t="prod"; if (n ~/^stksvblku/) t="prod"; if (n ~/^stksvblock/) t="prod"} /sessionhost/+/host/{print t, n, $3;}' sample.xml |sort -u test stksprdapp01111 10.0.0.111 how works

in case, type, denoted t, set according series of if statements. above code, are:

t="test" if (n ~ /^stkpr/) t="prod" if (n ~ /^stksvblku/) t="prod" if (n ~ /^stksvblock/) t="prod"

by setting t="test", test becomes default: type test unless statement matches. if of next statements looks @ string begins host name and, if there match, sets type t new value. (when regular look begins ^, means follows must match @ origin of string.)

alternative using fancier regular expressions

since above 3 if statements prod type, 3 of them could, if preferred, rearranged to:

t="test" if (n ~ /^stk(pr|svblku|svblock)/) t="prod"

(metalcated: fixed unmatched parentheses bracket)

xml bash awk xml-parsing substr

c++ - Recursion Binary to Decimal - completely stuck -



c++ - Recursion Binary to Decimal - completely stuck -

i using c++ write programme uses recursion convert user input binary number decimal. i've played code hours

(earlier initialized i i = binary.length();)

void bin2dec(string binary, int i) { double decnum=0; if (i >= 0) { if (binary[i] = 0) { decnum = (decnum + 0); } else { decnum = (decnum + pow(2, (i-1))); } bin2dec(binary, i-1); } cout << decnum; }

that recursion function. unfortunately, stuck. programme runs gives me wrong values. example, when plug in 1 binary, expect 1 decimal in return. .5 number. calculation wrong or using recursion incorrectly?

thank you!

upon receiving suggestions, made next changes. however, programme still returns wrong value.

void bin2dec(string binary, int i) { double decnum=0; if (i >= 0) { if (binary[i] == 1) { decnum = (decnum + pow(2, i)); } else if (binary[i] == 0) { decnum = (decnum + 0); } bin2dec(binary, - 1); cout << decnum; } }

assuming using little endian, should utilize pow(2, i). i-1, going have 1 in position 0 in array, means evaluate pow(2, -1), 0.5.

consider working illustration (https://ideone.com/pwvagp):

int bintodec(string binary, unsigned int = 0) { int tot = 0; if (i < binary.length()) { if (binary[i] == '1') tot = pow(2, i); else if (!binary[i] == '0') throw "string not formatted in binary"; homecoming tot + bintodec(binary, ++i); } homecoming tot; }

note it's possible start @ end of string , work backwards, prefer starting @ 0 since think simpler. total additions, easiest thing homecoming phone call of function, did @ end of if(i < binary.length() block. 1 time have nail base of operations case (in case i == binary.length()), homecoming 0, added total number doesn't alter it. 1 time base of operations case has returned, others begin returning portion of sum 1 above them, keeps getting added until reaches bottom of phone call stack, original calling function.

if not want homecoming answer, alter function signature void bintodec(int& tot, string binary, unsigned int = 0) , maintain adding value tot rather returning it, requires caller gives int modify.

c++ recursion

elseif in php code is not working -



elseif in php code is not working -

this php code. else if statement not working. please help me.thanks in advance.

if($row=mysql_fetch_array($result1,mysql_assoc)){ $pv=$row['pv']; $cv=$row['cv']; if($pv=="first_name"){ $sql1="update user set fname='$cv' id='$id'"; $result1=mysql_query($sql1); }elseif($pv=="lastname"){ $sql1="update user set lname='$cv' id='$id'"; $result1=mysql_query($sql1); } }

your code looks okay rid of elseif

if($row=mysql_fetch_array($result1,mysql_assoc)){ $cv=$row['cv']; $column="fname"; if($row['pv']=="lastname"){ $column="lname"; } $sql1="update user set $column='$cv' id='$id'"; $result1=mysql_query($sql1); }

php

MYSQL Stored procedure for concatenating code -



MYSQL Stored procedure for concatenating code -

i have table contain fields(id,code,name,...), when want insert new record code field should (abc-001) , next record should (abc-002) , on. want write mysql procedure don't know how, body has idea? in advance

first user insert query like:

insert yourtable values(..,'abc',...);

now write trigger after update set code value in expected format:

create trigger triggernmae after insert on yourtable each row begin update yourtable set code = concat(code,'-',lpad(new.id,3,'0')); id = new.id ; end;

mysql

datatable - Scrollable horizontal and vertical table with fixed top and left headers JSF - icefaces -



datatable - Scrollable horizontal and vertical table with fixed top and left headers JSF - icefaces -

i'm facing problem can't solve. i'm using icefaces , mojarra implementation. want create table fixed header on top , left scrollable info (horizontal , vertical).

just set simple want table similar excel environment. if scroll right header on top moves right first column remeins fixed, if scroll downwards header on top has remain fixed first column has scroll down.

i did normal datatable headers on top , different table on left. using jquery, i'm assigning scroll position of datatable left table, incredibly slow. moving scroll , downwards user sees mismatch between rows , left header , after time table result aligned again.

there way icefaces without jquery ? told me utilize iframe, can help me finding infos ? in advance.

you can utilize icefaces ace:datatable component. has both column pinning, fixed header , footer.

jsf datatable icefaces

html - Centering span near an image with the respect to the wrapper div -



html - Centering span near an image with the respect to the wrapper div -

how both vertically , horizontally center span element without using tables?

i need image on left , thereafter span aligned in center of wrapper div. span element should not aligned in between img , right side, whole div itself.

fiddle

class="snippet-code-html lang-html prettyprint-override"><div style="height: 100px; background-color:black;color:white;"> <img style="height:100px;" src="http://www.kiplinger.com/quiz/business/t049-s001-test-your-start-up-know-how/images/all-small-businesses-have-to-be-incorporated1.jpg"> <span class="hejsa">hej du</span> </div>

as op stated:

i need span centered respect whole site.

one alternative position <span> element absolutely , align text center horizontally , vertically follows:

method #1:

using top/left , transform properties:

class="snippet-code-css lang-css prettyprint-override">.wrapper { position: relative; height: 100px; background-color:black; color:white; } .wrapper > span.hejsa { position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); -moz-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); -o-transform: translate(-50%, -50%); transform: translate(-50%, -50%); } class="snippet-code-html lang-html prettyprint-override"><div class="wrapper"> <img style="height:100px;" src="http://www.kiplinger.com/quiz/business/t049-s001-test-your-start-up-know-how/images/all-small-businesses-have-to-be-incorporated1.jpg" /> <span class="hejsa"> lorem ipsum dolor sit down amet... </span> </div>

it's worth noting css transform not supported in ie8 , olders (which not op's concern s/he mentioned in comments)

method #2:

expanding absolutely positioned <span> element top/right/bottom/left properties:

class="snippet-code-css lang-css prettyprint-override">.wrapper { position: relative; height: 100px; background-color:black; color:white; } /* .wrapper > img { position: relative; z-index: 1; } */ /* optional */ .wrapper > span.hejsa { position: absolute; top: 0; left: 0; right: 0; bottom: 0; line-height: 100px; text-align: center; } class="snippet-code-html lang-html prettyprint-override"><div class="wrapper"> <img style="height:100px;" src="http://www.kiplinger.com/quiz/business/t049-s001-test-your-start-up-know-how/images/all-small-businesses-have-to-be-incorporated1.jpg" /> <span class="hejsa"> lorem ipsum dolor sit down amet... </span> </div>

this method has wider browser support, 1 drawback of text should not multiline.

html css vertical-alignment

ruby on rails - Paperclip saving files in the right folder but giving the wrong url -



ruby on rails - Paperclip saving files in the right folder but giving the wrong url -

here paperclip initiaizer:

paperclip.options[:command_path] = "/usr/local/bin/" paperclip::attachment.default_options[:storage] = :fog paperclip::attachment.default_options[:fog_credentials] = {:provider => "local", :local_root => "#{rails.root}/public/system"} paperclip::attachment.default_options[:fog_directory] = "" paperclip::attachment.default_options[:use_timestamp] = false

in model have:

class auto < activerecord::base has_attached_file :logo, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png", :url => "/system/cars/logo/:id/:style/:filename" validates_attachment_content_type :logo, :content_type => /\aimage\/.*\z/ end

but reasons when do: car.last.logo.url get: http://localhost:3000/cars/logo/18/original/7450392a-5e39-11e4-9a87-bea65d182201.png instead of http://localhost:3000/system/cars/logo/18/original/7450392a-5e39-11e4-9a87-bea65d182201.png

i don't understand i'm doing wrong.

ruby-on-rails paperclip

android - PhoneGap webview function calls from native code not executing after font change -



android - PhoneGap webview function calls from native code not executing after font change -

i'm developing app has partial functionality implemented in phonegap , partial in native android. it's works great mostly. don't save state when app killed os on configuration change, memory recovering etc. when came app after font change, phonegap function calls native code don't execute, rather these calls beingness queued @ phonegap side. when action performed on phonegap webview, queued calls executed. have thought unusual behavior.

fixed after debugging in cordova. having few plugin calls in onresume() on main activity. when app resumed after oncreate() called followed onresume() , process faster normal launch. cordava not loaded in time plugin calls, in onresume() followed after coming plugin calls, stucked in cordova queue , never executed again. fix, skipped plugin calls in onresume() when savedinstancestate != null.

android cordova cordova-plugins cordovawebview

cocos2d x - MenuItemImage get touch coordinates -



cocos2d x - MenuItemImage get touch coordinates -

i have menuitemimage when touched calls registered callback.

void callback(ref* psender) { ... }

is possible psender actual touch coordinates?? way can see if touched pixel transparent on image or not.

cocos2d-x cocos2d-x-3.0

ruby on rails - Create packages with active_shipping -



ruby on rails - Create packages with active_shipping -

i utilize active_shipping gem calculate shipping cost , have problem.my bundle can have several identical objects. utilize packageitem class these when utilize find_rates method have error.

nomethoderror: undefined method 'inches' #<activemerchant::shipping::packageitem:0x007fec95f24610>

that illustration how utilize it:

origin = location.new(country: 'us', zip: '91801') dest = location.new(country: 'us', zip: '90001') packages = packageitem('test', 32, 18, 15, units: :imperial) carrier = usps.new(login: 'login') carrier.find_rates(origin, dest, packages)

this initializer packageitem:

def initialize(name, grams_or_ounces, value, quantity, options = {}) @name = name majestic = (options[:units] == :imperial) || (grams_or_ounces.respond_to?(:unit) && m.unit.to_sym == :imperial) @unit_system = majestic ? :imperial : :metric @weight = attribute_from_metric_or_imperial(grams_or_ounces, mass, :grams, :ounces) @value = package.cents_from(value) @quantity = quantity > 0 ? quantity : 1 @sku = options[:sku] @hs_code = options[:hs_code] @options = options end

value item cost, thats how understand this.

if using usps carrier, error can create in place:

def self.size_code_for(package) if package.inches(:max) <= 12 'regular' else 'large' end end

thanks!

i think need using package module instead of packageitem module (which doesn't appear have quantity, you'll have duplicate package objects higher quantities).

see note documentation of packageitem: (http://www.rubydoc.info/github/shopify/active_shipping/activemerchant/shipping/packageitem)

this required shipping methods (label creation) right now.

ruby-on-rails activemerchant

android - Custom Cursor Adapter Error When Running, Illegal Argument Exception -



android - Custom Cursor Adapter Error When Running, Illegal Argument Exception -

i have updated post changes, inserted '_id', , working should

i hope can help problem quite new android , java. have created app uses sqlite database, using custom cursor adapter print out 1 line of database along 2 buttons , edittext. think have right code when seek , run app getting illegalargumentexception, have been looking through forum few days , still stuck. if point out error , help me prepare great!

this main activity

import android.app.activity; import android.content.intent; import android.database.cursor; import android.os.bundle; import android.util.log; import android.view.layoutinflater; import android.os.handler; import android.view.view; import android.view.viewgroup; import android.widget.baseadapter; import android.widget.button; import android.widget.listview; import android.widget.toast; import com.pinchtapzoom.r; import java.io.file; import java.io.filenotfoundexception; import java.io.fileoutputstream; import java.io.ioexception; import java.io.inputstream; import java.io.outputstream; public class myactivity extends activity { private customcursoradapter customadapter; //private com.example.rory.dbtest.dbadapter databasehelper; public listview list1; com.example.rory.dbtest.dbadapter db = new com.example.rory.dbtest.dbadapter(this); //customcursoradapter c = new customcursoradapter(this,c); @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_my); list1 = (listview)findviewbyid(r.id.data_list); db.open(); button addbtn = (button)findviewbyid(r.id.add); addbtn.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { intent = new intent(myactivity.this, addassignment.class); startactivity(i); } }); button deletebtn = (button)findviewbyid(r.id.delete); deletebtn.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { intent = new intent(myactivity.this, delete.class); startactivity(i); } }); button updatebtn = (button)findviewbyid(r.id.update); updatebtn.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { intent = new intent(myactivity.this, update.class); startactivity(i); } }); seek { string destpath = "/data/data/" + getpackagename() + "/databases/assignmentdb"; file f = new file(destpath); if (!f.exists()) { copydb( getbasecontext().getassets().open("mydb"), new fileoutputstream(destpath)); } } grab (filenotfoundexception e) { e.printstacktrace(); } grab (ioexception e) { e.printstacktrace(); } new handler().post(new runnable() { @override public void run() { //log.d("test", "customadapter " + customadapter.tostring()); //log.d("test", "databasehelper " + databasehelper.tostring()); customadapter = new customcursoradapter(myactivity.this, db.getallrecords()); list1.setadapter(customadapter); } }); } private class dbadapter extends baseadapter { private layoutinflater minflater; //private arraylist<> @override public int getcount() { homecoming 0; } @override public object getitem(int arg0) { homecoming null; } @override public long getitemid(int arg0) { homecoming 0; } @override public view getview(int arg0, view arg1, viewgroup arg2) { homecoming null; } } public void copydb(inputstream inputstream, outputstream outputstream) throws ioexception { //---copy 1k bytes @ time--- byte[] buffer = new byte[1024]; int length; while ((length = inputstream.read(buffer)) > 0) { outputstream.write(buffer, 0, length); } inputstream.close(); outputstream.close(); } }

this database class

import android.content.contentvalues; import android.content.context; import android.database.cursor; import android.database.sqlexception; import android.database.sqlite.sqlitedatabase; import android.database.sqlite.sqliteopenhelper; import android.util.log; public class dbadapter { public static final string key_rowid = "_id"; public static final string key_item = "item"; public static final string key_litres = "litres"; private static final string tag = "dbadapter"; private static final string database_name = "dripdrop"; private static final string database_table = "assignments"; private static final int database_version = 1; private static final string database_create = "create table if not exists assignments (_id integer primary key autoincrement, " + "item varchar not null, litres date );"; private final context context; private databasehelper dbhelper; private sqlitedatabase db; public dbadapter(context ctx) { this.context = ctx; dbhelper = new databasehelper(context); } private static class databasehelper extends sqliteopenhelper { databasehelper(context context) { super(context, database_name, null, database_version); } @override public void oncreate(sqlitedatabase db) { seek { db.execsql(database_create); } grab (sqlexception e) { e.printstacktrace(); } } @override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { log.w(tag, "upgrading database version " + oldversion + " " + newversion + ", destroy old data"); db.execsql("drop table if exists contacts"); oncreate(db); } } //---opens database--- public dbadapter open() throws sqlexception { db = dbhelper.getwritabledatabase(); homecoming this; } //---closes database--- public void close() { dbhelper.close(); } //---insert record database--- public long insertrecord(string item, string litres) { contentvalues initialvalues = new contentvalues(); initialvalues.put(key_item, item); initialvalues.put(key_litres, litres); homecoming db.insert(database_table, null, initialvalues); } //---deletes particular record--- public boolean deletecontact(long rowid) { homecoming db.delete(database_table, key_rowid + "=" + rowid, null) > 0; } //---retrieves records--- public cursor getallrecords() { homecoming db.query(database_table, new string[] {key_rowid, key_item, key_litres}, null, null,null, null, null); } //---retrieves particular record--- public cursor getrecord(long rowid) throws sqlexception { cursor mcursor = db.query(true, database_table, new string[] {key_rowid, key_item, key_litres}, key_rowid + "=" + rowid, null, null, null, null, null); if (mcursor != null) { mcursor.movetofirst(); } homecoming mcursor; } //---updates record--- public boolean updaterecord(string item, string litres) { db.execsql("update "+database_table+" set "+key_litres+"='"+litres+"' "+key_item+"='"+item+"'"); homecoming true; } }

this custom cursor class import android.content.context; import android.database.cursor; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.cursoradapter; import android.widget.textview; import com.pinchtapzoom.r;

public class customcursoradapter extends cursoradapter { public customcursoradapter(context context, cursor c) { super(context, c); } @override public view newview(context context, cursor cursor, viewgroup parent) { // when view created first time, // need tell adapters, how each item layoutinflater inflater = layoutinflater.from(parent.getcontext()); view retview = inflater.inflate(r.layout.row, parent, false); homecoming retview; } @override public void bindview(view view, context context, cursor cursor) { // here setting our info // means, take info cursor , set in views textview textviewpersonname = (textview) view.findviewbyid(r.id.item1); textviewpersonname.settext(cursor.getstring(cursor.getcolumnindex(cursor.getcolumnname(1)))); } }

and logcat error getting when run app

4501-4501/com.example.rory.dbtest e/androidruntime﹕ fatal exception: main process: com.example.rory.dbtest, pid: 4501 java.lang.illegalargumentexception: column '_id' not exist @ android.database.abstractcursor.getcolumnindexorthrow(abstractcursor.java:303) @ android.widget.cursoradapter.init(cursoradapter.java:172) @ android.widget.cursoradapter.<init>(cursoradapter.java:120) @ com.example.rory.dbtest.customcursoradapter.<init>(customcursoradapter.java:19) @ com.example.rory.dbtest.myactivity$4.run(myactivity.java:94)

basically need alter id column _id because when using custom cursor adapter requires column _id there. it's unwritten rule of using databases custom cursor adapter

android sqlite logcat

asp.net web api routing - Can I overload a Web API get call? -



asp.net web api routing - Can I overload a Web API get call? -

i'm trying set web api app able take like

/api/product/1 1 id , /api/product/somestringidentifier

the latter can not nail get(string alias) method. (int id) , getproducts() work fine.

routes

config.routes.maphttproute( name: "defaultapi", routetemplate: "api/{controller}/{id}", defaults: new { id = routeparameter.optional } ); config.routes.maphttproute( name: "aliasselector", routetemplate: "api/{controller}/{alias}" );

controller

[acceptverbs("get")] public iproduct get(int id) { homecoming new product(id); } [acceptverbs("get")] public iproduct get(string alias) { homecoming new product(alias); } [acceptverbs("get")] [actionname("products")] public ienumerable<iproduct> getproducts() { homecoming new products().tolist(); }

assuming id going integer , alias going string, seek adding route constraints so:

config.routes.maphttproute( name: "defaultapi", routetemplate: "api/{controller}/{id}", defaults: new { id = routeparameter.optional }, constraints: new { id = @"\d*" } ); config.routes.maphttproute( name: "aliasselector", routetemplate: "api/{controller}/{alias}", constraints: new { alias= @"[a-za-z]+" } );

asp.net-web-api-routing

javascript - Couchdb's Update Event Handler in Node.js -



javascript - Couchdb's Update Event Handler in Node.js -

i want create app in node.js. app modified document, lets :

{_id: xxx, text: "hello"}

every time document changed, want execute function in node.js app. it's

$db.on('update', function(id){ console.log("there changes in " + id) })

how can node.js ?

you looking couchdb's changes feed. every time document updated in db, have subscribed to, notification sent. can hear on notification , execute code.

you can subscribe particular document id's. see request options in post request.

also since using node js suggest take @ follow library. makes want lot easier.

example:-

var follow = require('follow'); follow({db: "<database name here>", include_docs:true}, function(error, change) { if(!error) { console.log(change.doc) // updated doc console.log("got alter number " + change.seq + ": " + change.id); } });

javascript node.js couchdb

angularjs - Visual Studio (2013), Resharper and AnglarJS - angle brackets in expressions causes Tag 'div' not closed warning -



angularjs - Visual Studio (2013), Resharper and AnglarJS - angle brackets in expressions causes Tag 'div' not closed warning -

in asp.net mvc project, using angularjs framework in visual studio 2013 resharper, including resharper angularjs plug in, angle brackets in expressions causes html validation warnings in editor.

i believe warnings generated resharper, though angularjs plug in present.

example:

in code sample, 'greater than' symbol '>' seen ide closing html element.

<div> <span class="table-header">description</span> <span><input type="text" ng-model="item.file.description" ng-disabled="item.progress > 0" /></span> </div>

how looks in visual studio. pop out of view in image reports "tag 'div' not closed"

is there alternate syntax can utilize in angularjs expression, or other means of having ide recognise angle bracket not intended close html element?

angularjs visual-studio-2013 resharper

node.js - Is NPM - node-soap support WsHttpBinding? -



node.js - Is NPM - node-soap support WsHttpBinding? -

i getting error status code 415 while calling method written in wcf service. later identified error caused because of default protocol used in wcf service wshttpbinding.

after altering config basichttpbinding, response started getting successfully, security aspect not right way handle this.

npm bundle link

is there alternative back upwards wshttpbinding soap client?

thanks peter

anyone can reply if wshttpbinding supported node-soap clients ?

i read: "as wshttpbinding built using ws-* specifications, not back upwards wider ranges of clients , cannot consumed older .net versions less 3 version"

source: http://www.codeproject.com/articles/36396/difference-between-basichttpbinding-and-wshttpbind

node.js wcf soap wcf-binding

hash - Persisting Hashes in Ruby -



hash - Persisting Hashes in Ruby -

i trying solve simple ruby quiz problem , having problem working hashes. when create wallet regular variable loop has no thought bout variable wallet , when create @wallet merge not persisted when returned after loop.

i have tried merge! collect garbage , keeps info previous test.

class coins coinstar = { :h=>50,:q=>25,:d=>10,:n=>5,:p=>1 } def self.make_change(value) homecoming {} if value == 0 coinstar.each |k,v| wallet = hash.new if value >= v wallet.merge(k=>value / v) value = value - (v * (value % v)) end end wallet end end #test run coins.make_change(26) coins.make_change(91) coins.make_change(1) #=>returns # {:p=>1, :q=>1} # {:p=>1, :q=>1, :h=>1} # {:p=>1, :q=>1, :h=>1}

any ideas on how persist hash without collecting info previous test?

to work, need prepare 3 problems.

first, ymonad notes, move wallet = hash.new before each loop.

second, alter merge merge!.

third, alter value = value - (v * (value % v)) value = value % v.

the first alter needed move wallet scope of method def self.make_change rather scope of each loop.

the sec alter needed want persist info through iterations of each loop (so half dollars, quarters, dimes, nickels, , pennies added).

the 3rd alter needed create sure value equals number of coins remaining (e.g, value 91, v 50, 91 % 50 = 41 91 - (50 * (91 % 50)) = 91 - (50 * 41) = (91 - 2050) = -1959).

ruby hash persistent persist

regex - simple htaccess RewriteRule is not working -



regex - simple htaccess RewriteRule is not working -

hello have urls in format : http://domain.com/index.php?action=page&name=privacy utilize domain.com/page/privacy instead of http://domain.com/index.php?action=page&name=privacy using htaccess. ideas please

rewriterule \/index\.php\/(.*)$ /action/$1

you need rule in root .htaccess:

rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]+)/([^/]+)/?$ index.php?action=$1&name=$2 [l,qsa]

regex apache .htaccess mod-rewrite redirect

Django template does not change when `TEMPLATE_DIRS` is modified -



Django template does not change when `TEMPLATE_DIRS` is modified -

i next tutorial in offical documentation https://docs.djangoproject.com/en/1.7/intro/tutorial02/

i in section of customizing templates, running problems changing content of templates

this in settings.py

template_dirs = [os.path.join(base_dir, 'templates')] print template_dirs

here tree structure

└── mysite ├── manage.py ├── mysite ├── polls └── templates └── admin └── base_site.html

i double check path using print, should correct

['/users/mysite/templates']

and edit base_site.html to

{% block title %}{{ title }} | {{ site_title|default:_('poll admin') }}{% endblock %}

however seems cannot see changes when rerun

python manage.py runserver

the other questions seems have path problem, think path correct,

http://stackoverflow.com/questions/4921080/how-do-i-change-templates-on-django-admin-pages

django django-templates

c# - Background task memory usage WP8.1 -



c# - Background task memory usage WP8.1 -

according of link microsoft increases memory limit apps in windows phone 8.1 in 2gb device available background task 40mb memory. when trigger background task breakpoints in first string in run method see in windows phone developer powerfulness tools (8.1) task private bytes 30.73mb working set 31.27mb. memorymanager show me 35 mb in run method.

is mean can utilize 40-30=10mb needs in background task? is possible alter 30mb (switch off requirements in manifest)? how work 512mb devices available 16mb memory background task?

p.s. after reset of phone , reinstall application see 2 mb @ same string...

c# windows-phone-8.1 memory-limit background-task

android - get checkbox checked on first click -



android - get checkbox checked on first click -

i creating checkboxes dynamically. want check 1 checkbox @ time.i have achieved using setchecked(false) method.its working fine,the problem when unchecked first checkbox , click on sec 1 getting checked @ sec time.i want checked @ first time.

code have used-

cb.setoncheckedchangelistener(new compoundbutton.oncheckedchangelistener() { @override public void oncheckedchanged(compoundbutton buttonview,boolean ischecked) { log.e("ischecked",""+ischecked); if(ischecked==true) { count++; senddata(j); if(count>1) { //cb[i].setchecked(false); buttonview.setchecked(false); count=0; } } };

@neha seek this...

@override public void oncheckedchanged(compoundbutton buttonview, boolean ischecked) { if(ischecked) { if(count==0) { count++; toast.maketext(mainactivity.this, "count="+count, 0).show(); return; } buttonview.setchecked(false); } else { count--; toast.maketext(mainactivity.this, "count="+count, 0).show(); return; } }

android checkbox

c++ - Calling custom deleter class member function for shared pointer -



c++ - Calling custom deleter class member function for shared pointer -

i happened stumble upon post on stack overflow: make shared_ptr not utilize delete

and have related question c++ standard library book nicolai m. josuttis. below next piece of code book:

#include <string> #include <fstream> // ofstream #include <memory> // shared_ptr #include <cstdio> // remove() class filedeleter { private: std::string filename; public: filedeleter (const std::string& fn) : filename(fn) { } void operator () (std::ofstream* fp) { delete fp; // close file std::remove(filename.c_str()); // delete file } }; int main() { // create , open temporary file: std::shared_ptr<std::ofstream> fp(new std::ofstream("tmpfile.txt"), filedeleter("tmpfile.txt")); //... }

i understand signature of deleter function should of next :

void deleter(t* p)

so in above example, how deleter function (specified filedeleter("tmpfile.txt")) looks constructor phone call class rather function above format? how deleter function invoked on destruction of shared pointer here?

filedeleter("tmpfile.txt") creates deleter object pass shared pointer.

the shared pointer's implementation stores re-create somewhere variable, managed object, along lines of

std::ofstream * object; filedeleter deleter;

the shared pointer's destructor invoke as

deleter(object);

which phone call deleter's overloaded operator(), deleting object , removing file.

c++

javascript - Backbone to use Underscore templates with helpers -



javascript - Backbone to use Underscore templates with helpers -

i want utilize helper functions underscore templates , backbone. i'm doing way:

view:

var view = backbone.view.extend({ // ... template: gettpl('#b_ezlo', 1), // ... render: function(){ this.$el.html( this.template(this.model.tojson()) ); } });

template getter: here homecoming template, along helper functions. problem when prepare cannot homecoming helper functions, because require homecoming other variables template, , causes undefined getdisabledstate:

function gettpl(tpl, options) { if (!tpl) return; if (!options) options = null; var prepare = false; if (options == 1) { // called on view initialization // template: gettpl('#b_ezlo', 1), options = {}; prepare = true; } var viewhelpers = {} if (tpl == "#b_view") { console.log("prepare", prepare); viewhelpers.getdisabledstate = function() { if (typeof options.disabled != "undefined") { homecoming options.disabled; } else { homecoming ''; } } } _.extend(options, viewhelpers); if (prepare) { homecoming _.template($(tpl).html()); } else { homecoming _.template($(tpl).html())(options); } }

and part of template (jade) want utilize helper:

.icon-block(data-disabled!="<% if (typeof getdisabledstate != 'undefined') {getdisabledstate()} %>")

what dislike here if (typeof getdisabledstate != 'undefined') part, not nice have in template.

so if there other way prepare templates helper functions?

thanks evgeniy's comment, marionettejs way - defining helpers in view.

http://marionettejs.com/docs/marionette.view.html#viewtemplatehelpers

javascript templates backbone.js underscore.js

windows - substitution of ConfigurationManager -



windows - substitution of ConfigurationManager -

i'm working on windows phone 7 project, want read appsettings config file such app.config using configurationmanager class, seems not implemented in windows phone 7 sdk, have no thought how resolve issue, knows this?

i'm using vs 2010 os windows 7

thanks

i 1 time implemented simple config class, read configuration xml file added project. take @ https://github.com/igorkulman/kulman.wp7/blob/master/kulman.wp7/config/appconfig.cs.

this requires having app.config in project , calling appconfig.parseandloadappconfig() in app.xaml.cs constructor.

windows windows-phone-7 windows-phone-8

java.lang.classcastexception java.lang.string cannot be cast to java.lang.integer in Criteria Spring MVC + Hibernate + JQGrid + MySQL application -



java.lang.classcastexception java.lang.string cannot be cast to java.lang.integer in Criteria Spring MVC + Hibernate + JQGrid + MySQL application -

i developing spring mvc + hibernate + jqgrid + mysql application. filter records, using criteria , passing json filter string generate restrictions. in mysql table, field brcode integer , other fields of type string.

i getting "java.lang.classcastexception java.lang.string cannot cast java.lang.integer" error in line cr.list.size().

please help me resolve error without hampering generic nature of functions, since of conditions can applied of fields. have attached error log below:

org.apache.catalina.core.standardwrappervalve.invoke servlet.service() servlet [dispatcher] in context path [/nioerpj] threw exception [request processing failed; nested exception java.lang.classcastexception: java.lang.string cannot cast java.lang.integer] root cause java.lang.classcastexception: java.lang.string cannot cast java.lang.integer @ org.hibernate.type.descriptor.java.integertypedescriptor.unwrap(integertypedescriptor.java:36) @ org.hibernate.type.descriptor.sql.integertypedescriptor$1.dobind(integertypedescriptor.java:64) @ org.hibernate.type.descriptor.sql.basicbinder.bind(basicbinder.java:90) @ org.hibernate.type.abstractstandardbasictype.nullsafeset(abstractstandardbasictype.java:286) @ org.hibernate.type.abstractstandardbasictype.nullsafeset(abstractstandardbasictype.java:281) @ org.hibernate.loader.loader.bindpositionalparameters(loader.java:1994) @ org.hibernate.loader.loader.bindparametervalues(loader.java:1965) @ org.hibernate.loader.loader.preparequerystatement(loader.java:1900) @ org.hibernate.loader.loader.executequerystatement(loader.java:1861) @ org.hibernate.loader.loader.executequerystatement(loader.java:1838) @ org.hibernate.loader.loader.doquery(loader.java:909) @ org.hibernate.loader.loader.doqueryandinitializenonlazycollections(loader.java:354) @ org.hibernate.loader.loader.dolist(loader.java:2553) @ org.hibernate.loader.loader.dolist(loader.java:2539) @ org.hibernate.loader.loader.listignorequerycache(loader.java:2369) @ org.hibernate.loader.loader.list(loader.java:2364) @ org.hibernate.loader.criteria.criterialoader.list(criterialoader.java:126) @ org.hibernate.internal.sessionimpl.list(sessionimpl.java:1682) @ org.hibernate.internal.criteriaimpl.list(criteriaimpl.java:380) @ com.nej.branchmst.dao.branchmstdaoimpl.searchbranchmsts(branchmstdaoimpl.java:103) @ com.nej.branchmst.service.branchmstserviceimpl.searchbranchmsts(branchmstserviceimpl.java:61) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:483) @ org.springframework.aop.support.aoputils.invokejoinpointusingreflection(aoputils.java:317) @ org.springframework.aop.framework.reflectivemethodinvocation.invokejoinpoint(reflectivemethodinvocation.java:190) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:157) @ org.springframework.transaction.interceptor.transactioninterceptor$1.proceedwithinvocation(transactioninterceptor.java:98) @ org.springframework.transaction.interceptor.transactionaspectsupport.invokewithintransaction(transactionaspectsupport.java:262) @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:95) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:207) @ com.sun.proxy.$proxy83.searchbranchmsts(unknown source) @ com.nej.controller.branchmstcontroller.getfilteredrecords(branchmstcontroller.java:95) @ com.nej.controller.branchmstcontroller.getall(branchmstcontroller.java:60) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:483) @ org.springframework.web.method.support.invocablehandlermethod.invoke(invocablehandlermethod.java:215) @ org.springframework.web.method.support.invocablehandlermethod.invokeforrequest(invocablehandlermethod.java:132) @ org.springframework.web.servlet.mvc.method.annotation.servletinvocablehandlermethod.invokeandhandle(servletinvocablehandlermethod.java:104) @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.invokehandlemethod(requestmappinghandleradapter.java:749) @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.handleinternal(requestmappinghandleradapter.java:689) @ org.springframework.web.servlet.mvc.method.abstracthandlermethodadapter.handle(abstracthandlermethodadapter.java:83) @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:938) @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:870) @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:961) @ org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:852) @ javax.servlet.http.httpservlet.service(httpservlet.java:618) @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:837) @ javax.servlet.http.httpservlet.service(httpservlet.java:725) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:301) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:239) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:330) @ org.springframework.security.web.access.intercept.filtersecurityinterceptor.invoke(filtersecurityinterceptor.java:118) @ org.springframework.security.web.access.intercept.filtersecurityinterceptor.dofilter(filtersecurityinterceptor.java:84) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.access.exceptiontranslationfilter.dofilter(exceptiontranslationfilter.java:113) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.session.sessionmanagementfilter.dofilter(sessionmanagementfilter.java:103) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.authentication.anonymousauthenticationfilter.dofilter(anonymousauthenticationfilter.java:113) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.servletapi.securitycontextholderawarerequestfilter.dofilter(securitycontextholderawarerequestfilter.java:154) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.savedrequest.requestcacheawarefilter.dofilter(requestcacheawarefilter.java:45) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.authentication.abstractauthenticationprocessingfilter.dofilter(abstractauthenticationprocessingfilter.java:199) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.authentication.logout.logoutfilter.dofilter(logoutfilter.java:110) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.header.headerwriterfilter.dofilterinternal(headerwriterfilter.java:57) @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:108) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.context.securitycontextpersistencefilter.dofilter(securitycontextpersistencefilter.java:87) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.context.request.async.webasyncmanagerintegrationfilter.dofilterinternal(webasyncmanagerintegrationfilter.java:50) @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:108) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.filterchainproxy.dofilterinternal(filterchainproxy.java:192) @ org.springframework.security.web.filterchainproxy.dofilter(filterchainproxy.java:160) @ org.springframework.web.filter.delegatingfilterproxy.invokedelegate(delegatingfilterproxy.java:344) @ org.springframework.web.filter.delegatingfilterproxy.dofilter(delegatingfilterproxy.java:261) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:239) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:219) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:106) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:503) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:136) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:78) @ org.apache.catalina.valves.abstractaccesslogvalve.invoke(abstractaccesslogvalve.java:610) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:88) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:526) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1033) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:652) @ org.apache.coyote.http11.http11aprprotocol$http11connectionhandler.process(http11aprprotocol.java:277) @ org.apache.tomcat.util.net.aprendpoint$socketprocessor.dorun(aprendpoint.java:2451) @ org.apache.tomcat.util.net.aprendpoint$socketprocessor.run(aprendpoint.java:2440) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617) @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61) @ java.lang.thread.run(thread.java:745) 08-oct-2014 21:22:21.420 severe [http-apr-8080-exec-14] org.apache.catalina.core.standardwrappervalve.invoke servlet.service() servlet [dispatcher] in context path [/nioerpj] threw exception [request processing failed; nested exception java.lang.classcastexception: java.lang.string cannot cast java.lang.integer] root cause java.lang.classcastexception: java.lang.string cannot cast java.lang.integer @ org.hibernate.type.descriptor.java.integertypedescriptor.unwrap(integertypedescriptor.java:36) @ org.hibernate.type.descriptor.sql.integertypedescriptor$1.dobind(integertypedescriptor.java:64) @ org.hibernate.type.descriptor.sql.basicbinder.bind(basicbinder.java:90) @ org.hibernate.type.abstractstandardbasictype.nullsafeset(abstractstandardbasictype.java:286) @ org.hibernate.type.abstractstandardbasictype.nullsafeset(abstractstandardbasictype.java:281) @ org.hibernate.loader.loader.bindpositionalparameters(loader.java:1994) @ org.hibernate.loader.loader.bindparametervalues(loader.java:1965) @ org.hibernate.loader.loader.preparequerystatement(loader.java:1900) @ org.hibernate.loader.loader.executequerystatement(loader.java:1861) @ org.hibernate.loader.loader.executequerystatement(loader.java:1838) @ org.hibernate.loader.loader.doquery(loader.java:909) @ org.hibernate.loader.loader.doqueryandinitializenonlazycollections(loader.java:354) @ org.hibernate.loader.loader.dolist(loader.java:2553) @ org.hibernate.loader.loader.dolist(loader.java:2539) @ org.hibernate.loader.loader.listignorequerycache(loader.java:2369) @ org.hibernate.loader.loader.list(loader.java:2364) @ org.hibernate.loader.criteria.criterialoader.list(criterialoader.java:126) @ org.hibernate.internal.sessionimpl.list(sessionimpl.java:1682) @ org.hibernate.internal.criteriaimpl.list(criteriaimpl.java:380) @ com.nej.branchmst.dao.branchmstdaoimpl.searchbranchmsts(branchmstdaoimpl.java:103) @ com.nej.branchmst.service.branchmstserviceimpl.searchbranchmsts(branchmstserviceimpl.java:61) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:483) @ org.springframework.aop.support.aoputils.invokejoinpointusingreflection(aoputils.java:317) @ org.springframework.aop.framework.reflectivemethodinvocation.invokejoinpoint(reflectivemethodinvocation.java:190) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:157) @ org.springframework.transaction.interceptor.transactioninterceptor$1.proceedwithinvocation(transactioninterceptor.java:98) @ org.springframework.transaction.interceptor.transactionaspectsupport.invokewithintransaction(transactionaspectsupport.java:262) @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:95) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:207) @ com.sun.proxy.$proxy83.searchbranchmsts(unknown source) @ com.nej.controller.branchmstcontroller.getfilteredrecords(branchmstcontroller.java:95) @ com.nej.controller.branchmstcontroller.getall(branchmstcontroller.java:60) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:483) @ org.springframework.web.method.support.invocablehandlermethod.invoke(invocablehandlermethod.java:215) @ org.springframework.web.method.support.invocablehandlermethod.invokeforrequest(invocablehandlermethod.java:132) @ org.springframework.web.servlet.mvc.method.annotation.servletinvocablehandlermethod.invokeandhandle(servletinvocablehandlermethod.java:104) @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.invokehandlemethod(requestmappinghandleradapter.java:749) @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.handleinternal(requestmappinghandleradapter.java:689) @ org.springframework.web.servlet.mvc.method.abstracthandlermethodadapter.handle(abstracthandlermethodadapter.java:83) @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:938) @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:870) @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:961) @ org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:852) @ javax.servlet.http.httpservlet.service(httpservlet.java:618) @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:837) @ javax.servlet.http.httpservlet.service(httpservlet.java:725) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:301) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:239) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:330) @ org.springframework.security.web.access.intercept.filtersecurityinterceptor.invoke(filtersecurityinterceptor.java:118) @ org.springframework.security.web.access.intercept.filtersecurityinterceptor.dofilter(filtersecurityinterceptor.java:84) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.access.exceptiontranslationfilter.dofilter(exceptiontranslationfilter.java:113) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.session.sessionmanagementfilter.dofilter(sessionmanagementfilter.java:103) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.authentication.anonymousauthenticationfilter.dofilter(anonymousauthenticationfilter.java:113) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.servletapi.securitycontextholderawarerequestfilter.dofilter(securitycontextholderawarerequestfilter.java:154) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.savedrequest.requestcacheawarefilter.dofilter(requestcacheawarefilter.java:45) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.authentication.abstractauthenticationprocessingfilter.dofilter(abstractauthenticationprocessingfilter.java:199) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.authentication.logout.logoutfilter.dofilter(logoutfilter.java:110) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.header.headerwriterfilter.dofilterinternal(headerwriterfilter.java:57) @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:108) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.context.securitycontextpersistencefilter.dofilter(securitycontextpersistencefilter.java:87) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.context.request.async.webasyncmanagerintegrationfilter.dofilterinternal(webasyncmanagerintegrationfilter.java:50) @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:108) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.filterchainproxy.dofilterinternal(filterchainproxy.java:192) @ org.springframework.security.web.filterchainproxy.dofilter(filterchainproxy.java:160) @ org.springframework.web.filter.delegatingfilterproxy.invokedelegate(delegatingfilterproxy.java:344) @ org.springframework.web.filter.delegatingfilterproxy.dofilter(delegatingfilterproxy.java:261) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:239) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:219) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:106) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:503) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:136) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:78) @ org.apache.catalina.valves.abstractaccesslogvalve.invoke(abstractaccesslogvalve.java:610) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:88) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:526) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1033) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:652) @ org.apache.coyote.http11.http11aprprotocol$http11connectionhandler.process(http11aprprotocol.java:277) @ org.apache.tomcat.util.net.aprendpoint$socketprocessor.dorun(aprendpoint.java:2451) @ org.apache.tomcat.util.net.aprendpoint$socketprocessor.run(aprendpoint.java:2440) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617) @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61) @ java.lang.thread.run(thread.java:745)

the relevant portion of branchmstdaoimpl.java file below:

@override public list<branchmst> searchbranchmsts(string filters, int pagesize, int page, string sidx, string sord) { list<branchmst> ls = null; criteria cr = getcurrentsession().createcriteria(branchmst.class); jqgridfilter jqgridfilter = jqgridobjectmapper.map(filters); (jqgridfilter.rule rule: jqgridfilter.getrules()) { cr.add(getrestriction(rule.getfield(), rule.getop(), (string) rule.getdata())); } noofrecords = cr.list().size(); cr.setfirstresult((page - 1) * pagesize); cr.setmaxresults(pagesize); ls = cr.list(); homecoming ls; } public simpleexpression getrestriction(string field, string op, string data){ if(op.equals("cn")){ homecoming restrictions.like(field, data, matchmode.anywhere); }else if(op.equals("eq")){ homecoming restrictions.eq(field, data); }else if(op.equals("ne")){ homecoming restrictions.ne(field, data); }else if(op.equals("lt")){ homecoming restrictions.lt(field, data); }else if(op.equals("le")){ homecoming restrictions.le(field, data); }else if(op.equals("gt")){ homecoming restrictions.gt(field, data); }else if(op.equals("ge")){ homecoming restrictions.ge(field, data); }else{ homecoming null; } }

i getting error on line "noofrecords = cr.list().size();" in function searchbranchmsts.

in string fields no error, error comes if seek filter using brcode field integer. pl. help, resolving error keeping generic nature of above function filter conditions can more 1 , may in order.

java mysql spring hibernate jqgrid