Friday, 15 June 2012

Azure Worker Role data volatility -



Azure Worker Role data volatility -

i create application holds big amount of volatile info in memory. little part of info needs persisted when host machine shuts down, or in case of maintenance. outages should rare, in memory info needs accessible of time, rare restrats of service bearable.

if have been developing server, create windowsservice, runs reliably while machine up, , persist fraction of info in onstop() method.

i'm thinking of moving whole thing cloud. question if worker role similiar windows service point of view? run of time rare outages, or recycled / restarted time time or when idle?

like windows service, worker role meant processing background tasks. 1 thing need maintain in mind worker role can go downwards time. may because of hardware failure or software updates. can't assume highly available. that's why windows azure recommends deploying multiple instances of application.

what have multiple instances of worker role running , of them sharing mutual cache set volatile data. take @ windows azure caching (http://msdn.microsoft.com/en-us/library/windowsazure/gg278356.aspx) either dedicate memory of vm (i.e. instance) caching purpose or have total vm dedicated caching. way you'll have volatile info somewhere outside of worker roles , making available instances.

azure

graphics - Absolute Aspect Ratios in Mathematica -



graphics - Absolute Aspect Ratios in Mathematica -

suppose plot[1000 x,{x,0,1}]. options utilize forcefulness resulting graphic image have 10,000 pixels in y-direction , 10 pixels in x-direction, i.e., want x , y axes scaled identically (in pixels).

well, illustration of 1000x, it's bit hard see because slope vertical. let's utilize gentler slope ease of display---perhaps slope of 10. then, do:

plot[10 x, {x, 0, 10}, aspectratio -> automatic]

graphics options aspect-ratio

ruby on rails - User model: username format method -



ruby on rails - User model: username format method -

ok, in user model have created get_username in effort format username.

the thought able use

theuser.get_username

and correctly format username based on user level (admin). test created this:

def get_username fname = '<span style="color:red">john</span>' fname end

however, displayed value literally code showing..

how able plug username in display correctly

you can utilize html_safe.

def get_username fname = '<span style="color:red">john</span>' fname.html_safe end

to user_name use:

def get_username fname = "<span style='color:red'>#{user_name}</span>" fname.html_safe end

note bad code, not abusing seperation of responsibilty of mvc may introduce security vulernabilities.

code should in view or helper.

ruby-on-rails ruby format username

Python MySQLdb not inserting data -



Python MySQLdb not inserting data -

ubuntu version: 12.10 mysql server version: 5.5.29-0 python version: 2.7

i trying utilize mysqldb insert info localhost mysql server. don't errors when run script info isn't come in table. view tables phpmyadmin.

i tried going basics , next tutorial same result. weird thing can create , delete tables not come in data.

the code tutorial reports 4 rows inserted. preventing info beingness entered table when script reports fine??

cursor = conn.cursor () cursor.execute ("drop table if exists animal") cursor.execute (""" create table animal ( name char(40), category char(40) ) """) cursor.execute (""" insert animal (name, category) values ('snake', 'reptile'), ('frog', 'amphibian'), ('tuna', 'fish'), ('racoon', 'mammal') """) print "%d rows inserted" % cursor.rowcount

add :

conn.commit()

after bottom of script.

on side note, have @ next : http://mysql-python.sourceforge.net/mysqldb.html

python-2.7 mysql-python ubuntu-12.10

c++ - Tesseract setVariable whitelist for another language -



c++ - Tesseract setVariable whitelist for another language -

tesseract setvariable whitelist works ok english language language illustration utilize recognize digits , letters image (excluding special characters &*^%! etc)

myocr->setvariable("tessedit_char_whitelist", "0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");

but can't same thing russian language

myocr->setvariable("tessedit_char_whitelist", "0123456789абвгдежзийклмнопрстуфхцчшщъыьэюяАБВГДЕЖЗИЙКЛМОПРСТУФХЦЧШЩЭЮЯ");

is there different principle? because don't work. instead of determined characters recieve digits in output, tesseract ignores russian letters set whitelist. blacklist didn't work too. there way rid it? thanks.

so reply utilize symbols unicode codes in whitelist, don't know how exactly

c++ ocr tesseract

ios - How to use terminal for working with xCode Command Line Tools? -



ios - How to use terminal for working with xCode Command Line Tools? -

context: have installed command line tools separately conventional method of "xcode->preferences->downloads->components->command line tools->install" didn't work me.

purpose: need implement internationalization/localization on application , want utilize genstrings creating localizable.strings files.

problem: when seek utilize terminal , type command like

$ find . -name *.m | xargs genstrings -o en.lproj

i get:

couldn't connect output directory en.lproj

how should specify path directory? also, might need specify path *.m files well.

note: suggested read genstrings manual not sure how work particular xcode project while using terminal.

two things need taken care of:

1) after entering terminal, first go folder in targeted .m files present. use:

cd "path"

2) while using genstrings code, specify finish path of output directory. e.g.:

genstrings -o /users/kushalashok/desktop/projectnname/en.lproj *.m

after running code, new file named "localizable.strings" created in specified output folder.

ios xcode localization terminal genstrings

WMIC error: desciption = exception occured when searching for hotfix -



WMIC error: desciption = exception occured when searching for hotfix -

i have wmic command want run query list of machines , homecoming csv file if hotfix installed. in case hotfix id 2617858. starts process , comes after 20 seconds: error: desciption = exception occured . works when there few machines in file need run against 40 computers.

any suggestions ? thanks

code:

wmic /failfast:on /node:@"c:\users\username\desktop\servers.txt" qfe | find "2617858" > \\computername\c$\users\username\desktop\hotfix.csv

for it's worth, might easier inquire wmic filter rather piping wmic through find. this:

wmic /node:@"c:\users\username\desktop\servers.txt" qfe hotfixid="kb983590" csname /format:list >>hotfix.txt

or if problem wmic can't handle many servers in servers.txt, seek looping through list batch for loop.

@echo off setlocal /f "usebackq delims=" %%i in ("c:\users\username\desktop\servers.txt") ( set /p "=checking %%i... " wmic /node:%%i qfe hotfixid="kb983590" csname /format:list >>hotfix.txt 2>>failures.txt echo done. ) echo unable query next computers: type failures.txt

as alternative, can perform same action using powershell.

powershell -command "$pcs = get-content c:\users\username\desktop\servers.txt; foreach ($pc in $pcs) { get-wmiobject -computername $pc win32_quickfixengineering | where-object {$_.hotfixid -eq 'kb980232'} | select-object csname }" >>hotfix.txt

... although if wmi unresponsive on server wmic, won't have much improve luck using powershell.

wmic

sql - updating a table upon two conditions from the same table -



sql - updating a table upon two conditions from the same table -

i have table columns book, startyear, endyear , author.

i need update startyear , endyear columns simultaneously depending on next conditions,

startyear = endyear startyear=0 , endyear != 0 endyear = startyear endyear =0 , startyear != 0

it possible

update table set startyear = endyear startyear=0 , endyear<>0; update table set endyear = startyear endyear =0 , startyear<>0;

how can write these 2 queries in single query?

update table set startyear = case when startyear = 0 , endyear<>0 endyear else startyear end, endyear = case when endyear = 0 , startyear <> 0 startyear else endyear end startyear = 0 or endyear = 0;

sql oracle

java - How do you log out all logged in users in spring-security? -



java - How do you log out all logged in users in spring-security? -

i want able log out logged in users programmatically. how forcefulness logout users on event?

first define httpsessioneventpublisher in web.xml

<listener> <listener-class>org.springframework.security.web.session.httpsessioneventpublisher</listener-class> </listener>

then define <session-management> in spring security.xml file.

now, utilize sessionregistry in controller method invalidate sessions. below code retrieves active sessions.

list<sessioninformation> activesessions = new arraylist<sessioninformation>(); (object principal : sessionregistry.getallprincipals()) { (sessioninformation session : sessionregistry.getallsessions(principal, false)) { activesessions.add(session); } }

on each active session, can phone call expirenow() method expire or invalidate them.

java spring authentication spring-security logout

gem - Getting remove_entry_secure error while using ruby application -



gem - Getting remove_entry_secure error while using ruby application -

i trying split pdf files images using docsplit. appears have issues ruby installation. maintain getting next error every time:

/usr/lib/ruby/1.8/fileutils.rb:694:in `remove_entry_secure': parent directory world writable

here total command line output:

$ docsplit images pdf-test.pdf /usr/lib/ruby/1.8/fileutils.rb:694:in `remove_entry_secure': parent directory world writable, fileutils#remove_entry_secure not work; abort: "/tmp/d20130207-6739-1f9i6b" (parent directory mode 42777) (argumenterror) /var/lib/gems/1.8/gems/docsplit-0.6.4/lib/docsplit/image_extractor.rb:51:in `convert' /var/lib/gems/1.8/gems/docsplit-0.6.4/lib/docsplit/image_extractor.rb:19:in `extract' /var/lib/gems/1.8/gems/docsplit-0.6.4/lib/docsplit/image_extractor.rb:19:in `each' /var/lib/gems/1.8/gems/docsplit-0.6.4/lib/docsplit/image_extractor.rb:19:in `extract' /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `each_with_index' /var/lib/gems/1.8/gems/docsplit-0.6.4/lib/docsplit/image_extractor.rb:18:in `each' /var/lib/gems/1.8/gems/docsplit-0.6.4/lib/docsplit/image_extractor.rb:18:in `each_with_index' /var/lib/gems/1.8/gems/docsplit-0.6.4/lib/docsplit/image_extractor.rb:18:in `extract' /var/lib/gems/1.8/gems/docsplit-0.6.4/lib/docsplit/image_extractor.rb:16:in `each' /var/lib/gems/1.8/gems/docsplit-0.6.4/lib/docsplit/image_extractor.rb:16:in `extract' /var/lib/gems/1.8/gems/docsplit-0.6.4/lib/docsplit.rb:63:in `extract_images' /var/lib/gems/1.8/gems/docsplit-0.6.4/bin/../lib/docsplit/command_line.rb:44:in `run' /var/lib/gems/1.8/gems/docsplit-0.6.4/bin/../lib/docsplit/command_line.rb:37:in `initialize' /var/lib/gems/1.8/gems/docsplit-0.6.4/bin/docsplit:5:in `new' /var/lib/gems/1.8/gems/docsplit-0.6.4/bin/docsplit:5 /usr/bin/docsplit:19:in `load' /usr/bin/docsplit:19

any ideas on how prepare this?

it turns out there problem /tmp folder permissions. next fixed problem:

steps followed are:

user@host-$: chmod 777 -r /tmp user@host-$: chmod o+t -r /tmp user@host-$: ls -l tmp drwxrwxrwt 2 user grouping 4096 2009-11-21 17:01 tmp

ruby gem ubuntu-10.04 docsplit

Mark tests explicit in SpecFlow -



Mark tests explicit in SpecFlow -

is there way mark specflow test "explicit" attribute? aware test can marked "ignore" attribute via utilize of special tag @ignore.

maybe.

if @ generated xxx.feature.cs, see defined

public partial class xxx{...

so can add together file project xxx.partial.cs contains other part of partial definition.

and that's end of know, might able do.

in theory utilize partial class definition , modify it, create abstract. add together derived class override test in question, have new can't utilize virtual in xxx, , add together [explicit] there.

i have no thought if work. have sorts of issues abstract not taking, or test attributes disappearing on derived class, etc. maybe might going.

p.s. i'm not sure near practice. :-)

specflow

jquery - Add class to element -



jquery - Add class to element -

like this, have 2 tabs, when click on 1 it's active, logic. im trying create difference between active , inactive tab, not .css property, wanna' add together specific class clicked tab, this:

$(".tab1").addclass('active');

but, no good. have in mind i'm using external css file.

<div id="menuitem" class="tab1"></div> <div id="menuitem" class="tab2"></div> .active { width: 170px; height: 70px; float: right; background-color: red; } #menuitem { width: 170px; height: 70px; float: right; background-color: white; }

first of don't utilize same id on different elements, id's must unique , seek this:

jquery:

$('.menuitem').click(function() { $('.menuitem').removeclass('active'); //removes active class menu items $(this).addclass('active'); //adds active class clicked 1 });

html:

<div id="tab1" class="menuitem"></div> <div id="tab2" class="menuitem"></div>

css: don't need define same properties active class, define difference:

.active { background-color: red; } .menuitem { width: 170px; height: 70px; float: right; background-color: white; }

jquery class add

string - Crystal Reports: Formula unable to make 0.00 value appear blank -



string - Crystal Reports: Formula unable to make 0.00 value appear blank -

i have summarized our inventory usage per financial year quarter. null values appear 0.00, want create them blank. formula have worked out far this:

if isnull({usage.curfy_q1}) , isnull({usage.curfy_q2}) , isnull({usage.curfy_q3}) , isnull({usage.curfy_q4}) "" else "q1: " & cstr({usage.curfy_q1}) & chr(13) & chr(10) & "q2: " & cstr({usage.curfy_q2}) & chr(13) & chr(10) & "q3: " & cstr({usage.curfy_q3}) & chr(13) & chr(10) & "q4: " & cstr({usage.curfy_q4})

the formula creates result:

q1: 5.00 q2: 2.00 q3: 0.00 q4: 0.00

i prefer:

q1: 5 q2: 2 q3: q4:

i think totext(q1,0) may involved... :)

local stringvar q1; local stringvar q2; local stringvar q3; local stringvar q4; if isnull({usage.curfy_q1}) q1:="" else q1:=totext({usage.curfy_q1},0); if isnull({usage.curfy_q2}) q2:="" else q2:=totext({usage.curfy_q2},0); if isnull({usage.curfy_q3}) q3:="" else q3:=totext({usage.curfy_q3},0); if isnull({usage.curfy_q4}) q4:="" else q4:=totext({usage.curfy_q4},0); if (q1="" , q2="" , q3="" , q4="") "" else "q1: " & q1 & chr(10) & "q2: " & q2 & chr(10) & "q3: " & q3 & chr(10) & "q4: " & q4

string crystal-reports formula inventory-management

javascript - dynamic show/hide of div elements using id -



javascript - dynamic show/hide of div elements using id -

$(document).ready(function() { $("input[name$='type']").click(function() { var value = $(this).val(); if(value == 'variant-3'){ $('[id*=variant]').show(); } else{ $('[id*=variant]').hide(); $('.'+ value ).show(); } }).click(); });

http://jsfiddle.net/sushanth009/h6q38/1/

uses class show/hide div elements. how can same achieved using id instead of class? tried, end hiding or showing all.

this code http://jsfiddle.net/h6q38/8/

i think want :

<div id="variant-1">variant 1</div> <div id="variant-2">variant 2</div> <div id="variant-1.1">variant 1.1</div> <!-- don't reuse id! --> <div id="variant-2.1">variant 2.1</div> <!-- don't reuse id! --> $("input[name$='type']").click(function() { if (this.value=='variant-3'){ $('[id^=variant]').show(); } else{ $('[id^=variant]').hide(); $('[id^='+this.value+']').show(); } });

demonstration

javascript jquery html ajax

How can I get current localization of Linux through C? -



How can I get current localization of Linux through C? -

how can current localization (ru-ru, en-us, en-gb, e.t.c.) of linux through c?

thank you.

on posix-compliant system, setlocale(lc_ctype, null); homecoming name of locale selected category lc_ctype.

c linux locale

C++ pass array and its length into a function (using macro/inline function?) -



C++ pass array and its length into a function (using macro/inline function?) -

i have been writing c++ little while (java/c long while), wondering if there trick don't know can help me following.

vector<unsigned char> *fromarray(unsigned char data[], int length) { vector<unsigned char> *ret = new vector<unsigned char >(); while (length--) { ret->push_back(*data); } homecoming ret; }

and can utilize so:

unsigned char tmp[] = {0, 1, 2, 3, 4, 5}; vector<unsigned char> *a = fromarray(tmp, sizeof(tmp)); // utilize `a' here

i find pretty cumbersome - i'd write on 1 line

vector<unsigned char> *a = fromarray({0, 1, 2, 3, 4, 5}); // utilize `a' here

is such thing possible? don't have access c++11 unfortunately (looks initializer_list want).

edit

sorry had of fundamentals wrong in here. avoid extending std::vector. think question still valid, illustration bad one.

** potential workaround **

i could define bunch of overloaded functions take different numbers of arguments, eg

vector<unsigned char> *fromarray(unsigned char a) { vector<unsigned char> *ret = new vector<unsigned char >(); ret->push_back(a); homecoming ret; } vector<unsigned char> *fromarray(unsigned char a, unsigned char b) { vector<unsigned char> *ret = new vector<unsigned char >(); ret->push_back(a); ret->push_back(b); homecoming ret; }

but don't think bother...

you can utilize template deduce size of fixed size array:

template< class t, size_t n > auto_ptr<bytearray> foo( t (&data)[n] ) { homecoming auto_ptr<bytearray>(new bytearray(data, n)); }

then

unsigned char tmp[] = {0, 1, 2, 3, 4, 5}; auto_ptr<bytearray> = foo(tmp);

but bear in mind auto_ptr deprecated. prefer unique_ptr. also, note should not publicly inherit std::vector.

c++ arrays macros inline

XML character encoding issue with PHP -



XML character encoding issue with PHP -

i have code creating xml, problem encoding of words á, olá , ção. these characters dont appear correctly , when seek reading xml error displayed relating character.

$dom_doc = new domdocument("1.0", "utf-8"); $dom_doc->preservewhitespace = false; $dom_doc->formatoutput = true; $element = $dom->createelement("hotels"); while ($row = mysql_fetch_assoc($result)) { $contact = $dom_doc->createelement( "m" . $row['id'] ); $nome = $dom_doc->createelement("nome", $row['nome'] ); $data1 = $dom_doc->createelement("data1", $row['data'] ); $data2 = $dom_doc->createelement("data2", $row['data2'] ); $contact->appendchild($nome); $contact->appendchild($data1); $contact->appendchild($data2); $element->appendchild($contact); $dom_doc->appendchild($element);

what can alter prepare problem, using utf-8???

you using utf-8, 8-bit unicode encoding format. though supports 1,112,064 code points in unicode possible there issue here. seek utf-16 standard, idea. see below:

$dom_doc = new domdocument("1.0", "utf-16");

or

$dom_doc = new domdocument("1.0", "iso-10646");

php xml character-encoding

javascript - Cannot set innerHTML or $(this).val successfully in AJAX function -



javascript - Cannot set innerHTML or $(this).val successfully in AJAX function -

using ajax have retrieved json info but, during function, cannot display text in relevant div.

the code works right bottom, can see using console, if set placeholder text in div "place", placeholder text stays same right end of function.

$.each(data, function(i,item){ if(i===0){ var placehtml='<h2>'+item.name+'</h2>' + '<p>where can <br>' + 'a pint of <em>'+item.pint+'</em> only<br>' + '<span>£'+item.cost+'!</span></p>'; window.localstorage.setitem("placename", item.name); window.localstorage.setitem("placeloc1", item.location); window.localstorage.setitem("placeloc2", item.location2); window.localstorage.setitem("placeemail", item.email); window.localstorage.setitem("placenumber", item.number); console.log("data saved"); document.getelementbyid("place").innerhtml = placehtml; console.log("data placed:"); console.log(placehtml); $("#loadtext").fadeout(); $('#place').fadein(); homecoming false; } });

i have tried replacing document.getelementbyid("place").innerhtml = foo $("#place").val(foo) no luck.

the div has values id="place" , class="place".

document.getelementbyid("place").innerhtml = placehtml;

should be

document.getelementbyid("place").innerhtml = placehtml;

to jquery

$("#place").html(placehtml)

val set value of input field, alter inner html jquery want utilize html() function

javascript jquery html ajax

oracle - SSIS Data Flow Task doesn't load all rows from OLE DB -



oracle - SSIS Data Flow Task doesn't load all rows from OLE DB -

i'm trying load table sql server using microsoft ole db provider oracle table (using oracle provider ole db). bundle straight forwards ole db source (sql server) -> ole db destination (oracle).

i'm using sql server 2008 r2 , oracle 11g.

every time run package, different number of rows in destination table, , bids reports fewer rows read there in source table. number of rows returned different each time run it. no errors or kickouts, boxes source , destination remain yellowish after bids says "package completed successfully".

dumping source table flat file instead of oracle destination works fine, , rows expect. can utilize flat file pull info oracle destination table without problems well.

even though have work-around, want understand why happening, , can resolve problem without having utilize flat files.

edit: looks using flat file oracle doesn't bring on rows. first time luck?

edit/update: running bundle out of integration services (not bids) seems have eliminated problem (tested 3 times). still don't understand why happening though.

oracle ssis sql-server-2008-r2

cuda - constant memory -



cuda - constant memory -

i write code copying integer constant memory , utilize in global function,but doesn't work correctly.i mean no "cuprintf" in global function works , nil printed!

i think because of "if(*num == 5)",since remove it, "cuprintf" print want!

i seek "if(num == 5)" visual studio doesn't compile , shows error.

why "num" right in "cuprintf" not right in "if" statement?

how should utilize "num" in "if" statement?

#include "cuda_runtime.h" #include "device_launch_parameters.h" #include "stdio.h" #include "stdlib.h" #include "cuprintf.cu" __constant__ int* num; __global__ void kernel(){ cuprintf("\n num=%d\n",num); if(*num == 5) cuprintf("\n num equal 5"); else cuprintf("\n num not equal 5"); } void main(){ int x; printf("\n\nplease come in x:"); scanf("%d",&x); cudamemcpytosymbol( num, &x,sizeof(int)*1); cudaprintfinit(); kernel<<<1,1>>>(); cudaprintfdisplay(stdout, true); cudaprintfend(); int wait; scanf("%d",&wait); }

if change:

__constant__ int* num;

to

__constant__ int num;

and change:

cudamemcpytosymbol( num, &x,sizeof(int)*1);

to

cudamemcpytosymbol( &num, &x,sizeof(int)*1);

then

cuprintf("\n num=%d\n",num);

will show "num=0" input!

"num" should not pointer. changed code 1 below, works me (note requires sm 2.0 or newer printf):

#include "cuda_runtime.h" #include "device_launch_parameters.h" #include "stdio.h" #include "stdlib.h" __constant__ int num; __global__ void kernel() { printf("\n num=%d\n", num); if (num == 5) printf("\n num equal 5"); else printf("\n num not equal 5"); } int main() { cudaerror_t err; int x; printf("\n\nplease come in x:"); scanf("%d", &x); err = cudamemcpytosymbol(num, &x, sizeof(int) * 1); if (err != cudasuccess) { printf("error: %d\n", err); homecoming 1; } kernel<<<1, 1>>>(); err = cudadevicesynchronize(); if (err != cudasuccess) { printf("error: %d\n", err); homecoming 1; } homecoming 0; }

cuda

ruby on rails - Rails_admin do not show all included models -



ruby on rails - Rails_admin do not show all included models -

i have rails app models, frontend , administration rails_admin. have these rails_admin settings:

# config/initializers/rails_admin.rb railsadmin.config |config| ... config.included_models = %w[ user page event link slide main partner ] ... end

but it's not working, show events, links, pages. not know did mistake.

are using cancan rails admin? maybe haven't set ability model create them manageable.

or maybe haven't restarted server.

ruby-on-rails rails-admin

My Spring application does not open another page -



My Spring application does not open another page -

i have created spring application using netbeans, did not alter of configuration. in index.jsp have link page not sec page , shows "the requested resource () not available."

in server console shows next warning

"warning: no mapping found http request uri [/myapp/emp.htm] in dispatcherservlet name 'dispatcher'"

my emp.jsp file in jsp folder.

index.jsp

<%@page contenttype="text/html" pageencoding="utf-8"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>welcome spring web mvc project</title> </head> <body> <a href="emp.htm">emp</a> </body> </html>

dispatcher-servlet

<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <bean class="org.springframework.web.servlet.mvc.support.controllerclassnamehandlermapping"/> <!-- controllers utilize controllerclassnamehandlermapping above, index controller using parameterizableviewcontroller, must define explicit mapping it. --> <bean id="urlmapping" class="org.springframework.web.servlet.handler.simpleurlhandlermapping"> <property name="mappings"> <props> <prop key="index.htm">indexcontroller</prop> </props> </property> </bean> <bean id="viewresolver" class="org.springframework.web.servlet.view.internalresourceviewresolver" p:prefix="/web-inf/jsp/" p:suffix=".jsp" /> <!-- index controller. --> <bean name="indexcontroller" class="org.springframework.web.servlet.mvc.parameterizableviewcontroller" p:viewname="index" /> <bean name="/emp.htm" class="controller.employee"/> <<i changed "/myapp/emp.htm" not work </beans>

web.xml

<?xml version="1.0" encoding="utf-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <context-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/applicationcontext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>*.htm</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>redirect.jsp</welcome-file> </welcome-file-list> </web-app>

employee.java

/* * alter template, take tools | templates * , open template in editor. */ bundle controller; import org.springframework.web.servlet.mvc.controller; import org.springframework.web.servlet.modelandview; import javax.servlet.servletexception; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import org.apache.commons.logging.log; import org.apache.commons.logging.logfactory; import java.io.ioexception; public class employee implements controller { protected final log logger = logfactory.getlog(getclass()); @override public modelandview handlerequest(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { logger.info("returning hello view"); homecoming new modelandview("emp.jsp"); } }

change <a href> actual url this

<a href="<c:url value="/emp"/>" />

also create sure dispatcher servlet mapped in web.xml

<servlet> <servlet-name>dispatcherservlet</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcherservlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>

more spring mvc implementation can found here

spring spring-mvc

java - How to get rid of the "Class path contains multiple SLF4J bindings" warning? -



java - How to get rid of the "Class path contains multiple SLF4J bindings" warning? -

this more-or-less "common" question, however, haven't managed find reply yet. so, again, here warning:

slf4j: class path contains multiple slf4j bindings. slf4j: found binding in [jar:file:/home/eualin/.m2/repository/org/slf4j/slf4j-jcl/1.6.0/slf4j-jcl-1.6.0.jar!/org/slf4j/impl/staticloggerbinder.class] slf4j: found binding in [jar:file:/home/eualin/.m2/repository/org/slf4j/slf4j-log4j12/1.5.11/slf4j-log4j12-1.5.11.jar!/org/slf4j/impl/staticloggerbinder.class] slf4j: see http://www.slf4j.org/codes.html#multiple_bindings explanation.

and here 2 potential solutions problem [1][2].

assuming both work me, obviously, hacks, , not sure if should rely on of them @ all. recommend me? maintain in mind warning not appear when in terminal; when run application through intellijidea.

any suggestion highly appreciated.

slf4j expects 1 version of staticloggerbinder nowadays in application runtime. if there more one, slf4j cannot guarantee log messages routed appropriate logger.

the architecture of slf4j requires 1 library used route log messages (e.g. slf4j-<logging framework>.jar). when multiple classpath's in play via application servers, ide's, startup scripts, etc., slf4j libraries can included multiple times. may have hunt , peck find classpath's either beingness added or modified in intellijidea (such in configured java compilers or in startup configurations).

java warnings slf4j

perl - How to use regex in not ASCII strings? -



perl - How to use regex in not ASCII strings? -

i have code:

opendir(dir, "."); while (readdir dir) { print $1, "\n" if $_ =~ /(\w+)/i; }

it gets ascii strings of course. how can non ascii strings in output using regexp?

upd

for illustration if in "." directory there 2 files file , другойфайл. when run script file in output i'd file non english language name другойфайл

the next code seems work:

use warnings; utilize strict; utilize encode qw(decode); $dir = $argv[0] || '.'; opendir $dh, $dir or die "$0: $dir: $!\n"; while (readdir $dh) { $_ = decode 'utf-8', $_; print $1, "\n" if /(\w+)/; }

this assumes file scheme stores names in utf-8, of course.

output:

file другойфайл

regex perl unicode

operating system - Can we detect type of Mobile(android/symbian etc) through the imei number? -



operating system - Can we detect type of Mobile(android/symbian etc) through the imei number? -

we doing application need identify mobile type i.e android based or symbian etc through imei number of phone. possible! if please give guidance

look @ article:

http://en.wikipedia.org/wiki/international_mobile_station_equipment_identity

and type allocation code:

http://en.wikipedia.org/wiki/type_allocation_code

http://www.mulliner.org/tacdb/

so, believe it's possible (at to the lowest degree partially).

android operating-system symbian imei

Requesting root access for android app -



Requesting root access for android app -

i know there questions here, tried answers given without success.

there's simple checkboxpreference (titled "root"):

<checkboxpreference android:key="root" android:title="@string/root" android:summary="@string/root_summary" android:defaultvalue="false" />

now need set onpreferencechangelistener on , gain root access. if checkbox should checked, otherwise should not:

public class settings extends preferenceactivity implements onpreferencechangelistener { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); addpreferencesfromresource(r.xml.settings); findpreference("root").setonpreferencechangelistener(this); } @override public boolean onpreferencechange(preference preference, object newvalue) { string key = preference.getkey(); if ("root".equals(key) && !((checkboxpreference) preference).ischecked()) { seek { process p = runtime.getruntime().exec("su"); p.waitfor(); log.d("settings", integer.tostring(p.exitvalue())); if (p.exitvalue() == 255) { log.d("settings", "###no root###"); homecoming false; } } grab (exception e) { log.d("settings", "###no root###"); log.d("settings", e.getmessage()); homecoming false; } log.d("settings", "!!!root!!!"); } homecoming true; } }

superuser prompts correctly root access. denying returns true, exitvalue 1 (???) , allowing freezes whole app (i guess @ p.waitfor).

i'm running superuser 3.1.3 su binary 3.1.1 (newest versions).

taking logcat can see next message: activity pause timeout activityrecord{42c0ebb8 com.example/.gui.settings}

the command you're running su will, suspect, run shell superuser. you're waiting (indefinitely) shell finish.

you need specify su some-command-here-which-needs-to-run-as-root.

unfortunately, there no way accomplish superuser permissions java code within android project. root-ness applies commands spawned su itself.

android

ssl - Can't connect to JIRA Python through REST api https url -



ssl - Can't connect to JIRA Python through REST api https url -

i seek connect jira dev sandbox through https comes ssl23_get_server_hello:unknown protocol error

this error log/stack trace. seek both ports 8080 , 443 no joy.

>>> jira.client import jira >>> options = {'server':'localhost:8080'} >>> auth = ('username', 'password') >>> jira = jira(options, auth) traceback (most recent phone call last): file "<stdin>", line 1, in <module> file "/home/ve/lib/python2.6/site-packages/jira/client.py", line 88, in __init__ self._create_http_basic_session(*basic_auth) file "/home/ve/lib/python2.6/site-packages/jira/client.py", line 1369, in _create_http_basic_session r = self._session.post(url, data=json.dumps(payload)) file "/home/ve/lib/python2.6/site-packages/requests/sessions.py", line 284, in post homecoming self.request('post', url, data=data, **kwargs) file "/home/ve/lib/python2.6/site-packages/requests/sessions.py", line 241, in request r.send(prefetch=prefetch) file "/home/ve/lib/python2.6/site-packages/requests/models.py", line 638, in send raise sslerror(e) requests.exceptions.sslerror: [errno 1] _ssl.c:480: error:140770fc:ssl routines:ssl23_get_server_hello:unknown protocol >>> options = {'server':'localhost:443'} >>> auth = ('username', 'password') >>> jira = jira(options, auth) traceback (most recent phone call last): file "<stdin>", line 1, in <module> file "/home/ve/lib/python2.6/site-packages/jira/client.py", line 88, in __init__ self._create_http_basic_session(*basic_auth) file "/home/ve/lib/python2.6/site-packages/jira/client.py", line 1369, in _create_http_basic_session r = self._session.post(url, data=json.dumps(payload)) file "/home/ve/lib/python2.6/site-packages/requests/sessions.py", line 284, in post homecoming self.request('post', url, data=data, **kwargs) file "/home/ve/lib/python2.6/site-packages/requests/sessions.py", line 241, in request r.send(prefetch=prefetch) file "/home/ve/lib/python2.6/site-packages/requests/models.py", line 631, in send raise connectionerror(sockerr) requests.exceptions.connectionerror: [errno 110] connection timed out >>>

try this:

from jira.client import jira options = {'server':'localhost:8080'} jira = jira(options) jira = jira(basic_auth=('username', 'password'))

if doesn't help, chance have openssl conflicts?

when curl linked against openssl 0.9.8 , tries access server running openssl 1.0.0, ssl handshake fails with: curl: (35) error:14077458:ssl routines:ssl23_get_server_hello:reason(1112)

python ssl https connection jira

blackberry - Strange things happen when set margin to VerticalFieldManager -



blackberry - Strange things happen when set margin to VerticalFieldManager -

i'd generate verticalfieldmanager has none-zero margin, create verticalfieldmanager, , utilize vfm.setmargin(10, 10, 10, 10); after that, set fields(buttonfield, objectchoicefield) in it.

it seems simple, right? unusual thing happens. when focus lastly objectchoicefield , press space toggle selection of it, objectchoicefield disappeared.

how can be? here demo code, kindly find bug?

class="lang-java prettyprint-override">final class helloworldscreen extends mainscreen{ helloworldscreen() { // demo show unusual thing string [] arr = {"a","b"}; for(int = 0; < 10; i++){ verticalfieldmanager vfm = new verticalfieldmanager(); // field.use_all_width vfm.setmargin(10, 10, 10, 10); buttonfield btn = new buttonfield(string.valueof(i)); objectchoicefield ch = new objectchoicefield(string.valueof(i), arr); vfm.add(btn); vfm.add(ch); add(vfm); } } }

edit: screenshot of desired ui margins:

that strange.

for benefit of don't run code, what's happening when click on object selection fields, whole screen scrolling little bit vertically. after each vertical scroll, screen loses ability scroll way downwards bottom. after many such operations, much of lower part of screen no longer accessible.

i don't know why happening. (looks blackberry bug me)

what observed if take out phone call

class="lang-java prettyprint-override"> vfm.setmargin(10, 10, 10, 10);

the problem goes away.

may suggest workaround use

class="lang-java prettyprint-override"> vfm.setpadding(10, 10, 10, 10);

instead?

i know margin , padding not same thing. however, depending on total ui design (which cannot see), in case, setting 10 pixel padding may sufficient trying do.

update: based on screenshot of desired ui, able produce workaround. again, shouldn't much work, additional code worked me:

class="lang-java prettyprint-override">public class bugscreen extends mainscreen { private static final int bg_color = color.lightgray; private static final int fg_color = color.white; private static final int border_line_color = color.gray; private static final int pad = 10; public bugscreen() { super(mainscreen.vertical_scroll | mainscreen.vertical_scrollbar); getmainmanager().setbackground(backgroundfactory.createsolidbackground(bg_color)); // additional phone call ensures when scrolling bounces, area "behind" // normal visible area of bg_color setbackground(backgroundfactory.createsolidbackground(bg_color)); // found lean grayness padding on screen's left/right sides // note: seem drawing artifacts if seek utilize sides! getmainmanager().setpadding(0, pad, 0, pad); string [] arr = {"a","b"}; for(int = 0; < 10; i++){ verticalfieldmanager vfm = new verticalfieldmanager(field.use_all_width) { public int getpreferredwidth() { homecoming display.getwidth() - 2 * pad; } public void paint(graphics graphics) { int oldcolor = graphics.getcolor(); super.paint(graphics); graphics.setcolor(border_line_color); // draw (1-pixel wide) border size like. graphics.drawrect(0, 0, getpreferredwidth(), getheight()); graphics.setcolor(oldcolor); } }; vfm.setbackground(backgroundfactory.createsolidbackground(fg_color)); buttonfield btn = new buttonfield(string.valueof(i)); objectchoicefield ch = new objectchoicefield(string.valueof(i), arr); vfm.add(btn); vfm.add(ch); // add together separator field lean grayness margin between (vfm) fields add(new marginfield()); add(vfm); } // add together 1 lastly margin field @ bottom add(new marginfield()); } private class marginfield extends field { public marginfield() { super(field.use_all_width); } public int getpreferredheight() { homecoming pad; } protected void paint(graphics g) { int oldcolor = g.getcolor(); g.setcolor(bg_color); g.fillrect(0, 0, getwidth(), getpreferredheight()); g.setcolor(oldcolor); } protected void layout(int width, int height) { setextent(width, getpreferredheight()); } } }

blackberry

asp.net mvc - Razor Editor not working for some projects in solution -



asp.net mvc - Razor Editor not working for some projects in solution -

i creating cms using mvc 4 , razor syntax , have unusual problem. in main project working fine, have additional projects in solution (also mvc 4 projects) extensions main project (loaded @ runtime) have own views/layouts.

now in these additional projects razor editor eighter highlight should, underlining missing (like html helper) or not work @ all: or

does have thought why? files open razor editor via "open with..." shure razor editor used.

just add together dummy web.config file root of class library next contents in order fool visual studuio's intellisense in razor files (taken this blog post):

<?xml version="1.0"?> <configuration> <configsections> <sectiongroup name="system.web.webpages.razor" type="system.web.webpages.razor.configuration.razorwebsectiongroup, system.web.webpages.razor, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"> <section name="host" type="system.web.webpages.razor.configuration.hostsection, system.web.webpages.razor, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" requirepermission="false" /> <section name="pages" type="system.web.webpages.razor.configuration.razorpagessection, system.web.webpages.razor, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" requirepermission="false" /> </sectiongroup> </configsections> <system.web.webpages.razor> <host factorytype="system.web.mvc.mvcwebrazorhostfactory, system.web.mvc, version=3.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" /> <pages pagebasetype="system.web.mvc.webviewpage"> <namespaces> <add namespace="system.web.mvc" /> <add namespace="system.web.mvc.ajax" /> <add namespace="system.web.mvc.html" /> <add namespace="system.web.routing" /> </namespaces> </pages> </system.web.webpages.razor> <system.web> <compilation targetframework="4.0"> <assemblies> <add assembly="system.web.abstractions, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/> <add assembly="system.web.routing, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/> <add assembly="system.data.linq, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089"/> <add assembly="system.web.mvc, version=3.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" /> </assemblies> </compilation> </system.web> </configuration>

asp.net-mvc razor asp.net-mvc-4 visual-studio-2012

sitecore6 - sitecore: editframe -



sitecore6 - sitecore: editframe -

i need utilize editframe allow front end user modify checkbox fields

i create new edit frame button , set fields want front end user edit. illustration : core db -> /sitecore/content/applications/webedit/edit frame buttons/(edit button folder)/(field editor button). in fields edited front end user, have set headline.

in sublayout, have code

<sc:editframe id="editfield" runat="server" buttons="/sitecore/content/applications/webedit/edit frame buttons/editfields"> <div id="whatyoumissed"> <asp:listview id="listview1" runat="server"> <layouttemplate> <ul style="list-style-type: none;" > <asp:placeholder runat="server" id="itemplaceholder"></asp:placeholder> </ul> </layouttemplate> <itemtemplate> <li style="float: left;margin-left:20px;"> <sc:fieldrenderer id="fieldrenderer2" runat="server" fieldname="headline" item="<%# container.dataitem sitecore.data.items.item %>" /> <br /> <sc:fieldrenderer id="fr3" runat="server" fieldname="cb" item="<%# container.dataitem sitecore.data.items.item %>" /> </li> </itemtemplate> </asp:listview> </div> </sc:editframe>

code behind

string querypath = "/bla/bla/bla/bla/bla/bla/bla/bla/bla"; var item = sc.context.database.getitem(querypath); var children = item.children; listview1.datasource = children; listview1.databind();

when click on edit frame in page editor, prompted box not have field (headline) me modify it. suggestion?

answer: have google abit of sitecore edit frame datasource , end link http://blog.jan.hebnes.dk/2011/12/using-sitecore-editframe-with.html

instead of using code behind shown martijn bos, modify code prev following.

<asp:listview id="listview1" runat="server"> <layouttemplate> <ul style="list-style-type: none;" > <asp:placeholder runat="server" id="itemplaceholder"></asp:placeholder> </ul> </layouttemplate> <itemtemplate> <sc:editframe id="editfield" runat="server" buttons="/sitecore/content/applications/webedit/edit frame buttons/editfields" datasource="<%# ((sitecore.data.items.item)container.dataitem).paths.fullpath %>" > <li style="float: left;margin-left:20px;"> <sc:fieldrenderer id="fieldrenderer2" runat="server" fieldname="headline" item="<%# container.dataitem sitecore.data.items.item %>" /> <br /> <sc:fieldrenderer id="fr3" runat="server" fieldname="cb" item="<%# container.dataitem sitecore.data.items.item %>" /> </li> </sc:editframe> </itemtemplate> </asp:listview>

have tried setting datassource of editframe?

e.g. editfield.datasource = item.paths.fullpath;

sitecore sitecore6 page-editor

Python recursion -



Python recursion -

i have generate possible combinations of letters represents number sequence in telephone... example: if entry '423', output should be:

gad gae gaf gbd gbe gbf gcd gce gcf had hae haf hbd hbe hbf hcd hce hcf iad iae iaf ibd ibe ibf icd water ice icf

i must utilize recursion solve this... started using dictionary this:

dic = {'2' : 'abc', '3' : 'def', '4' : 'ghi', '5' : 'jkl', '6' : 'mno', '7' : 'pqrs', '8' : 'tuv', '9' : 'wxyz'}

but don't know how can utilize recursion here... help?

i thought start with:

def telephonesequence(str): in range (len(str)): homecoming dic[str[i]]

i think you're looking itertools.product:

>>> import itertools >>> list(itertools.product('ghi','abc','def')) [('g', 'a', 'd'), ('g', 'a', 'e'), ('g', 'a', 'f'), ('g', 'b', 'd'), ('g', 'b', 'e'), ('g', 'b', 'f'), ('g', 'c', 'd'), ('g', 'c', 'e'), ('g', 'c', 'f'), ('h', 'a', 'd'), ('h', 'a', 'e'), ('h', 'a', 'f'), ('h', 'b', 'd'), ('h', 'b', 'e'), ('h', 'b', 'f'), ('h', 'c', 'd'), ('h', 'c', 'e'), ('h', 'c', 'f'), ('i', 'a', 'd'), ('i', 'a', 'e'), ('i', 'a', 'f'), ('i', 'b', 'd'), ('i', 'b', 'e'), ('i', 'b', 'f'), ('i', 'c', 'd'), ('i', 'c', 'e'), ('i', 'c', 'f')]

this gives bunch of tuples, can ''.join them easily.

>>> list(''.join(p) p in itertools.product('ghi','abc','def')) ['gad', 'gae', 'gaf', 'gbd', 'gbe', 'gbf', 'gcd', 'gce', 'gcf', 'had', 'hae', 'haf', 'hbd', 'hbe', 'hbf', 'hcd', 'hce', 'hcf', 'iad', 'iae', 'iaf', 'ibd', 'ibe', 'ibf', 'icd', 'ice', 'icf']

of course, isn't recursive , won't help out if have other constraining forces (a professor perhaps?). leave reply demonstrate how powerful python standard library , show recursion isn't best tool sort of problem (at to the lowest degree not in python).

python recursion

c# - App-wide Observable Collection -



c# - App-wide Observable Collection -

if set observable collection within separate .cs (class) file , utilize in mainpage.xaml, how can create info stored within same observable collection accessible within different xaml page @ later time?

e.g.

myclass.cs: public observablecollection<string> oc = new observablecollection<string>(); mainpage.xaml.cs: // add together observable collection secondpage.xaml.cs: // access , utilize info stored in observablecollection

i think want this:

myclass.cs: public static observablecollection<string> oc = new observablecollection<string>(); mainpage.xaml.cs: // add together observable collection secondpage.xaml.cs: // access , utilize info stored in observablecollection

once oc static, can reference 1 time again , 1 time again class / page.

if want bind (since cannot bind fields or static properties in windows 8 apps) need have xaml page reference static property in simple property:

secondpage.xaml.cs: public static observablecollection<string> oc { { homecoming myclass.oc; } }

i hope makes sense!

c# .net xaml windows-8 microsoft-metro

windows - Identifying consistently physical usb slots where devices are plugged in -



windows - Identifying consistently physical usb slots where devices are plugged in -

i have applicattion in windows 7 uses 2 usb handsets plugged specific physical external usb slots in pc (eg: left side usb slot , right-side usb slot in tablet).

the application needs handle differently handsets, based on physical external usb slots plugged in. far have got find location info via setupdigetdeviceregistryproperty() parameter spdrp_location_information.

that gives me string "port_#0004_hub_#0006" can manually , inspection associate external physical usb slots given hardware system. isn't reliable , persistent, since varies many things windows version installed, variability between units of same model of pc, etc.

is there consistent procedure of identification : 1. stable across restarts of scheme 3. stable across installations of new devices, windows or drivers updates, or reinstallations of windows. 2. stable across plugging of additional usb hubs 4. stable across different units of same computer model

i have been warned knowledgeable guys unachievable, still hope improve luck!

many help.

windows usb device slots

c# - Subquery help in LINQ -



c# - Subquery help in LINQ -

hi can help me how write below query in linq i'm new linq

select * employee employeeid = 'e101' or empdept = (select dept departments deptid = 'd101')

thanks in advance

you can utilize grouping join

from e in employee bring together d in deparment.where(x => x.deptid == "d101") on e.empdept equals d.dept g e.employeeid == "e101" || g.any() select e;

that generates next sql

declare @p0 nvarchar(1000) = 'e101' declare @p1 nvarchar(1000) = 'd101' select * [employee] [t0] ([t0].[employeeid] = @p0) or (exists( select null [empty] [deparment] [t1] ([t0].[empdept] = [t1].[dept]) , ([t1].[deptid] = @p1) ))

c# sql linq subquery

c++ - This struct is defined, so why does the function think it isn't? -



c++ - This struct is defined, so why does the function think it isn't? -

new c++. making simple struct/array program. why can't pass array of structs intend here?

int numgrads(); int main() { struct pupil { int id; bool isgrad; }; const size_t size = 2; pupil s1, s2; pupil students[size] = { { 123, true }, { 124, false } }; numgrads(students, size); std::cin.get(); homecoming 0; } int numgrads(student stu[], size_t size){ }

i appreciate must passing either reference or value, certainly if i've defined in main(), shouldn't getting error parameter of numgrads?

student defined in main(). define outside of main it's in same scope numgrads:

struct pupil { int id; bool isgrad; }; int main() { ... }

c++ arrays parameters struct undefined

android - Play music over bluetooth network -



android - Play music over bluetooth network -

how can play music 1 phone in phone(asynchronous , not copying file) via bluetooth? eg. have file in phone. need play in paired device before transferring entire file phone.( may copying part of file , playing, , transfer next part of file while playing).

btw, can done in more 1 phone simultaneously?

android bluetooth share music

ASP.NET MVC Best Pratice for jQuery updates -



ASP.NET MVC Best Pratice for jQuery updates -

history

i created new asp.net mvc 4.0 project basic , didn't include jquery or other scripts intranet , net templates insert default. went add together scripts using nuget , installed latest version of jquery , related files installed mvc intranet , net templates.

when tried running application started receive errors. apparently there incompatibilities libraries/extensions written previous jquery 1.9. seemed after fixing issue i'd run another. gave , copied versions of js files have installed. resolved issues able utilize features such remote validation.

questions

since i'm new asp.mvc, i'd know best practice related jquery updates. assume need wait until libraries/extensions have caught up, need follow status of each library/extension determine when upgrade.

is improve wait , utilize versions installed mvc templates , not upgrade? , when next update mvc comes out, re-create libraries/extensions scripts folder updated templates use? i noticed mvc templates not install jquery nuget packages install files content , script folders. prevent developers upgrading , experiencing issues found using newer version of libraries/extensions? does microsoft time updates jquery.unobtrusive-ajax.js , related libraries updates asp.net mvc? if seem create sense hold off updating dependencies until asp.net mvc updated.

jquery deprecated .live() method in v1.9. can replaced .on(). broke jquery.unobtrusive-ajax.js. know experience when cursing update first pulled nuget.

there update jquery.validate out there, mentioned in this thread. have not validated yet, jquery 1.9.1 available well.

for questions...

i think practice maintain packages upto date, research deprecated functionality. using source save tools idea. revert breaking changes 1 or 2 mouse clicks.

even though there not \packages folder added virgin project (intra or internet). if open nuget bundle manager ui, updates still show up.

asp.net-mvc asp.net-mvc-4

jQuery UI Tabs: Disable "First Tab" -



jQuery UI Tabs: Disable "First Tab" -

i'm looking load jquery ui tabs widget without "first tab" beingness loaded default.

i tried following, first tab still beingness shown:

$('#tabs').tabs({ selected: -1 });

you can set collapsible alternative true , active alternative false:

$("#tabs").tabs({ collapsible: true, active: false });

jquery-ui tabs

xcode - FaceBook checkin in IOS 6 and IOS 5 -



xcode - FaceBook checkin in IOS 6 and IOS 5 -

i have predefined location of different stores.i want checkin these locations through ios app.how can it?

here code used ios 5

appdelegate *appdelegate = (appdelegate *)[[uiapplication sharedapplication] delegate]; sbjson *jsonwriter = [sbjson new]; nsmutabledictionary *coordinatesdictionary = [nsmutabledictionary dictionarywithobjectsandkeys: [nsstring stringwithformat: @"%f", latitude], @"latitude", [nsstring stringwithformat: @"%f", longitude], @"longitude", nil]; nsstring *coordinates = [jsonwriter stringwithobject:coordinatesdictionary]; nsmutabledictionary *params = [nsmutabledictionary dictionarywithobjectsandkeys: [[placesarray objectatindex:indexpath.row] objectforkey:@"id"], @"place", //the placeid coordinates, @"coordinates", // latitude , longitude in string format (json) @"testing check in", @"message", // status message nil]; // tags, @"tags", // user's friends beingness checked in [[appdelegate facebook] requestwithgraphpath:@"me/checkins" andparams:params andhttpmethod:@"post" anddelegate: self]; // deselect

ios xcode facebook ios5 ios6

javascript - is my anti xss function safe? -



javascript - is my anti xss function safe? -

i have javascript functions on website, don't know if safe utilize them.

here code :

// works php's $_get function get(name){ name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); regexs="[\\?&]"+name+"=([^&#]*)"; regex=new regexp(regexs); results=regex.exec(window.location.href); if(results==null) homecoming ''; homecoming results[1]; } // , here anti xss filter var param = unescape(decodeuri(get("q"))); param = param.replace(/<(.*?)>/gi, ""); someelement.innerhtml = param;

is possible bypass filters?

do not seek , find xsses on way application. programme may transform info internally in such way filter create circumventable.

instead, apply proper html encoding of info on way out of application. way avoid vulnerabilities.

javascript security filter xss

java - How do I add an instance of a class without the constructor's parameters? -



java - How do I add an instance of a class without the constructor's parameters? -

i'm trying create fantasy football game draft program. first step i'm having hard time reading info list properly. want scan data, line line. created loop sets each role name, goes on add together people have role until "-----" shows on line. role added list of roles. believe loop right that, however, not know how work person constructor correctly contains rank, name, , origin can't accomplish setdata method in person class. i'm still beginner @ programming, , want know if i'm missing something.

data file

leader

1 superman dc

2 captain america marvel

3 professor x marvel

4 shoveler mystery men

brawn

1 hulk marvel

2 wolverine marvel

3 thing marvel

4 beast marvel

5 thor marvel

6 mr. furious mystery men

7 mr. incredible pixar

...and on

main class import java.util.hashmap; import java.util.list; import java.util.scanner; import java.io.*; import java.util.arraylist; public class fantasyteamdraft { /** * joseph simmons * cps 181 * feb 6, 2013 */ public static void main(string[] args) throws ioexception{ scanner scan = new scanner (system.in); system.out.println("enter name , location of file wanted draft: "); file draftdata = new file (scan.next()); scanner scandata = new scanner(draftdata); list <role> listofroles = new arraylist <role> (); while (scandata.hasnext()) { string line = scandata.nextline(); if (!isinteger (line)) { role role = new role (); role.setrolename(line); string personline = scandata.nextline(); while (isinteger(personline)){ person person = new person(); person.setdata(personline); role.addperson(person); } listofroles.add(role); } } } public static boolean isinteger (string line) { seek { integer.parseint(line.split("\t") [0]); } grab (numberformatexception e) { homecoming false; } homecoming true; }

}

person class import java.util.scanner; public class person { private int rank; private string name; private string origin; public person () { } public person (int rank, string name, string origin) { this.rank = rank; this.name = name; this.origin = origin; } public void setdata (string line) { string [] array = line.split("\t"); this.rank = integer.parseint(array [0]); this.name = array [1]; this.origin = array [2]; }

}

role class import java.util.list; import java.util.scanner; public class role { private string rolename = ""; private list <person> listofpeople; public role (string rolename) { this.rolename = rolename; } public void setrolename (string line) { this.rolename = line; } public string getrolename() { homecoming rolename; } public void addperson (person person) { this.listofpeople.add(person); }

}

in code see

while (isinteger(personline)){ person person = new person(); person.setdata(personline); role.addperson(person); }

this infinite loop if isinteger(personline) evaluates true. perhaps should if instead of while, or need modify personline in each iteration.

java constructor instance-variables

oracle - Find out the history of SQL queries -



oracle - Find out the history of SQL queries -

any 1 have executed update sql query on server. this, many problems coming now. want list of update queries executed on lastly 2 months trace exact sql query beingness problem.

can please help me on this?

thanks!!

select v.sql_text, v.parsing_schema_name, v.first_load_time, v.disk_reads, v.rows_processed, v.elapsed_time, v.service v$sql v to_date(v.first_load_time,'yyyy-mm-dd hh24:mi:ss')>add_months(trunc(sysdate,'mm'),-2)

where clause optional. can sort results according first_load_time , find records 2 months ago.

oracle sql-update database-administration

linux - Change UNIX password with JAVA -



linux - Change UNIX password with JAVA -

sorry if english language bad. wanna inquire executing "passwd" command java (i utilize netbeans ide & jsch library)

this code

string username = txtusername.gettext(); string password = txtpassword.gettext(); string ip = txtip.gettext(); int port = 22; session session = null; session session2=null; channelexec channel = null; channel channel2 = null; stringbuffer result = new stringbuffer(); seek { jsch shell = new jsch(); session = shell.getsession(username, ip, port); java.util.properties config = new java.util.properties(); config.put("stricthostkeychecking", "no"); session.setconfig(config); session.setpassword(password); session.connect(3000); channel = (channelexec) session.openchannel("exec"); ((channelexec)channel).setcommand("passwd"); channel.setinputstream(null); channel.setoutputstream(null); ((channelexec)channel).seterrstream(system.err); inputstream in=channel.getinputstream(); outputstream out=channel.getoutputstream(); printstream char_to_send_to_channel = new printstream(out,true); bufferedreader out_from_channel=new bufferedreader(new inputstreamreader(in)); char_to_send_to_channel.println(); string line; channel.connect(); joptionpane.showmessagedialog(null,"channel opened!" +"\n"); // process p = runtime.getruntime().exec("passwd"); byte[] tmp=new byte[1024]; while(true){ while(in.available()>0){ int i=in.read(tmp, 0, 1024); if(i<0) { break; } } } } grab (ioexception ex) { logger.getlogger(connect.class.getname()).log(level.severe, null, ex); } catch(jschexception | headlessexception e){ joptionpane.showmessagedialog(null, e); } }

the problem is, output like

(current) unix password:

and if type / input current unix password,nothing happened. want alter ubuntu server business relationship password, installed on vmware. , run programme on original os. simply, want output interactive (input , output output linux command 'passwd')

whats wrong code? :( need suggestions

passwd default read straight pty instead of stdin. need pass --stdin alternative passwd.

for more information, see answers question: using passwd command within shell script.

java linux command jsch passwd

Is there a way to ignore default values during serialization with ServiceStack json? -



Is there a way to ignore default values during serialization with ServiceStack json? -

i using entity framework orm. has complextypeattribute (which used annotate poco's). properties complex types, instantiated (using default constructor), regardless of value; , consequence, serialized servicestack jsonserializer (along properties).

json.net has enum called defaultvaluehandling, can used in these situations.

does servicestack have similar?

for example:

class person { string name { get; set; } address address { get; set; } } [complextype] class address { string street { get; set; } int number { get; set; } int postalcode { get; set; } }

when serialize person doesn't have address this:

"{ name: jim, address : { number: 0, postalcode: 0 } }"

in json.net if set defaultvaluehandling ignore, get

"{ name: jim }"

yes, here different ways can ignore properties servicestack's json , text serializers.

the serializers support multiple hooks customize serialization , deserialization.

the jsconfig class shows customizations possible.

json servicestack

javascript - Appending options to a select -



javascript - Appending options to a select -

this related adding options select using jquery/javascript has different focus

my problem not able append option-elements select in ie8. when changing engine ie7 in ie's developer-tools work.

it works in ff , chrome.

var valt = "some text"; var charstoignore = 2; var o = new option(valt.slice(charstoignore), valt); $(o).html(valt.slice(charstoignore)); $('#availablepages').append(o);

another method tried:

$('<option/>', {value: valt, text: valt}).appendto("#availablepages");

availablepages id of select. select not contain elements when page received client. doctype <!doctype html>.

i tried remove other scripts , css site create sure no side-effects apply.

edit:\ downvoting! it's not fault if provided solutions not work in ie8-versions. since question what work in ie8-versions? is, point of view, understandable not take answers not work me. can see in adding options select using jquery/javascript not 1 whom other replies here not work. using up-/down-vote functionalities channel own mood no wiki/qa-behaviour.

this should trick you:

$('#availablepages').append(new option(valt.slice(charstoignore), valt));

(tested , working in ie8)

javascript jquery html internet-explorer-8

Perl class variables -



Perl class variables -

i cannot seem create variable global class , usable in subroutines of class.

i see examples on apparently work, cannot work.

code:

my $test = new player(8470598); bundle player; utilize strict; utilize warnings; utilize const::fast; $player::url = 'asdfasdasurl'; $test3 = '33333333'; our $test4 = '44444444444'; const $player::test0 => 'asdfasdas000'; const $test1 => 'asdfasdas111'; const our $test2 => 'asdfasdas222'; sub new{ print $player::url; print $player::test0; print $test1; print $test2; print $test3; print $test4; return(bless({}, shift)); }

output:

use of uninitialized value $player::url in print @ d:\text\programming\hockey\test.pl line 19. utilize of uninitialized value $player::test0 in print @ d:\text\programming\hockey\test.pl line 20. utilize of uninitialized value $test1 in print @ d:\text\programming\hockey\test.pl line 21. utilize of uninitialized value $player::test2 in print @ d:\text\programming\hockey\test.pl line 22. utilize of uninitialized value $test3 in print @ d:\text\programming\hockey\test.pl line 23. utilize of uninitialized value $player::test4 in print @ d:\text\programming\hockey\test.pl line 24.

what going on here?

while entire code compiled before executed, executable parts happen in order. in particular, new() phone call happens before of assignments or const calls in bundle player.

moving player code player.pm file , invoking use player; cause compiled , executed before new , work expect.

perl

c - makefile error: make: *** No rule to make target `omp.h' ; with OpenMP -



c - makefile error: make: *** No rule to make target `omp.h' ; with OpenMP -

all, compiling c programme openmp. it's first time utilize makefile. when excuting "make", gcc reports error make: * no rule create target omp.h', needed bysmooth.o'. stop. omp.h in /usr/lib/gcc/i686-linux-gnu/4.6/include/omp.h , wondering how prepare it. help me? give thanks you.

cc=gcc cflags = -fopenmp all: smooth smooth: smooth.o ompsooth.o $(cc) $(cflags) -o smooth smooth.o ompsmooth.o ompsmooth.o: ompsmooth.c assert.h stdio.h stdlib.h omp.h ompsmooth.h gcc $(cflags) ompsmooth.c smooth.o: smooth.c ompsmooth.h omp.h stdio.h stdlib.h string.h sys/types.h sys/stat.h fcntl.h gcc $(cflags) smooth.c clean: rm *.o rm smooth

unless you're expecting standard header files change, simplest solution remove them prerequisite list(s).

if don't want above, you'll either need specify finish path omp.h, or utilize vpath mechanism.

c gcc makefile openmp

Java getDesktop().open works in Windows but, doesn't work in Mac -



Java getDesktop().open works in Windows but, doesn't work in Mac -

i using windows programming , open file using code below, worked fine.

file file2 = new file(folderchooser + file.separator + "targetapp" + file.separator + name + file.separator + "index.html"); desktop.getdesktop().open(file2);

now i'm using macbook programing , code doesn't work anymore, , i'm getting next exception:

java.awt.headlessexception @ java.awt.desktop.getdesktop(desktop.java:142) @ br.com.facilit.target.app.desktop.view.mainviewcontroller.btnabriroffline(mainviewcontroller.java:709) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:601) @ javafx.fxml.fxmlloader$controllermethodeventhandler.handle(fxmlloader.java:1435) @ com.sun.javafx.event.compositeeventhandler.dispatchbubblingevent(compositeeventhandler.java:69) @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(eventhandlermanager.java:217) @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(eventhandlermanager.java:170) @ com.sun.javafx.event.compositeeventdispatcher.dispatchbubblingevent(compositeeventdispatcher.java:38) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:37) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:92) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:35) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:92) @ com.sun.javafx.event.eventutil.fireeventimpl(eventutil.java:53) @ com.sun.javafx.event.eventutil.fireevent(eventutil.java:28) @ javafx.event.event.fireevent(event.java:171) @ javafx.scene.node.fireevent(node.java:6863) @ javafx.scene.control.button.fire(button.java:179) @ com.sun.javafx.scene.control.behavior.buttonbehavior.mousereleased(buttonbehavior.java:193) @ com.sun.javafx.scene.control.skin.skinbase$4.handle(skinbase.java:336) @ com.sun.javafx.scene.control.skin.skinbase$4.handle(skinbase.java:329) @ com.sun.javafx.event.compositeeventhandler.dispatchbubblingevent(compositeeventhandler.java:64) @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(eventhandlermanager.java:217) @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(eventhandlermanager.java:170) @ com.sun.javafx.event.compositeeventdispatcher.dispatchbubblingevent(compositeeventdispatcher.java:38) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:37) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:92) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:35) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:92) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:35) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:92) @ com.sun.javafx.event.eventutil.fireeventimpl(eventutil.java:53) @ com.sun.javafx.event.eventutil.fireevent(eventutil.java:33) @ javafx.event.event.fireevent(event.java:171) @ javafx.scene.scene$mousehandler.process(scene.java:3324) @ javafx.scene.scene$mousehandler.process(scene.java:3164) @ javafx.scene.scene$mousehandler.access$1900(scene.java:3119) @ javafx.scene.scene.impl_processmouseevent(scene.java:1559) @ javafx.scene.scene$scenepeerlistener.mouseevent(scene.java:2261) @ com.sun.javafx.tk.quantum.glassvieweventhandler.handlemouseevent(glassvieweventhandler.java:228) @ com.sun.glass.ui.view.handlemouseevent(view.java:528) @ com.sun.glass.ui.view.notifymouse(view.java:922)

how can open html file in browser using mac??

java

latitude longitude - How to store the LatLng variable in Android in an SQL Lite Database for use later? -



latitude longitude - How to store the LatLng variable in Android in an SQL Lite Database for use later? -

i trying store marker info in sql lite database on android device, converting latlng variable string , saving way.

latlng latlng coords = latlng.tostring();

the problem is, , have tried many things, converting string latlng variable can used again. looking latlng variable see 2 doubles separated comma, thinking splitting string , converting doubles passing latlng don't know how in android.

any ideas on how this?

i solved doing this:

latlng latlng; double l1=latlng.latitude; double l2=latlng.longitude; string coordl1 = l1.tostring(); string coordl2 = l2.tostring(); l1 = double.parsedouble(coordl1); l2 = double.parsedouble(coordl2); googlemap.addmarker(new markeroptions() .position(new latlng(l1, l2)) .title(title) .snippet(info));

so latlng variable 2 doubles, strings,back doubles , passed newmarker position , works!

:)

android latitude-longitude

c++ - Default Argument in Virtual Function -



c++ - Default Argument in Virtual Function -

this question has reply here:

virtual function default arguments behaviour 6 answers

please help me find reasons behind it:

#include <iostream> using std::cout; class { public: virtual void fun(int = 5) { cout<<a; } }; class b::public { public: void fun(int = 10) { cout<<"inside a::b::fun().\n"; cout<<"\n"<<a; } }; int _tmain(int argc, _tchar* argv[]) { *obj = new b(); obj->fun(); reutrn 0; }

althought calling b::fun(), still printing 5, why , how work.?

a *obj = new b(); obj->fun();

in code, fun() invoked polymorphically - caller uses (only) knowledge of a::fun(), phone call dispatched pointer redirects implementation b::fun(). function argument - a / 5 - provided caller before redirected phone call though (way before - during compilation) - a's default seen, not b's.

if want seem expect, might find works have a::fun(int = -1) or other sentinel value, implementations of fun checking sentinel value replacing 5 or 10 desired. way, implementation-specific values incorporated during call, not before.

c++ virtual-functions default-arguments

c++ - What is the efficient way to split a vector -



c++ - What is the efficient way to split a vector -

is there other constant time way split vector other using following.

std::vector<int> v_splitvector(start , end);

this take complexity of o(n). in case o(end - start). there constant time operation this.

or using wrong container task?..

the deed of "splitting" container, container vectors, elements sits on contiguous memory, require re-create / move of needs go on other side.

container list, have elements each on own memory block can rearranged (see std::list::splice)

but having elements in non contiguous memory may result in lower memory access performance due more frequent cache missing.

in other words, complexity of algorithm may not factor influencing performance: infrequent linear re-create may damage less frequent linear walk on dispersed elements.

the trade-off depends on how hardware manage caches , how std implementation using takes care of (and how compiler can optimize)

c++ vector

php - Using masonry plugin with infinite scroll, callback function? -



php - Using masonry plugin with infinite scroll, callback function? -

im working on tumblr site uses infinite scroll along masonry.

the scroll plugin called externally 3rd party, , trigger masonry plugin on page load...

$(window).load(function(){ $('.autopagerize_page_element').masonry(); });

the problem when scroll pulls in more info masonry no longer works, has had problem before?

php javascript jquery html css

events - JQuery Click inside other click -



events - JQuery Click inside other click -

all need click event start simple modal , click button in modal, sec click (triggered first click) not working. :(

jquery(function ($) { // load dialog on click $('#basic-modal .basic').click(function (e) { $('#basic-modal-content').modal(); $("#botaoteste").click(); homecoming false; }); });

you separete on function , phone call need, sample:

jquery(function ($) { // create function function clickeventtest(e) { // code } // set function on click of 'botaoteste' element $("#botaoteste").click(clickeventtest); // load dialog on click $('#basic-modal .basic').click(function (e) { $('#basic-modal-content').modal(); // phone call function clickeventtest(e); homecoming false; }); });

jquery events click

datagridview - Update and refresh datagrid view -



datagridview - Update and refresh datagrid view -

i have info entry form datagridview, utilize local database.sdf file. when search particular name of person, click edit button new update form displayed. info succesfully passed update form

requirement: succesfully update info of person update form , info refreshed , shown in datagridview when nail update button , update form closes

error: first tried sqlcedataadapter adap.fill(databasedataset, "mainform"); //rest of code shown down// when click update button updates info creates entire re-create of whole info nowadays in datagridview. tried sqlcedataadapter adap.update(databasedataset, "mainform"); , code updates info succesfully , not create copies datagridview not refresh, info shown when close , open application again

code tried: in form 1:

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; using system.data.sqlclient; using system.data.sqlserverce; namespace hdr2 { public partial class frmupdate : form { public string name, age, gender, family_member, family_member_name, shnong, dong, grand, amount, phone_number, date_registered, date_recieved, status; private form1 f1; public frmupdate(form1 f2) { initializecomponent(); f1 = f2; } public void passdgvvaluetoform2() { nametxtupdate.text = name; agetxtupdate.text = age; gendertxtupdate.text = gender; familymembertxtupdate.text = family_member; familymembernametxtupdate.text = family_member_name; shnongtxtupdate.text = shnong; dongtxtupdate.text = dong; grandtxtupdate.text = grand; amounttxtupdate.text = amount; phonenumbertxtupdate.text = phone_number; dateregisteredupdate.text = date_registered; daterecievedupdate.text = date_recieved; statuscbupdate.text = status; } private void frmupdate_load(object sender, eventargs e) { } private void update() { sqlceconnection con = new sqlceconnection("data source=database.sdf"); con.open(); using (sqlcecommand cmd = new sqlcecommand("update mainform set name=@name, age=@age, gender=@gender, family_member=@family_member, family_member_name=@family_member_name, shnong=@shnong, dong=@dong, grand=@grand, amount=@amount, phone_number=@phone_number, date_registered=@date_registered, date_recieved=@date_recieved, status=@status name=@name", con)) { cmd.parameters.addwithvalue("@name", nametxtupdate.text); cmd.parameters.addwithvalue("@age", agetxtupdate.text); cmd.parameters.addwithvalue("@gender", gendertxtupdate.text); cmd.parameters.addwithvalue("@family_member", familymembertxtupdate.text); cmd.parameters.addwithvalue("@family_member_name", familymembernametxtupdate.text); cmd.parameters.addwithvalue("@shnong", shnongtxtupdate.text); cmd.parameters.addwithvalue("@dong", dongtxtupdate.text); cmd.parameters.addwithvalue("@grand", grandtxtupdate.text); cmd.parameters.addwithvalue("@amount", amounttxtupdate.text); cmd.parameters.addwithvalue("@phone_number", phonenumbertxtupdate.text); cmd.parameters.addwithvalue("@date_registered", dateregisteredupdate.text); cmd.parameters.addwithvalue("@date_recieved", daterecievedupdate.text); cmd.parameters.addwithvalue("@status", statuscbupdate.text); cmd.executenonquery(); con.close(); } con.close(); } private void frmupdate_formclosed(object sender, formclosedeventargs e) { f1.loademployee(); } private void btnupdate_click_1(object sender, eventargs e) { update(); f1.loademployee(); this.close(); } } }

and in form 2 //frmupdate:

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; using system.data.sqlclient; using system.data.sqlserverce; namespace hdr2 { public partial class frmupdate : form { public string name, age, gender, family_member, family_member_name, shnong, dong, grand, amount, phone_number, date_registered, date_recieved, status; private form1 f1; public frmupdate(form1 f2) { initializecomponent(); f1 = f2; } public void passdgvvaluetoform2() { nametxtupdate.text = name; agetxtupdate.text = age; gendertxtupdate.text = gender; familymembertxtupdate.text = family_member; familymembernametxtupdate.text = family_member_name; shnongtxtupdate.text = shnong; dongtxtupdate.text = dong; grandtxtupdate.text = grand; amounttxtupdate.text = amount; phonenumbertxtupdate.text = phone_number; dateregisteredupdate.text = date_registered; daterecievedupdate.text = date_recieved; statuscbupdate.text = status; } private void frmupdate_load(object sender, eventargs e) { } private void update() { sqlceconnection con = new sqlceconnection("data source=database.sdf"); con.open(); using (sqlcecommand cmd = new sqlcecommand("update mainform set name=@name, age=@age, gender=@gender, family_member=@family_member, family_member_name=@family_member_name, shnong=@shnong, dong=@dong, grand=@grand, amount=@amount, phone_number=@phone_number, date_registered=@date_registered, date_recieved=@date_recieved, status=@status name=@name", con)) { cmd.parameters.addwithvalue("@name", nametxtupdate.text); cmd.parameters.addwithvalue("@age", agetxtupdate.text); cmd.parameters.addwithvalue("@gender", gendertxtupdate.text); cmd.parameters.addwithvalue("@family_member", familymembertxtupdate.text); cmd.parameters.addwithvalue("@family_member_name", familymembernametxtupdate.text); cmd.parameters.addwithvalue("@shnong", shnongtxtupdate.text); cmd.parameters.addwithvalue("@dong", dongtxtupdate.text); cmd.parameters.addwithvalue("@grand", grandtxtupdate.text); cmd.parameters.addwithvalue("@amount", amounttxtupdate.text); cmd.parameters.addwithvalue("@phone_number", phonenumbertxtupdate.text); cmd.parameters.addwithvalue("@date_registered", dateregisteredupdate.text); cmd.parameters.addwithvalue("@date_recieved", daterecievedupdate.text); cmd.parameters.addwithvalue("@status", statuscbupdate.text); cmd.executenonquery(); con.close(); } con.close(); } private void frmupdate_formclosed(object sender, formclosedeventargs e) { f1.loademployee(); } private void btnupdate_click_1(object sender, eventargs e) { update(); f1.loademployee(); this.close(); } } }

// note tried adap.fill not work.

datagridview

java - Need advice on collision-handling -



java - Need advice on collision-handling -

i'm making 2d game, nil fancy, objects (called entities on) should collide eachother , terrain. now, detecting collision not problem, problem when entities collide terrain.

i have simple .png, upon loading game go through pixels of image , add together black ones list, these pixels collidable.

collision-code entity-class:

int ceiling = integer.max_value; int floor = 0; int rightpoint = 0; int leftpoint = integer.max_value; for(point p : main.terrain.points) if(gethyporect().contains(p)) { if(p.x > rightpoint && right) rightpoint = p.x; if(p.x < leftpoint && left) leftpoint = p.x; if(p.y < ceiling && up) ceiling = p.y; if(p.y > floor && down) floor = p.y; } if(rightpoint != 0) xcoord = rightpoint - sprite.getimage().getwidth(); else if(right) xcoord+=speed; if(leftpoint != integer.max_value) xcoord = leftpoint; else if(left) xcoord-=speed; if(ceiling != integer.max_value) ycoord = ceiling; else if(up) ycoord-=speed; if(floor != 0) ycoord = floor - sprite.getimage().getheight(); else if(down) ycoord+=speed;

in for-loop go through points (black pixels) in terrain, check if entity's collisionbox contains them (speed added in method, or rather "hypothetically" added, that's why has weird name). now, if x-value of point greater "rightpoint", , if entity walking right, it's overwritten. same happens leftpoint ("leftest" point), ceiling , floor. check if of these points have been changed, if have means collided terrain bounce them back. example, entity walking right , collided terrain, rightpoint have been written "rightest" point collided set coordinate entity right beside point collided with.

if 1 go @ 1 direction @ time, work perfectly, "weird" things happen when take multiple inputs account.

example: entity walks, flat floor, towards ledge on right, when entity halfway on ledge, wants go down, both right , downwards pressed, code check inputs, set entity wants , bounce if nail terrain, see press right , bounce entity end of ledge.

this own thought of how terraincollision work, couldn't find online except how check if collision took place, nil covers this. thought create solution work, or pointer how terraincollision should done?

your bouncing thought maybe problematic. seek instead ignore moves collide terrain: if player moves downwards , right, first check if downwards collide, if yes, ignore movement, , check right, if right possible right movement, else block, too.

java 2d user-input collision terrain

html - Inset box shadow behind h2's background image/color, need it above -



html - Inset box shadow behind h2's background image/color, need it above -

as title suggests i'm having issue inset box shadow going underneath h2 elements background, need above element.

http://jsfiddle.net/9qyt4/

i've set background image allow easy editing of colors depending on pages of site visited, help on how create shadow appear above h2 appreciated, thanks!

also, possible png gradient well? improve solution i'm trying shadow on right (but it's showing on top , bottom well)

sass

#region-postscript-second { width:300px; background:#fff; margin: 20px; box-shadow: inset -6px 0 10px rgba(0, 0, 0, 0.15); h2 { background: url('http://vt.lexcorp.ca/sites/all/themes/vermont/img/middle-heading-bg.png') center center no-repeat #8ccc1b; font-size:20px; text-transform:uppercase; font-weight:normal; color:#646567; text-align:center; }}

view html on jsfiddle, thanks!

i created pseudo after element contains shadow: http://jsfiddle.net/jpux3/

#region-postscript-second:after{ content: " "; display: block; position: absolute; right: 0; top: 0; height: 100%; width: 14px; box-shadow: inset -14px 0 8px -8px rgba(0, 0, 0, .25); }

and #region-postscript-second added:

position: relative;

here @ end 1 side box-shadows - http://css-tricks.com/snippets/css/css-box-shadow/

html css background css3

asp.net mvc 3 - Add New Post using ID = -1 in Entity Framework -



asp.net mvc 3 - Add New Post using ID = -1 in Entity Framework -

i have learning asp.net mvc 3 , entity framework video tutorials. have been searching propose of passing -1 id in new post object. insert new id database or else. using entity framework. , it's working , have run code , insert -1 id in database.

public post getpost(int? id) { homecoming id.hasvalue ? model.posts.where(x => x.id == id).first() : new post() { id = -1 }; }

asp.net-mvc-3 entity-framework

for loop - Running WHILE or CURSOR or both in SQL Server 2008 -



for loop - Running WHILE or CURSOR or both in SQL Server 2008 -

i trying run loop of sort in sql server 2008/tsql , unsure whether should while or cursor or both. end result trying loop through list of user logins, determine unique users, run loop determine how many visits took user on site 5 minutes , broken out channel.

table: loginhistory

userid channel datetime durationinseconds 1 website 1/1/2013 1:13pm 170 2 mobile 1/1/2013 2:10pm 60 3 website 1/1/2013 3:10pm 180 4 website 1/1/2013 3:20pm 280 5 website 1/1/2013 5:00pm 60 1 website 1/1/2013 5:05pm 500 3 website 1/1/2013 5:45pm 120 1 mobile 1/1/2013 6:00pm 30 2 mobile 1/1/2013 6:10pm 90 5 mobile 1/1/2013 7:30pm 400 3 website 1/1/2013 8:00pm 30 1 mobile 1/1/2013 9:30pm 200

sql fiddle schema

i can select unique users new table so:

select userid #users loginhistory grouping userid

now, functionality i'm trying develop loop on these unique userids, order logins datetime, count number of logins needed 300 seconds.

the result set hope this:

userid totallogins websitelogins mobilelogins loginsneededto5min 1 4 2 2 2 2 2 2 0 0 3 3 3 0 3 4 1 1 0 0 5 2 1 1 2

if performing in language, think this: (and apologies because not complete, think going)

for (i in #users): totallogins = count(*), websitelogins = count(*) channel = 'website', mobilelogins = count(*) channel = 'mobile', (i in loginhistory): if duration < 300: count(numlogins) + 1

** ok - i'm laughing @ myself way combined multiple different languages/syntaxes, how thinking solving **

thoughts on way accomplish this? preference utilize loop can go on write if/then logic code.

ok, 1 of times cursor outperform set based solution. sadly, i'm not cursors, can give set base of operations solution try:

;with cte ( select *, row_number() over(partition userid order [datetime]) rn userlogins ), cte2 ( select *, 1 recursionlevel cte rn = 1 union select b.userid, b.channel, b.[datetime], a.durationinseconds+b.durationinseconds, b.rn, recursionlevel+1 cte2 inner bring together cte b on a.userid = b.userid , a.rn = b.rn - 1 ) select a.userid, count(*) totallogins, sum(case when channel = 'website' 1 else 0 end) websitelogins, sum(case when channel = 'mobile' 1 else 0 end) mobilelogins, isnull(min(recursionlevel),0) loginsneedeto5min userlogins left bring together ( select userid, min(recursionlevel) recursionlevel cte2 durationinseconds > 300 grouping userid) b on a.userid = b.userid grouping a.userid

sql-server-2008 for-loop