Posts

Showing posts from February, 2015

Type Inference in Haskell v. Scala -

given following code: prelude> let f x = if (x) 55 else "foo" why compiler num [char] ? <interactive>:2:23: no instance (num [char]) arising literal `55' in expression: 55 in expression: if (x) 55 else "foo" in equation `f': f x = if (x) 55 else "foo" however, in scala, find least-upper bound of 55 , "foo" , any : scala> def f(x: boolean) = if (x) 55 else "foo" f: (x: boolean)any import scala.reflect.runtime.universe._ scala> lub( list[type]( typeof[int], typeof[string] ) ) res4: reflect.runtime.universe.type = what's key difference between haskell's , scala's type inference? you can add instance num [char] in haskell, if that's want: {-# language flexibleinstances #-} import data.function (on) import data.composition ((.:)) -- cabal install composition helper :: (integer -> integer -> integer) -> (string -> string -> string) helper o

ios - Set UIButton state to selected when creating custom UIButton class -

my uibutton has been created , has colors states want. however, when click it, not remain selected. all code reading addresses state of button in view controller after ib action. not yet understand touchesbegan method either. i have repeat 14 times , avoid setting each one.. edit: code: class appointmentdatepickerambutton: uibutton { required init(coder adecoder: nscoder) { super.init(coder: adecoder) self.settitlecolor(uicolor.graycolor(), forstate: uicontrolstate.normal) self.settitlecolor(uicolor.redcolor(), forstate: uicontrolstate.highlighted) self.settitlecolor(uicolor.bluecolor(), forstate: uicontrolstate.selected) } } the thing have add target action button, pass button instance method , set on sender.selected = yes if selecting or sender.selected = !sender.selected if on/off behaviour wanted. in code defined how should selected state, have set control state. remember button can combine multiple states @ same t

Distributed Web crawling using Apache Spark - Is it Possible? -

an interesting question asked of me when attended 1 interview regarding web mining. question was, possible crawl websites using apache spark? i guessed possible, because supports distributed processing capacity of spark. after interview searched this, couldn't find interesting answer. possible spark? how way: your application set of websites urls input crawler, if implementing normal app, might follows: split web pages crawled list of separate site, each site small enough fit in single thread well: for example: have crawl www.example.com/news 20150301 20150401, split results can be: [www.example.com/news/20150301, www.example.com/news/20150302, ..., www.example.com/news/20150401] assign each base url( www.example.com/news/20150401 ) single thread, in threads data fetch happens save result of each thread filesystem. when application become spark one, same procedure happens encapsulate in spark notion: can customize crawlrdd same staff: split sites: def g

asp.net - i try make upload file using telerik tool with update panel to uplaod file using ajax but it dose not work correctly -

i nead upload file without postback, want use upload panel send data ashx save file <telerik:radscriptmanager runat="server" id="radscriptmanager1" /> <telerik:radskinmanager id="radskinmanager1" runat="server" showchooser="true" /> <div class="demo-container size-wide no-bg"> <telerik:radajaxpanel id="radajaxpanel1" runat="server" clientevents-onrequeststart="requeststart" loadingpanelid="loadingpanel1"> <div class="uploadpanel"> <div class="leftpanel"> <div class="controls first"> <span class="label">nick</span> <br /> <telerik:radtextbox id="nicktextbox" runat="server" skins ="silk" width="183px"></telerik:radtextbox>

c# - Rooms and Guests (object add to another object?) -

basically creating hotel check in kind of system , wanting create rooms 1-100 when create new object guest want assign guest room object if me. here have far guest , room class. edit: sorry not making clear asking. wanting know how can connect guest object room object using leadname property if possible? , best way store these rooms , properties such guests staying in them etc? roomclass: using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace hotel_check_in { public class room { public int roomnumber; public string roomtype; public string smokingallowed; public boolean booked; private guest leadname; public room() { } } } guest class: using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace hotel_check_in { public class guest { public string leadname; public in

Creating portlet in liferay using plugin SDK -

i trying create portlet using plugin sdk in liferay command prompt (create.bat hello-world "hello world") every time ended below error. what went wrong: problem occurred configuring root project 'liferay-plugins-sdk-6.2'. could not resolve dependencies configuration ':classpath'. not resolve commons-codec:commons-codec:1.9. required by: :liferay-plugins-sdk-6.2:unspecified not ' http://cdn.repository.liferay.com/nexus/content/groups/pu blic/commons-codec/commons-codec/1.9/commons-codec-1.9.pom'. connection http://cdn.repository.liferay.com refused please me how can rid of this. thanks, sourav this seems glitch https certificate name not matching hostname, there's https redirect when access http://cdn.repository.liferay.com/ directly - content there, e.g. on http://cdn.repository.liferay.com/nexus/content/groups/public/commons-codec/commons-codec/1.9/commons-codec-1.9.pom browser shows it. reason l

java ee - How to segregate common libraries from different war files into common location? -

this might seem novice question want clarify. have project has multiple wars deployed on server. of these use same jar files in lib folder. there way can segregate common libraries (say build ear/lib) can read rather packaging same jars individual wars.

Hatch a plot in MATLAB -

Image
i use code in order generate graph: and must hatch outside square. pos = [3.75 5.6 53.5 29.5]; %spatiul nemasurat axis([0 61 0 45]) %axele set(gca,'yticklabel',{'0', '7.5','11.85', '16.2', '20.55', '24.9', '29.25', '33.6', '39.3', '45'}) rectangle('position',pos,'edgecolor','black') i made function hatch_coordinates can return hatch pattern coordinates ( get code @ bottom of anwser ). that, plot hatch pattern on axis, plot rectangle on top of it. have set face color of rectangle hide pattern behind. xlim = [0 61] ; ylim = [0 45] ; [x,y] = hatch_coordinates( xlim , ylim ) ; %// return coordinates plot hatch pattern plot(x,y,'k') %// , plot pattern, attributes want (color, linespec, etc ...) hold on ; grid off pos = [3.75 5.6 53.5 29.5]; %spatiul nemasurat axis([0 61 0 45]) %axele set(gca,'yticklabel',{'

messaging - Publish/Subscribe pattern with subscriber response -

is possible in publish/subscribe pattern? a publisher publishes message topic; subscriber(s) receive(s) message; the subscribers reply publisher custom message. is step 3 possible? i'm designing system use mqtt protocol (communication between smartphones , microcontrollers). however, subscriber needs send answer publisher other acknowledged message. there no way directly reply message in mqtt system, there nothing stop using 2 topics (outboud/inbound) , including message id in payload of message identify reply original published message

Two Wordpress search results pages -

i have 2 different search results depending on page, user on. i have duplicated how previous search contents display, added code want staff search show, , put if statement around it. if user on page 'staff' - show else show this. i cant seem if-statement work, appreciated. edit this original working code, before put if statement in, try , create set of results staff searching specific page. <?php if ( is_home() ) { $paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : get_query_var( 'paged' ); $args = array( 'showposts' => (int) get_option('trim_homepage_posts'), 'paged' => $paged, 'category__not_in' => (array) get_option('trim_exlcats_recent'), ); query_posts( apply_filters( 'et_home_args', $args ) ); } ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <article class="entry post clearfix preowned

javascript - how to transfer data received from UDP to the webpage in node.js -

i'm running 2 apps here . have client: var port = 5007 ; var dgram = require('dgram'); var client = dgram.createsocket('udp4'); client.on('listening', function () { var address = client.address(); console.log('udp client listening on ' + address.address + ":" + address.port); client.setbroadcast(true) client.setmulticastttl(128); client.addmembership('224.1.1.1'); }); client.on('message', function (message, remote) { console.log('a: epic command received. preparing relay.'); console.log('b: from: ' + remote.address + ':' + remote.port +' - ' + message); }); client.bind(port); and server: var port = 5007 ; var dgram = require('dgram'); var client = dgram.createsocket('udp4'); client.on('listening', function () { var address = client.address(); console.log('udp client listening

c# - Regex Latin characters filter and non latin character filer -

i developing program ,where need filter words , sentences non-latin character. problem is, found latin character words , sentences , not found words , sentences mixed latin characters , non-latin characters. example, "hello" latin letter word, , can match using code: match match = regex.match(line.line, @"[^\u0000-\u007f]+", regexoptions.ignorecase); if (match.success) { line.line = match.groups[1].value; } but not found example mixed non-latin letter word or sentences : "hellø sømthing" . also, explain regexoptions.none or regexoptions.ignorecase , stand for? the 4 "latin" blocks (from http://www.fileformat.info/info/unicode/block/index.htm ): basic latin u+0000 - u+007f latin-1 supplement u+0080 - u+00ff latin extended-a u+0100 - u+017f latin extended-b u+0180 - u+024f so regex "include" of them be: regex.match(line.line, @"[\u0000-\u024f]+", regexoptions.none); while reg

c# - Bind DataGridTextColumn to method WPF -

is possible bind datagridtextcolumn method in xaml.cs? this xaml <my:datagrid.columns> <my:datagridtextcolumn binding="{binding iditem}" header="id item" width="150" isreadonly="true"/> <my:datagridtextcolumn binding="{binding concatenarmoneda}" header="costo" width="*"/> </my:datagrid.columns> and want bind second column following function private string concatenarmoneda { { return viewmodel.registro.costo.tostring() + " " + viewmodel.registro.sosmoneda.descripcion; } } this should result in 2 properties being concatenated in same column i have seen working textblock not working in case. see bind property method update more code requested this whole grid <grid grid.row="2" background="{dynamicresource grisoscuro}"> <my:datagrid

java - Using Thread local with SDF and removing it after usage -

using simple date format not thread safe. in order avoid it, threadlocal used. used maintain state in each thread. should careful while using can lead memory leaks. sdf set on threalocal , later used read it. prevent memory leakage, should removed well. can please illustrate same example thread local needs removed after sdf usage. below code public class concurrentdateformataccess { private threadlocal<dateformat> df = new threadlocal<dateformat> () { @override public dateformat get() { return super.get(); } @override protected dateformat initialvalue() { return new simpledateformat("yyyy mm dd"); } @override public void remove() { super.remove(); } @override public void set(dateformat value) { super.set(value); } }; public date convertstringtodate(string datestring) throws parseexception { return df.get().parse(datestring); } } please client code calling , handling removal part of threadlocal well

Set HTML Form data into PHP Variables -

this question has answer here: html form post php page [closed] 2 answers this basic, still... how create html form then, upon clicking enter button, sets text inside of field php variable, used somewhere else on page? php server-side language, have remember although php , html on same page, processed in different locations (server , client). the php interpreter processes .php file , runs code between <?php ?> tags. resulting processed html code sent client of client side processing can take place (css, js, html..). so when submit form, send form data server in can access form elements $_get[] , $_post[] arrays depending on if form's method or post. to see arrays carry, print them out print_r($_get); but agree looking @ basic php tutorials online basics down can understand what's going on.

ios - PostNotificationName Exception from inside shouldSelectViewController -

tab bar has log-out button displays login screen when tapped. i want put confirm logout alert before leaving current tab view , added following code beginning of shouldselectviewcontroller block: if(viewcontroller == mlogoutcont) { // post notification initiate showing logout confirmation alert. [[nsnotificationcenter defaultcenter] postnotificationname:@"confirmlogout" object:self userinfo:nil]; return false; } the app crashes inside postnotificationname call following nsexception error: 2015-04-29 09:40:59.333 testapplication[5420:210308] -[nsconcretenotification presentviewcontroller:animated:completion:]: unrecognized selector sent instance 0x7fe17217cc60 2015-04-29 09:40:59.341 testapplication[5420:210308] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[nsconcretenotification presentviewcontroller:animated:completion:]: unrecognized selector sent instance 0x7fe17217cc60' if comment out postnot

Undefined variable: _SESSION [CORE/src/Network/Session.php CakePHP 3.0 -

i using cakephp 3.0, , uploaded server, working fine in local somehow after uploading server shows error notice (8): undefined variable: _session [core/src/network/session.php, line 438] if have idea please me. still trying solve it. have tried put session_start(); in appcontroller , many other places goes blank. i have found issue, when uploading files servers automatically appending white blank lines @ end of appcontroller , controller files. so when removed blank lines files working fine again //to detect file have issue or space or header start //file location : vendor/cakephp/cakephp/src/network/session.php public function write($name, $value = null) { if (empty($name)) { return; } if (!$this->started()) { $this->start(); } $write = $name; if (!is_array($name)) { $write

c - wrong output on eclipse -

i open file called "elenco" in order write strings taken keyboard input, files create through eclipse empty, ideas why? before problem regularly wrote on file, output full of strange symbols. ds_file = open("elenco",o_rdwr|o_creat, 0666); if (ds_file==-1) { perror("errore nell'apertura del file"); } with take strings keyboard printf("cognome >> "); scanf("%s", cognome); printf("nome >> "); scanf("%s", nome); printf("telefono >> "); scanf("%s", telefono); and write parameters in file list, using support struct called contacts int aggiungi(contatto a, int df){ int sizewr; lseek(df,0,2); sizewr=write(df, a.cognome, sizeof(a.cognome)); if(sizewr==-1) return 0; sizewr=write(df, a.nome, sizeof(a.nome)); if(sizewr==-1) return 0; sizewr=write(df,

c++ - How to make the color of the parent and child window same? -

i hardly know windows.h library, have make application using (long story). anyways appreciate if can patient me on one. child window contains static text displayed on parent window, colors different how make them same? have tried googling don't seem hang of anything. oh , using c++. i saw on msdn hresult enablethemedialogtexture( _in_ hwnd hwnd, _in_ dword dwflags ); but not sure use it. my handle child window start. hresult enablethemedialogtexture(start,etdt_disable); i tried errors such [error] 'etdt_disable' not declared in scope [error] expression list treated compound expression in initializer [-fpermissive] i have backgroud as wc.hbrbackground = (hbrush)(color_gradientinactivecaption+1); my child window switch(message) { case wm_create: start = createwindow("static","some text here", ws_visible|ws_child,200,100,300,100,hwnd,null,null,null); break; case wm_destroy: { postqui

c++ - How do I include shared-library dependencies with my binary (w/o using a .deb or .rpm), and/or statically link against PulseAudio? -

i'm having hard times in building command line tools, written in c++, executed both i386 , amd64 versions of ubuntu (ideally other distros well, that's not important). distributed on usb key, have no control packaging. my command line tool should play audio buffer well, , i'm using pulseaudio simple in order play audio buffers. please note executable runs fine on development machine. problems arises when copy on usb key , run on other machines. there, launch executable, "file not found" error bash; have learned, should because of missing libpulse-dev package (and library, dynamically linked) on target machine. so, i'm kindly asking: i'm supposed do? tried build 32bit static pulseaudio can't compile, , don't know else try. there way, apart static linking, deploy shared libraries application in usb key? thanks please include relevant shared libraries on stick. that, run ldd your_app list of relevant libraries. make preferable

active directory - Security group in LDAP connection string -

i've following structure in active directory i.mydomain.dk myorganizationalunit mysecuritygroup i want users in security group (mysecuritygroup) have access website. ldap connection string looks this: ldap://i.mydomain.dk/ou=mysecuritygroup, ou=myorganizationalunit, dc=i, dc=mydomain, dc=dk this not working because mysecuritygroup not ou. is possible include security group in ldap connection string? if so, how should ldap connection string like?

ifelse in 'r' returns NA value -

i have 2 data frames, , want match contents of 1 other, using following function: t <- read.csv("f:/m.tech/semester4/thesis/code/book1.csv") s <- read.csv("f:/m.tech/semester4/thesis/code/a4.csv") x <- nrow(s) y <- nrow(t) for(i in 1:x) for(j in 1:y) ifelse (match(s[i,2], t[j,1]), s[i,9] <- t[j,2] , s[i,9] <- 0) for code, when contents match works fine. else part returns na. how can assign 0 places there no match. getting result as: # word count word tf score word robability log values tfxidf score keyword probability # yemen 380 yemen 1 0.053938964 2.919902172 2.919902172 na # strikes 116 strikes 0.305263158 0.016465578 4.106483233 1.25355804 0.5 # deadly 105 deadly 0.276315789 0.014904187 4.206113074 1.162215455 0.7 # new 88 new 0.231578947 0.012491128 4.38273661 1.014949531 na instead of na . want store 0 there. issue 1: ifelse returns 1 of 2 values, depending on test condition. it'

uitableview - keep UISwitch state of a prototype cell when changing ViewControllers -

i have uitableviewcell subclass have connected uiswitch custom prototype cell. (data passed in table view previous viewcontroller) when change view controllers state of uiswitch changes default need way remember state of switch while navigating through app. have searched few other topics, nothing seemed fall in case. here code: import uikit class tableviewcell: uitableviewcell { @iboutlet weak var mystaticswitch: uiswitch! @iboutlet weak var celllabel: uilabel! @ibaction func myswitch(sender: uiswitch) { if mystaticswitch.on { self.celllabel.text = "on" //do other things } else { self.celllabel.text = "off" //do other things } } override func awakefromnib() { super.awakefromnib() // initialization code } override func setselected(selected: bool, animated: bool) { super.setselected(selected, animated: animated) // configure view selected state } } you should have model object used dete

javascript - How do I lock the orientation to portrait mode in a Mobile Web Application? -

i making web application using html, , javascript mobile devices (phones). how can lock screen orientation in portrait? there extensions, or frameworks this? edit: when user goes landscape mode, want div (in shape of box if matters) displayed contains text "please turn device portrait." you can use following css media query: @media screen , (orientation: landscape) { .main-content { display: none; } .use-portrait { display: block; } } which hide main-content , show use-portrait div when device in landscape mode. can use additional css rotate use-portrait div further entice user that: .use-portrait { -webkit-transform: rotate(90deg); transform: rotate(90deg); } and may need translate appear correctly.

formatting - Convert milliseconds to individual format in C# NPOI -

Image
i use npoi .net third party library export datas *.xlsx file. have got time value represented in milliseconds. example, 2 minutes 12 seconds 3 milliseconds represented 132003 milliseconds. display "132003" "02m 12.003s" in excel. if click cell in excel contains value, see "02m 12.003s" in cell, , "132003" in formula editor. how can solve it? thanks in advance. consider code below: var t = timespan.frommilliseconds(521516); var formatted = string.format("{0:d2}m:{1:d2}s:{2:d3}ms", t.minutes, t.seconds, t.milliseconds); system.diagnostic.debug.writeline(formatted); this output: 08m:41s:516ms you can use code retrive formatted text , add excel .

ruby on rails - I have two hash and want to check whether the key in first hash exist in second hash -

hash1 = simple_hash = {"month" => "january", "number" => "1"} hash2 = {"number" => "2"} want check whether second hash contains key in first hash. i using this, not approach. simple_hash.each |k,v| hash2.each |k1,v1| if k1==v1 puts k1 end end end to common keys: hash1.keys & hash2.keys # => ["number"] incase hash2 has single key: hash1.keys.include?(hash2.keys.first) # => true if interested in: want check whether second hash contains key in first hash. (irrespective of key). should sufficient: !(hash1.keys & hash2.keys).empty? # => true

android - Select CheckBox of all ListViewItem -

i got listactivity list items i've created. each item got checkbox in it. in addition, layout got button suppose check check boxes, yet it's not working though onclicklistener of button being called. this method called list adapter: public void changeallcheckstatus(boolean checked) { synchronized (items) { (itemdata item : items) { item.checked= checked; } } notifydatasetchanged(); } and getview method: @override public view getview(int position, view convertview, viewgroup parent) { view vi = convertview; if (vi == null) { vi = m_inflater.inflate(r.layout.myitem, null); } textview nametextview = (textview) vi.findviewbyid(r.id.firsttext); textview addresstextview = (textview) vi.findviewbyid(r.id.secondtext); checkbox cb = (checkbox) vi.findviewbyid(r.id.the_checkbox); nametextview.se

javascript - CSS not dynamically updating in AngularJS -

i'm trying make 2 div's width set angularjs value (0 - 100) did this: <span class="green" ng-style="{width: '{{videorating}}%'}"</span> <span class="red" ng-style="{width: '{{100-videorating}}%'}"></span> but width calculated on initial value of videorating. when change value, won't update style. any suggestions on how this? i tried adding ng-cloak , $scope.$apply() no luck ng-style should not use {{}} interpolation directive, use direct scope variables there. markup <span class="green" ng-style="{width: videorating + '%'}"</span> <span class="red" ng-style="{width: (100 - videorating) + '%'}"></span>

c# - Windows fonts are not recognized on .net 3.5 + windows xp -

i want set font of label labeltime.font = new font("gotham rounded medium", 120); in win8 works. on xp machine not. font listed in font folder. reinstalled isn't recognized winxp+.net 3.5? font works example in wordpad. any ideas? winforms on win xp doesn't use gdi+. therefore can't display otf fonts. converting fonts ttf enable them on win xp.

java - What is the difference between queryvalue() and querynode()? -

when wrote line: this.atputifnotnil("qwerttty", profile.queryvalue("qwertty"), profile); it throwing compile time error. when changed querynode() , got rectified. this.atputifnotnil("qwerttty", profile.querynode("qwertty"), profile); i want know difference between two.

sql - Using indexes in json array in PostgreSQL -

referring original stackoverflow question , trying apply gin indexes keys in objects of array in postgres 9.4 i'm not getting results stated in first answer. can please rectify error? the steps followed have been written below. part 1: creating table , indexes create table tracks (id serial, artists jsonb); create index tracks_artists_gin_idx on tracks using gin (artists); insert tracks (id, artists) values (1, '[{"name": "blink-182"}]'); insert tracks (id, artists) values (2, '[{"name": "the dirty heads"}, {"name": "louis richards"}]'); part 2: query select * tracks artists @> '{"name": "the dirty heads"}'; id | artists ----+--------- (0 rows) this query gives empty results. tried use jsonb_path_ops gin indexes. alternative index , query: drop index tracks_artists_gin_idx; create index tracks_artistnames_gin_idx on tracks using gin (artists jsonb_pa

c# - readbytes of a file and running it -

i have 2 .net files ! once c#.net , 1 vb.net :) now want read bytes of , running :) dim mybyte byte() = system.io.file.readallbytes("e:\projects\expired.exe") system.reflection.assembly.load(mybyte) could not load file or assembly '8192 bytes loaded mybyte you have read file, stuffs (decrypt?), write content new file , run it. (you can embed file in project resources if want): // read file content project resources byte[] filecontent = myproject.properties.resources.myfile; // <do stuffs file content here> // write new file content temp file string tempfile = "yourfile.exe"; file.writeallbytes(tempfile , filecontent ); // run app process proc = process.start(new processstartinfo(tempfile));

ios - Pop to root view at midnight if app is still running -

i attempting return user first screen of application if app still , running @ midnight , things transition new day. i using - (void)applicationsignificanttimechange:(uiapplication *)application to detect change there issues... first, there random triggers occurring @ 9:30 or 10:45 causing app kick main screen soon. understand there other factors trigger method daylight savings , messages carrier. neither of applied day triggering early. so added in code manually check clock hour , minutes checking see if time on device between 11:58 pm , 12:02 am. //get current time nsdate* = [nsdate date]; nscalendar *gregorian = [[nscalendar alloc] initwithcalendaridentifier:nsgregoriancalendar]; nsdatecomponents *datecomponents = [gregorian components:(nshourcalendarunit | nsminutecalendarunit | nssecondcalendarunit) fromdate:now]; nsinteger hour = [datecomponents hour]; nsinteger minute = [datecomponents minute]; if ((hour>=23 && minute > 58) || (hour == 0 &

php - Error "Undefined index" if check box is not checked -

when check checkbox there no errors, when didn't check checkbox gives me errors. <?php if(isset($_request['btn'])) { $remmber = $_request['active']; if($remmber == "on") { echo "checked"; } else {$remmber = "";} } ?> <html> <form name= "frm" action = "test.php" method = "post" > <p>username <input type = "text" name = "name" value = "" /> </p> <p>password <input type = "text" name = "password" value = "" /> </p> <p> <td colspan = "2"><input type = "checkbox" name = "active" value = "active" />keep me loged in </p> <p><input type = "submit" name = "btn" value = "login"

plsql - PLS-00103 ERROR, what is wrong in the code -

create or replace procedure proc2_del_rows (v_tname varchar2, v_condition varchar2 default null) sql_stmt varchar2(500); where_clause varchar2(200) := 'where'||' '||v_condition; begin if v_condition null where_clause := null; end if; sql_stmt := 'delete :1'||' '||where_clause; execute immediate sql_stmt using v_tname; commit; end; / the table name can't bind variable. dbms_assert on input table name parameter , make sure valid table name literal, , directly concatenate delete statement. @ least protect against sql injection. i'd know reason behind doing delete using procedure , granting execute on procedure individual users, rather granting delete on table user directly, easier control/restrict. don't see how better in terms on security if going for.

How to encode in XML on SQL Server -

i generating xml follows: set @xml = ( select personalmessage [personal_message] #temporarydb xml path ('order'), root ('orders'), elements ); next add encoding info: select n'<?xml version="1.0" encoding="utf-8"?>' + convert(nvarchar(max), @xml) and when save xml bcp this: <?xml version="1.0" encoding="utf-8"?> <orders><order> <personal_message>liebe x1 und x2, "wir wuenschten wir koennten heute mit euch zusammen sitzen. das holen wir bald wieder nach." eure &amp; ina </personal_message></order></orders> but want this: <?xml version="1.0" encoding="utf-8"?> <orders><order> <personal_message>liebe x1 und x2,&#13;&#13; &quot;wir wuenschten wir koennten heute mit euch zusammen sitzen. das holen wir bald wieder nach.&quot; &#13;&#

c# - File size not showing in windows explorer -

i writing lots of files using c#. file size 1 mb , 500 files there in folder.all files written of contents. files showing file size 0 in windows explorer though has contents. i can see size when copy files other location. can see size when open in same location , refresh windows explorer. this propably caching problem in windows explorer. measured filesize when program created new file, before content has been written it. showing wrong (outdated) value. if can open file , see content, worked fine. try refresh folder in windows explorer f5 or try again after time. you can open console ( cmd ), go target folder ( cd path ) , take @ correct filesize using command dir .

android - Rotate view when device rotated with locked orientation -

in app need rotate few views when device rotated. i'm using android:configchanges="orientation" it's important not re-create activity on rotation rotate few views. when i'm trying @override public void onconfigurationchanged(configuration newconfig) log.i("info","changed"); nothing happened so, main question is: how handle device rotation when screen interface still same. update #1 i need work same activity when device rotated because of camera object , other stuff! http://i.stack.imgur.com/inhuf.jpg (have no 10 reputatiuon post image)

c# - EF6: How can we remove an unused navigation properties? -

i using entity framework 6 in database first model microsoft sql 2008 server. on every table, there integer field called creationuserid. field part of foreign key table user primary key userid. when schema generated database, navigation property creation user created every entity. also, make user entity having lot of navigation properties. i remove navigation properties because not navigate them. when highlighted relation between 2 tables, user , bank pressed delete key, relation , navigation property on both table got removed got message: error 3023: problem in mapping fragments starting @ line 1494: column bank.creationuserid in table bank must mapped: has no default value , not nullable. i created scalar integer property called creationuserid on bank entity , mapped field creationuserid property creationuserid. got message: error 3007: problem in mapping fragments starting @ lines 1504, 1701: column(s) [creationuserid] being mapped in both fragments different conceptua

windows - Perl script to download a file and check filetype -

what want simple: 1) download file hard-coded url (it stay same) 2) check if file pdf (i thought best check magic number %pdf) 3) if so, rename file , move folder xy||if not, rename accordingly. note: required run on windows 7 system. here code: #!/usr/bin/perl use warnings; use strict; use lwp::simple; use posix qw( strftime ); use file::copy; use file::type; $date = strftime("%m/%d/%y", localtime); $url = "http://www.oracle.com/technetwork/database/options" ."/advanced-analytics/r-enterprise/ore-reference-manual-1882822.pdf"; $dlfile = "test.pdf"; $resp = ''; $srcdir = "c:\\pdfscripthome"; $dest = "c:\\pdfdump"; $old = "$srcdir/$dlfile"; $resp = getstore( $url, $dlfile ); sub checkfiletype { $chkfile="$srcdir//test.pdf"; $ft = file::type->new(); $file_type = $ft->mime_type($chkfile); if ( $file_type eq 'application/pdf' ) { move( $ol

java - JPA and Hibernate - id generator -

i'm using jpa , hibernate frameworks , when i'm trying insert new record, hibernate returns error because column 'employee_id' null. class employee: @entity public class employee implements serializable { @id @generatedvalue(strategy = generationtype.identity) private long id; @onetomany(fetch = fetchtype.lazy, cascade = cascadetype.all, orphanremoval = true, mappedby="employee") private list<shift> shifts = new arraylist<shift>(); class shift: @entity public class shift implements serializable { @id @generatedvalue(strategy = generationtype.identity) private long id; @manytoone(fetch = fetchtype.eager, cascade = cascadetype.detach) @joincolumn(name="employee_id") private employee employee; the moment when insert record: employee employee = getemployeedata(); entitymanager.persist(employee); entitymanager.flush(); getemployeedata method: private employee getemployeedata()