Posts

Showing posts from March, 2015

c# - Confusion over relative and absolute paths -

i have wpf program deals images on canvas. i @ stage trying use serialization able save contents of program , reload @ later stage. so @ moment when inserting images control using absolute path values, understand bad idea program wanting save state of program , reload @ later time. so best course of action take in situation. do create folder inside wpf project example called images , copy images use in program folder , point path this? or on wrong lines here? if serializing state data of application, create folder in 1 or more of so-called system special folders, can call environment.getfolderpath . you may example store data application scope (same users) in folder below special folder specified specialfolder.commonapplicationdata enum (which c:\programdata on windows 7 systems). data specific current roaming user (who works on multiple computers on network), stored in folder below specialfolder.applicationdata . there specialfolder.localapplicationdata n

How to create sub menu item within Docpad? -

my document folder structure below index.html post/ post1.html post2.html pages/ about.html interior.html exterior.html gallery.html post.html //listing blog post contact.html interior/ in1.html in2.html ... in5.html exterior/ ex1.html ex2.html ... ex7.html gallery/ img1,2,3,4 my menu structure this home | | interior | exterior | gallery | posts | contact i create menu listing page collection, it's ok! .navigation nav ul.nav.topnav li.dropdown.active a(href='/') | home each doc in getcollection('pages').tojson() - clazz = (document.url === doc.url) ? 'active' : null li.dropdown(typeof="sioc:page", about=doc.url, class=clazz) a(href=doc.url, property="dc:title")= doc.title how can add submenu item interior , exterior listing pages interior/exterior folder thank in advance! may use docpad-menu ..?

.htaccess - Protecting a html page from access (except for redirected users) -

i have html page information signup form redirect traffic see. when users sign redirected there, dont want finds out page accessing it. for example www.buyshoes123.com has sign form, , when users sign up, they'll automatically redirected to; www.buyshoes123.com/discount.html is there way hide discount.html page else redirected users? example, if user decides copy-paste address , give colleague, how can prevent displaying? i don't think cookie solution mentioned in comment enough here. dealing here in general identity management . registration should result in identity creation registering user , start managed (logged in) session . then, on protected page, must check identity , session. have to utilise server side scripting achieve this.

c# - Resource not found error -

i have problem accessing method on homecontroller. show code of method : [httpget] public actionresult decriptidentifiantetredirige(string login_crypter, string mdp_crypter) { string loginacrypter = _globalmanager.protegemotdepasse(login_crypter); string mdpacrypter = _globalmanager.protegemotdepasse(mdp_crypter); user userapp = new models.user(login_crypter, mdp_crypter); if (userapp.authentificationvalidee(userapp.userlogin, userapp.password)) { session["name"] = userapp.userlogin; return redirecttoaction("accueil", "home"); } else { return redirecttoaction("validerauthentification", "home"); } } then in routeconfig.cs wrote route : routes.maproute( name: "authentificationapresdecryptage", url: "{controller}/{action}/{login_crypter}/{mdp_crypter}", defaults: new

java - spring singleton object state -

here have 1 doubt spring singleton object . spring create atleast 1 object per bean definition depending on scope. singleton scope, 1 object per bean definiton. as spring context provide singleton instance why not able share same session of it. the below code give error: throw null pointer error. org.hibernate.transactionexception: transaction not started while trying access same instance session. session instance null. in main method public static void main(string[] args) { testdao dao = (testdao) applicationcontext.getinstance().getbean(daotype.testdao.tostring()); dao.startoperation(); for(test test:testlist) { saveisbean(test,true) } dao.endoperation(); } this method save data if session open reuse it. private void saveisbean(isbean isbean,boolean issessionalreadyopen) throws ntexception { testdao dao = (testdao) applicationcontext.getinstance().getbean(daotype.testdao.tostring()); if(issessionalreadyopen) { //dao.start

jquery - Doubled page scroll by javascript -

i have code var scroll = $(window).scrolltop(); $(window).on("scroll", function () { scroll+=100; $(window).scrolltop(scroll); //* }) but code scroll window loop bottom. how make throttle in order avoid recursion ? the goal: have 404 page , iframe index page below of 404. , when user try scroll 404 page - index pages scroll top doubled speed to solve issue took different approach, upon scroll scrolling index location once. var $window = $(window); var indexlocation = 505; $window.one("scroll", function(e){ if ($window.scrolltop() < indexlocation){ $("body").animate({scrolltop: indexlocation}); } }); also can check out here: http://jsfiddle.net/jsjjk/1/

vb.net - convert numeric up down value to time format -

i have 1 numericupdown1 control if select 5 in numeric down control.the calling value this: numericupdown1.value that return value 5 integer instead of getting 5. want value in time format if select 5 .that should return 00:05:00 .. how can convert numeric down value times.. in data base want store value data type time(7).i tryed this: dim value timespan = convert.todecimal(numericupdown1.value) but getting error you using timespan wrongly, better rely on date : dim value date = new date(now.year, now.month, now.day, 0, numericupdown1.value, 0) you can convert variable string format want doing: dim valueasstring string = value.tostring("hh:mm:ss") this right way use timespan : dim value timespan = new timespan(0, numericupdown1.value, 0) but recommend date alternative above. use timespan measuring intervals (between date type variables) , better store date/time-related information date , easier deal with.

webrtc datachannel onopen is not fired -

my friends i'm trying test of webrtc. start no signal server, copy/paste offer , answer hand. my process is: setup events onicecandidate, datachannel.onopen, onmessage..etc with pc1.onicecandidate set pc1.addicecandidate(event.candidate); pc2, wrong? then create session: pc1 createoffer , set local description pc2 set offer(generated pc1 in above step) remote description, generate answer pc1 set remote description answer(generated pc2 in above step) datachannel.onopen not fired, know why? missing step? thanks help! ~rosone i'm using chrome 28. windows 2003 32bit. i've made work using socket server signaling. pc2 should add pc1's candidate and pc1 should add pc2's candidate. vip24.ezday.co.kr/docs/rtc-datachannel-for-beginners.html help. the peers make many candidate, , should added peer after generate 1 candidate, candidate fowarded peer signaling server

sql - MySQL slug function on insert -

i have table slug field. it's possible populate automatically field function manipulation of field? something like: insert people('name','slug') values ('xxxx',slug(name)); are looking this? create table people (`name` varchar(128), `slug` varchar(128)); -- it's not real function it's oversimplified example -- need implement own logic create function name_slug(name varchar(128)) returns varchar(128) return lower(replace(name, ' ', '-')); create trigger tg_people_insert before insert on people each row set new.slug = name_slug(new.name); insert people (`name`) values ('jhon doe'),('ian martin louis'), ('mark lee'); select * people; output: | name | slug | --------------------------------------- | jhon doe | jhon-doe | | ian martin louis | ian-martin-louis | | mark lee | mark-lee | here sqlfiddle demo

java - Error in connecting to PostgreSQL database using data inserted from android application through PHP -

my current android application allows user key in chat room name i'll utilizing name stored database name. hence name stored used connect database using php web service. understand there're solutions editing pg_ident.conf file, allowing www-data recognized 1 of users access database. however, i'm hoping have better solution. in advance given. this error message got warning: pg_connect() [function.pg-connect]: unable connect postgresql server: fatal: role "www-data" not exist. php code (blabla.php) <?php $host = "localhost"; $user = "bbcc"; $db=$_post['name']; $passwd = "abc"; $con = pg_connect("host=$host dbname=$db user=$user password=$passwd") or die ("could not connect server\n" . pg_last_error()); ?> java code snippet private void valid() { string room = "abcd"; try{ httpparams params = new basichttpparams(); htt

Issue while using WinForm user Control in asp.net MVC applicaton -

i need use winform user control in asp.net mvc4 application. the control has been embedded using object tag , classid attribute, upon viewing view in browser, blank frame visible, without cross-sign on top-left corner of frame. viewing browser on machine .net framework 4.5. similar issue faced in asp.net application same rectified using registry setting (enableiehosting = 1). kindly suggest. thanks. gitika winforms user controls not intended used asp.net (mvc or not) application. as should knows, asp.net generate html codes sent browser when requested. browser can run on multitude of operating systems (os). winforms user controls run under microsoft windows. the second thing know browser run in restricted environment , such limited access computer , os. since using asp.net mvc, should create partial view similar user control if want. also, thing know logic behing control need converted javascript or jquery. browsers understand.

qtcpsocket - QT connection with existing server with username and password -

i working on adapter interface connect simulator have constructed existing simulator running on server. i have been going through qabstractsocket , have got basic idea of it. but problem server trying access, has authentication system, need enter username , password credentials. as long have gone through class reference have not got solutions. can please guide me of qt class should use or can tell me ideas of how access them?

entity - Doctrine2, retry insert with different value on duplicate key -

i'm trying create hash. following path followed: create hash object unique key on $hash constructor fills in seed generate actual $hash try saving it if saving failed because of error 23000 (duplicate key), make different hash , repeat till unique hash made doesn't exist yet. now here's problem. using doctrine2, closes entitymanager when query fails due sql error. in case that's no problem because retry it. one solution search database if hash exists. due very, low amount of collision (md5) , need stuff fast possible (every ms can save worth it), want skip check. another solution thought worth shot, clone entity manager. however, internally entity manager passed objects inside , not cloned passed reference. a third solution use registry , create new entity manager. however, outside of object not have right entity manager: object gets em -> query object b gets em -> query > error > creates new em object c gets em -> query new em o

c# - error creating dynamic controls -

i supposed create label , textbox when checkboxlist event selectedindexchanged fires. i tried following code, giving me error: multiple controls same id 'mylab1' found protected void chkcar_selectedindexchanged(object sender, eventargs e) { // panel2.controls.clear(); string dat = datetime.parse(gridview1.selectedrow.cells[4].text).tostring("dd-mmm-yyyy"); lblname.text = ""; (int = 0; < chkcar.items.count; i++) { int sum = 0; if (chkcar.items[i].selected == true) { panel tt = new panel(); panel2.controls.add(new literalcontrol("<br />")); label mylab = new label(); mylab.id = "mylab" + nextid1; mylab.text = "no of persons in " + chkcar.items[i].value; panel2.controls.add(mylab); controlslist1.add(mylab.id); textbox mytext = new textbox(); mytext.id = &

php - How to split characters with "-" character? -

i generated serial number php, length of serial number 16 characters, want split serial number in 4 characters dash(-) character, format xxxx-xxxx-xxxx-xxxx wrote php code: for ($d=0; $d<=3; $d++){ $tmp .= ($tmp ? "-" : null).substr($serial,$d,4); } so loop return serial number xxxx-xxxx-xxxx-xxxx format, i want know there better way or function in php? i searched in internet found sprintf , number_format don't know how can use function format ! i use str_split() , implode() : $result = implode( '-', str_split( $serial, 4)); str_split() break string array, each element has 4 characters. then, implode() joins array pieces dash. so, if generate random $serial with: $serial = substr(md5(uniqid(rand(), true)), 0, 16); we as output similar to: 59e6-997f-8446-80a2

javascript - Creating links when switching between custom street view panoramas via <select> -

i have street view-map of campus area. can navigate around areas links created getcustomlinks fine. have been stuck while now: there way change between custom street view panoramas via select component? want able navigate around campus area arrows, able jump panorama in select-component. arrows work perfectly. far have managed change panoramas my select-box <select onchange="onchange()" id="hamk_select" width="1000px"> <option value="b_talo_piha">hamk visam&auml;ki</option> <option value="kirjasto">kirjasto</option> <option value="c_talo_auditorio">auditorio</option> </select> onchange()-function function test(){ d = document.getelementbyid("hamk_select").value; var panooptions = { pano: d, visible: true, panoprovider: getcustompanorama, scrollwheel: true, enableclosebutton: false,

excel vba - How can i control the position to copy one sheet into another workbook -

i have code copy 1 worksheet of original workbook terminated workbook , works fine. need control paste position terminated workbook. right paste before ever active sheet. want past second sheet after summary sheet. new macro, thanks. sub copytoternimal() dim copyname string on error goto errmess copyname = inputbox("please enter name of sheet copy ternimal") dim thissheet worksheet set thissheet = workbooks("original.xlsm").worksheets(copyname) thissheet.rows.copy dim newsheet worksheet set newsheet = workbooks("terminated employees.xlsm").worksheets.add() newsheet.name = thissheet.name newsheet.paste thissheet.delete errexit: exit sub errmess: msgbox "xxxxxx." goto errexit end sub i believe thissheet.copy after:=workbooks("terminated employees.xlsm").worksheets("name of first summary worksheet")

cron - Rails/MySQL: Different user timezones -

question 1 - have app on shared hosting in dallas, tx...so database/web server set central time...i'm unable change this, utc off table. my application records , displays date , time data user, every user in different time zone. if configure app (config.time_zone = 'central time (us & canada)') , allow users select timezone, def user_time_zone(&block) time.use_zone(current_user.time_zone, &block) end will ror display returned data in timezone of user's choice? or need evaluate data , modify accordingly before displayed? question 1.1 - have related mailers send daily/weekly/monthly reports users. if run these using cron, need schedule jobs @ different time intervals allow timezones? in other words, if 1 job contains when 'daily' @dates = params[:f]['date range'] = "#{date.current} - #{date.current}" date.current 1 hour ahead on east coast, , 3 hours behind on west , forth. (still using server timezone of ce

javascript - Assembling a var dynamically -

this question has answer here: how use string variable name in javascript? [duplicate] 3 answers how can assemble var in javascript during runtime without eval? var lc = $('.bezeichnung-1').length; (var lt = 1; lt <= lc; lt++) { eval("var neuerwert"+lt+"=0;"); // works don't want use because read eval bad } var lc = $('.bezeichnung-1').length; (var lt = 1; lt <= lc; lt++) { window["var neuerwert"+lt] = 0; // not work } how can assemble var in javascript during runtime without eval? you don't, can make property of something. if these @ global scope, they're properties: var lc = $('.bezeichnung-1').length; (var lt = 1; lt <= lc; lt++) { window["neuerwert"+lt] = 0; // -----^ no `var` keyword } if they're not @ global scope ( good you! ), make

how to increase the jsch buffer size? -

i using jsch sftp file transfer. when send file using sftp command setting buffer size 512 (-b option ) sftp b 512 [sftp server name] , invoking put command, can transfer files in 8.0mbps. (the regular speed 3.0mbps). when same file transfer using jsch api in java, 2.6mbps. there option increase buffer size in jsch or improve speed of jsch? here code... channel channel = null; channelsftp channelsftp = null; log("preparing host information sftp."); try { jsch jsch = new jsch(); session = jsch.getsession(username, hostname, port); session.setpassword(password); java.util.properties config = new java.util.properties(); config.put("stricthostkeychecking", "no"); session.setconfig(config); session.connect(); system.out.println("host connected."); channel = session.openchannel("sftp"); channel.connect(); log("sftp channel opened , connected."); channelsftp = (channelsftp) c

c# - iTextSharp - Position text on top of existing contents -

i have been able absolute position new text x,y co-ordinates new text hides behind existing image. played around stamper, overcontent no success. here's code using: pdfreader reader = new pdfreader(new randomaccessfileorarray(filenameexisting), null); rectangle size = reader.getpagesizewithrotation(1); using (var outstream = new filestream(filenamenew, filemode.create)) { document document = new document(size); pdfwriter writer = pdfwriter.getinstance(document, outstream); document.open(); try { pdfcontentbyte cb = writer.directcontent; cb.begintext(); try { cb.setfontandsize(basefont.createfont(), 12); cb.settextmatrix(10, 100); cb.showtext("my new text"); } { cb.endtext(); } pdfimportedpage page = writer.getimportedpage(reader, 1); cb.addtemplate(page, 0, 0); } { document.close(); wri

java - Using Modeshape 3.3 with JBoss 7.1.1 -

are there manage configure modeshape in jboss 7.1.1? following guide on link below after unzipped files server , restarted , try exectue command: /extension=org.modeshape:add() i get: { "outcome" => "failed", "failure-description" => "org.jboss.modules.moduleloadexception: error loading module c:\\users\\test\\jboss-as-7.1.1.final\\modules\\org\\mo deshape\\jcr\\api\\main\\module.xml", "rolled-back" => true } https://docs.jboss.org/author/display/mode/configuring+modeshape+in+as7 jboss as7.1 last public release of jboss project , 2 years old. has been superseded eap 6.1, based off of jboss project more recent , supported. eap 6.1 far more stable, , modeshape far better runtime platform. why modeshape 3.3 runs in eap 6.1. (jboss as7.1 old , has several critical issues in libraries modeshape uses. why newer releases of modeshape no longer deploy on top of as7.1.) see our documentation , blog

How to export Jetty launch configurations out of Eclipse -

this question has answer here: eclipse: export running configuration 4 answers i export jetty launch configuration eclipse's jetty can consume , use it. have searched .launch file, file found result of setting configurations, not file jetty reads configurations. appreciated, thanks! taken from: https://stackoverflow.com/a/8229831/850475 exporting : go file > export... > run/debug > launch configurations in dialog jetty set filename importing : go file > import... > run/debug > launch configurations in dialog select jetty config set filename

Bootstrap Twitter Modal - Clearing dialog input fields -

i have created modal dialog using bootstrap , i'm having problem modal dialog box not clearing form input fields after box closed or after it's submitted. html <!-- password reset modal --> <div id="passwmodal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <h4>forgot password?</h4> <p>please enter registered email address below , new password sent you.</p> </div> <div class="modal-body"> <div id="sent"><!-- display sent message after password reset --> <form class="form-horizontal" id="reset">

Using Spring Security in Grails with CAS and LDAP -

i trying set spring security in grails authenticating against cas , authorizing against ldap. have found examples several examples (i have 20 browser tabs open right now), none of them answer whole question. of examples grails + cas or grails + ldap, no examples of grails + cas + ldap. so got working, , isn't bad, wish had seen @cantoni's example first. have made easy. setup little more simple his, i'll add here. install spring security core, cas, , ldap plugins. important: until spring-security-cas:1.0.5 updated, wouldn't try use new spring-security-core:2.0-rc2 , spring-security-ldap:2.0-rc2 . cas plugin doesn't seem work them. plugins { .... //security compile ":spring-security-core:1.2.7.3" compile ":spring-security-cas:1.0.5" compile ":spring-security-ldap:1.0.6" ... } you don't need run quickstart command if you're not using daoauthenticationprovider, not. conf

Client/server database for android tutorial needed -

hope everyone's doing great; what best client/server application use database android? i know implementation of database java well. should use mysql, oracle or access example or should use sqlite database if need access via server on internet? i wasn't advised use jdbc @ all; in other way, advised connect database via http request. isn't sqlite database local 1 available on host? any ideas or there tutorial it? i'm bit confused.. thanks in advance , best regards, chris you seems confused. on client side (android app), can use sqlite store data locally. might not necessary @ actually. instance, can used offline features, search, etc. on server side (whatever server side technology know or want learn), can use whatever language, whatever database on whatever server os want. part commonly called back-end, store data while app communicate through http.

mysql - python sql fetchone without poping it off. -

how can use python fetchone() call without removing list. if do: while true: print cur.fetchone() where each line next row. how can like cur.fetchone(pop=false) # doesnt remove list im testing , fetch row later. basically. need fetch row. check in it. if matches, pop if off list , stuff row. otherwise. move on. you can't. store return value first: while true: result = cur.fetchone() if result not none: # something.

c++ - QML File Browser QDirModel vs QFileSystemModel -

i trying implement qml based file browser. there 2 file models in qt 5.1, qdirmodel , qfilesystemmodel, qdirmodel documentation says this class obsolete. provided keep old source code working. advise against using in new code. my code works qdirmodel not qfilesystemmodel, here code: main.cpp #include <qtwidgets/qapplication> #include <qquickview> #include <qqmlcontext> #include <qfilesystemmodel> #include <qurl> #include <qdirmodel> int main(int argc, char *argv[]) { qapplication a(argc, argv); qquickview view; qdirmodel model; view.rootcontext()->setcontextproperty("dirmodel", &model); view.setsource(qurl::fromlocalfile("main.qml")); view.setresizemode(qquickview::sizerootobjecttoview); view.show(); return a.exec(); } and here main.qml: import qtquick 2.0 rectangle { width: 400; height: 400; listview { id: view; anchors.fill: parent; model: visualdatamodel {

c++ - template-based compile time assert with custom messages can only be compiled in some of the compilers -

this code demos compile time assert using template. found can compiled g++ (4.4.7) following cmd line. $ g++ -std=c++98 a.cpp -o nether icc (13.0.1) nor visual c++ (14.00.50727.762 80x86) can compile it. icc, generate error msg this $ icpc a.cpp -o a.cpp(13): error: non-integral operation not allowed in nontype template argument compile_time_assert(true && "err msg"); ^ a.cpp(13): error: class "compiletimeassert<<error-constant>>" has no member "check" compile_time_assert(true && "err msg"); ^ compilation aborted a.cpp (code 2) however found assertions true && "err msg" used in run-time assert add custom messages in assert? questions are can solved without modifying code, proper compile options? if can't, alternative methods of compile time assert custom messages? demo code show follows. #include <iostream> template<bool b> class comp

ios - How to create if-else loop near #import sttatement to check the Device Type (iPad/iPhone) -

i using pkrevealcontroller create splitview in app. in pkrevealcontroller.m file giving value how screen reveal using code #define default_left_view_width_range nsmakerange(273, 310) this iphone want make loop select size. if device ipad large else small how can because outside of @interface pkrevealcontroller i have check code on google , find this #if defined(__iphone_6_0) || defined(__mac_10_8) #define af_cast_to_block id #else #define af_cast_to_block __bridge void * so can create selecting device? you can use code achive change value according need in pkrevealcontroller.m #define default_left_view_width_range_ipad nsmakerange(700, 700) #define default_left_view_width_range_iphone nsmakerange(273, 310) #define default_right_view_width_range_ipad default_left_view_width_range_ipad #define default_right_view_width_range_iphone default_left_view_width_range_iphone and in iterface find out setup method replace method pragma mark - setup - (void)se

jQuery - Image starts off invisible then fades in when user scrolls -

i'm close achieving effect want, have 1 obstacle left don't know how solve. basically, want start off image (that says "a new era of hosting), then, user scrolls, image fades out, , new 1 fades in, saying "tired of hosting kids?" i'm close achieving effect. problem is, page loads, both of images visible, , second 1 disappears begin scrolling. how make second image isn't visible when page loads? here jquery code, given question. please note haven't learnt jquery yet, , way have edited may amateurish or flat out wrong. $(document).ready(function () { var subsection2top = $('.sub-section2').offset().top; $(window).scroll(function () { var y = $(window).scrolltop(); if (subsection2top + 500 < y) { $('.sub-section2').fadeto(100, 1); } else { $('.sub-section2').fadeto(100, 0); } }); }); $(document).ready(function () { var subsectiontop = $('.

javascript - How do I show an element when another element has already been clicked? -

i have link, <a href="manager_view.html"> <p class="in_row">jane doe</p> </a> i want show checkmark, &check;, when jane doe has been clicked in past. how that? fiddle javascript document.getelementsbyclassname('in_row')[0].onclick = function() { this.classname = 'in_row clicked'; } or, if have more one: var rows = document.getelementsbyclassname('in_row'); (var = 0, len = rows.length; < len; i++) { rows[i].onclick = doclick; //this function above code } css .clicked:before { content:"✓"; }

java - Convert plain string to time -

this question has answer here: java string date conversion 13 answers i have string value need convert time , save in mysql.[the column's datatype time in database table] examples of string values might encounter convert time object are: string time = "5:32 pm"; string time = "12:00 am"; string time = "11:43 pm"; i browsed few examples pulled time date object couldn't find apt example, such in case convert plain string. main reason need convert time save in mysql. you can convert java.sql.date : string str = "5:32 pm"; dateformat formatter = new simpledateformat("hh:mm a"); java.util.date date = (java.util.date)formatter.parse(str); java.sql.date sqldate = new java.sql.date(date.gettime()); if need java.sql.time , : java.sql.time time = new java.sql.time(date.gettime());

gitx(L): view files that need committing -

in gitx(l), possible view files need committed? for example, handy have pane shows list of files have changes. however, can't seem see one. any suggestions? you can find list in staging dialog, accessible upper left corner. you'll see classic git commit, list of changed or untracked files, , ability stage , commit them.

c# - Use of local unassigned variable - even with else-statement -

this question has answer here: why compile error “use of unassigned local variable”? 9 answers mediadescription media; foreach(var field in fields) { switch(field.key) { case fieldtype.version: message.version = convert.toint32(field.value); break; case fieldtype.originator: message.originator = originatorfield.parse(field.value); break; ... ... case fieldtype.information: if(media == null) <-- use of local unassigned variable message.description = field.value; else media.description = field.value; break; ... i mean, why? compiler should smart enough precheck declaration , in else-statement declaration gets accessed. what's wrong? being not assigned , being assigned null 2 different states

c++ - Where is the documentation for cstdio's printf? -

on recent question of mine discovered not using printf() should have. specifically, printf() expecting argument of mine type wasn't obvious me. if have looked more closely @ documentation using, problem have solved itself. however, got me thinking, that documentation hardly looks official (although rather comprehensive). started searching official documentation cstdio 's printf() function, , can't seem find it. who owns , distributes code? documentation? header documentation? <stdio.h> * in c standard library, c standard place "official" specification ( printf() documented in section 7.19.6.3 of c99 standard ). all of standard library covered posix, should have man pages . if you're using *nix, can man 3 printf command-line. note posix may declare non-standard extensions behaviour, though. it's documented @ msdn (again, may include non-standard microsoft extensions). * <cstdio> c++ header.

security - Server to Client SSL Encryption w/o SSL Authentication - Tomcat & Spring -

scenario : sensitive information exchanged (1) client server , (2) server client . problem : data exchanged not encrypted, sniffing easy (it's theoretically possible, right?) solution : encrypt data transmitted in either direction (server-to-client , client-to-server). implementation : (1) client server - generate certificate, install private key on server , configure tomcat work on https (many tutorials online). (2) server client - private key goes (or generated by) clients, seems tutorials emphasize that every client should have own certificate sake of authentication. question: if authenticating users through database username/password (hashed salt) combo, still need encrypt server-to-client data transmissions reduce chance of sniffing, can generate 1 private key clients? there other ways of achieving need tomcat/spring? it seems you're mixing up: regular https includes encryption in both directions, , private key + certificate on server side.

c# - The original state instance has the wrong type -

i exception: invalidoperationexception: original state instance has wrong type. when using version of following cut down code: table existing = context.tables.single(t => t.key == derivedfromtable.key); context.tables.attach((table)derivedfromtable, existing); //thrown here context.submitchanges(); where derivedfromtable derivedfromtable , class derivedfromtable : table . what exception mean (as ((table)derivedfromtable) table , existing table ) , how can resolve it? the (table)derivedfromtable cast meaningless, because attach() method accepts argument of type table widening cast implicit. that doesn't matter, however, because linq sql checks type of passed in object dynamically, , doesn't support treating derived types if base entity (also because casting not change actual type of instance, changes static interface). if want this, you'll need first copy properties of derived instance instance of base type using automapper. example: table e

Csv import and changing locale of server -

on imports, if first character of row special miss. example; "Çanta" importing "anta". searched , problem locale. use centos on server , locale properties is: lang=en_us.utf-8 lc_ctype="en_us.utf-8" lc_numeric="en_us.utf-8" lc_time="en_us.utf-8" lc_collate="en_us.utf-8" lc_monetary="en_us.utf-8" lc_messages="en_us.utf-8" lc_paper="en_us.utf-8" lc_name="en_us.utf-8" lc_address="en_us.utf-8" lc_telephone="en_us.utf-8" lc_measurement="en_us.utf-8" lc_identification="en_us.utf-8" lc_all= i want use turkish charaters. how can change locale avoid csv import problem? you can change locale using setlocale .

c++ - boost::locale::conv utf8 to cp437 -

for last 2 days i've been trying convert utf-8 string cp437 string , i've tried this answer . example situation converting char *utf8="\xc2\xbb" char *cp437="\xaf" (or 175 decimal if will). i came many variations of this: struct consoleoutputwrapper { boost::locale::generator generator; std::string c_output; // charset name std::locale l_output; // locale consoleoutputwrapper() : generator(), c_output("cp437") { generator.locale_cache_enabled(true); l_output = generator(c_output); } void operator<<(const char* str) { std::cout << boost::locale::conv::from_utf<char>(str, l_output); } }; // test consoleoutputwrapper k; k << "\xc2\xbb"; but best conversion i've got > instead of » . any ideas how convert special characters these using boost?

javascript - Returning id from Ajax generated DOM elements -

i know there duplicate ( jquery: how id of dynamically generated element? ) tried solution , couldn't fix problem. an ajax/jquery query has returned table when inspected returns formed table: <table border="1"> <tbody> <tr><td>example</td><td class="del" id="1">delete</td></tr> <tr><td>example2</td><td class="del" id="2">delete</td></tr> </tbody> </table> the jquery code is: $('.del').click(function(){ var id = $(this).attr("id"); alert(id); }); if put table directly in html works fine when it generated ajax doesn't generate alert (and chrome doesn't return error). nb appologise in advance if stupid misnamed id have been trying figure out 3/4 hour , stuck! edit: the ajax call is: $.ajax({type : 'post', url : 'response.php'}).done(function(response){

mysql - Appfog / Node.js - What's the best way to store data online? -

i have app online in node.js on appfog takes in user data. need store data text file , me able download later. what's best way store these files? i've tried setting mysql or mongodb database, having lot of trouble. correct approach? thanks.

sql server - Pulling a value from Xml in a column -

i have table in sql server stores xml data in 1 of columns. xml column data looks this: <testdef weight="0" failvalue="2" conceptid="-327"> <tolerancedef objecttype="somename" targetvalue="0"targetrange="2" /> </testdef> i need write query fetches out conceptid's each rows xml column. here -327 i know can cast xml column nvarchar(max) use reg exp value not sure how use regular expression here's example using table variable. same concept actual table: declare @xmltable table ( id integer identity, xmlvalue xml ) insert @xmltable (xmlvalue) values ('<testdef weight="0" failvalue="2" conceptid="-327"><tolerancedef objecttype="somename" targetvalue="0" targetrange="2" /></testdef>') insert @xmltable (xmlvalue) values ('<testdef weight="0" failvalue="2" conceptid

logging - Stack trace prints everything on one line in log file (Java) -

i have program creates log file, , outputs stack trace of exception thrown. however, stack trace printed on single line. ideas on how break up, without manually catching exception , breaking line line? or how slf4j logs text file? log file 07-25-2013 11:11:27 [loggererror] - error - [exception] java.sql.sqlexception, [stack trace] [com.***.********.******.************.<init>(************.java:195), ***.***.*******.****.***********.main(***********.java:210)] code logging loggererror.error("[exception] {}, \n[stack trace] {}", e, e.getstacktrace()); using myeclipse, logging slf4j appreciated you use java's logger . with logger, should trick: logger = logger = logger.getlogger(<yourclass>); logger.log(level.severe, <your message>, e); if want the hard way should keep in mind getstacktrace() returns array , you'll have process it.

asp.net - javascript inside Usercontrol inside updatepanel is undefined -

i'm facing little problem here : i have aspx page contains update panel has place holder (in content template) containing different usercontrols show/hide depending on conditions. one of them has long script inside initializing function has controls retrieved server tags ( <% #myctrl.clientid%>) values etc.. , thing when call function once updatepanel finishes updating, says it's undefined.. as if usercontrol script wasn't seen @ all, here aspx page "initializefees" function call when update finished: <asp:scriptmanager id="scriptmanager1" runat="server" enablepartialrendering="true" enablepagemethods="true"> <asp:updatepanel runat="server"> <contenttemplate> <script type="text/javascript"> sys.webforms.pagerequestmanager.getinstance().add_endrequest(initializefees); </script> <div class="r

php - Adding elements to a table from an input area -

i trying have image below in php page. (the links in comments. unable post them here properly) once enter keyword , hit "plus" should appear in table, along color right. sequence of colors predetermined. if enter keyword again , hit "plus" again, keyword should appear below earlier keyword int table. time being assuming table consists of 5 rows , there less or equal 5 keywords. also want have submit button @ bottom when clicked should send keywords present php file. have form action attribute set php file. table , keyword input field part of form. i prefer using javascript , not php many complications. there way can store keywords , send php file once form submitted? any appreciated. you could: build html form 5 text inputs, stacked on top of 1 (i think using position: absolute). place html table underneath inputs. place submit button underneath table. use javascript to: hide 4 text inputs aren't being used display text input , cor

linux - how to open, read, and write from serial port in C -

i little bit confused reading , writing serial port. have usb device in linux uses ftdi usb serial device converter driver. when plug in, creates: /dev/ttyusb1. i thought itd simple open , read/write in c. know baud rate , parity information, seems there no standard this? am missing something, or can point me in right direction? i wrote long time ago, , copy , paste bits needed each project. #include <errno.h> #include <fcntl.h> #include <string.h> #include <termios.h> #include <unistd.h> int set_interface_attribs (int fd, int speed, int parity) { struct termios tty; memset (&tty, 0, sizeof tty); if (tcgetattr (fd, &tty) != 0) { error_message ("error %d tcgetattr", errno); return -1; } cfsetospeed (&tty, speed); cfsetispeed (&tty, speed); tty.c_cflag = (tty.c_cflag & ~csize) | cs8; // 8-bit chars /

AngularJS iterate over $dirty elements -

i know how check if input elements on form dirty or not, wondering if there quick way iterate on $dirty ones only? know angular sets ng-dirty class on elements, , can figure out how in jquery, can't figure out how in angularjs context. i wrote filter (with community) while , has served me pretty well. /* app module */ angular.module("dirtyfilter", []). filter("returndirtyitems", function () { return function (modeltofilter, form, treatasdirty, removethesecharacters) { //removes pristine items //note: treatasdirty must array containing names of items should not removed (var key in modeltofilter) { //delete item if: // * exists on form , pristine, or... // * not exist on form try{ //console.log("checking " + key + " pristine , found " + form[key].$pristine); } catch(err){ //console.log("key " + key + " did not have el

c# - Need to run a protected method when my class is instantiated -

i have base class custom attributes, class base class many other clases class: [customattribute1("first")] [customattribute2("other")] public class foo { protected void checkattributes() { // need run code when class , derived classes instantiated } } then if créate instance foo myclass = new foo(); or build dereived class: [customattribute1("firstderived")] public custclass : foo { public custclass(int myvar) { //something here } public void othermethod() { } } custclass myclass = new custclass(5); i need method checkattributes() allways run. is posible? there aproach ? note: need shure checkattributes() runs if in derived classes constructor redefined: yes, define constructor calls method: public class foo { public foo() { checkattributes(); } protected void checkattributes() { throw new notimplementedexception(); } } as lo

oracle - Would like to know more on dba_hist_sqlstat -

i'm using tables - dba_hist_sqlstat, dba_hist_snapshot , dba_hist_sqltext stats groups of similar sql statements on entire period of time since instance start up. found same sql_id belonging 2 different snapids (snapshots). +-------+---------+---------------+-------------+---------------+--------------+--------------+ |snap_id|dbid |instance_number|sql_id |plan_hash_value|optimizer_cost|optimizer_mode| +-------+---------+---------------+-------------+---------------+--------------+--------------+ |63618 |622294766|1 |0ps2wsx1rjv8q|2871982686 |4 |all_rows | |63522 |622294766|1 |0ps2wsx1rjv8q|2871982686 |4 |all_rows | +-------+---------+---------------+-------------+---------------+--------------+--------------+ so, "group sql_id" sufficient ? should group "sql_text" ? there better way ? [update] here query i've written far - select dh_sql.sql_id, d

multithreading - java: are global variables visible in threads -

if declare global variable in main thread, suppose main thread run new thread, can new thread access global variable in main thread? "msg" string variable acces /* simple banner applet. applet creates thread scrolls message contained in msg right left across applet's window. */ import java.awt.*; import java.applet.*; /* <applet code="simplebanner" width=300 height=50> </applet> */ public class appletskel extends applet implements runnable { string msg = " simple moving banner."; //<<-----------------variable access thread t = null; int state; boolean stopflag; // set colors , initialize thread. public void init() { setbackground(color.cyan); setforeground(color.red); } // start thread public void start() { t = new thread(this); stopflag = false; t.start(); } // entry point thread runs banner. public void run() { char ch; // display banner for( ; ; ) {

c# - Insert function to insert record in SQL table working properly but Update Function to Update Record is not working properly -

these functions update student record , insert student record in sql batabase. public void updatestudent(ref student stu, string rollno) //update values corresponding roll number 'rollno' { try { connection.open(); //i have defined connection , command command = new sqlcommand("update student set firstname='"+stu.firstname+"',lastname='"+stu.lastname+"',yearofadmission="+stu.yearofadmission+",branch='"+stu.branch+"' rollno='"+rollno+"'", connection); //yearofadmission int command.executenonquery(); } catch (exception) { throw; } { if (connection != null) connection.close(); } } public void insertstudent(ref student s) { try { connection.open();

size - Android sizing on different phones -

i testing app on 3.6" screen 480 x 850 pixels. working fine , images show up. i deployed it, , got email friend saying 20% of app gets cut down bottom. using 3.7" screen 320 x 480 pixels. is there fix this? thought android stretches proportions. i using hdpi folder in app. you have use mdpi,hdpi , ldpi folder images.. android app take self resolution, use 3 of them, if want support app in device thn should use layout/large,layout/medium,layout/xlarge,layout/small. for more information refere this link for have make changes in menifest file e.g <supports-screens android:resizeable=["true"| "false"] android:smallscreens=["true" | "false"] android:normalscreens=["true" | "false"] android:largescreens=["true" | "false"] android:xlargescreens=["true" | "false"]

sorting - Group Perl object by child nodes -

i have object in format shown below, , need group them available months. 1000, 2000, ect. amounts in dollars, , next level (6, 4) months. my object: $var1 = { '1000' => { '6' => { 'apr' => '13.9' }, '4' => { 'apr' => '11.9' } }, '2000' => { '6' => { 'apr' => '13.9' }, '4' => { 'apr' => '11.9' } }, '4000' => { '6' => { 'apr' => '13.9'

c# - Can I insert a large text value into SQL Server from ASP.net without having the whole file in memory on the webserver? -

as says in question, given large text file, how can contents nvarchar(max) column in sql server without loading entire file contents memory (either build dynamic sql statement or sp parameter)? my best solution far insert row empty value , in loop run updates appending chunks of data each time in transaction. there better way other copying file database server , using bcp? way stream data over? as of .net4.5 sqlparameters support textreader https://msdn.microsoft.com/en-us/library/hh556234(v=vs.110).aspx using (sqlconnection conn = new sqlconnection(connection_string)) using (sqlcommand cmd = conn.createcommand()) using (filestream file = file.openread(@"c:\temp\bigtextfile.txt")) { cmd.commandtext = "insert randomtable (textblob) values (@text)"; cmd.parameters.add("@text", system.data.sqldbtype.nvarchar, -1).value = file; conn.open(); cmd.executenonquery(); }

how can I remove empty directories in git-svn? -

i have specific problem did not found solution here or anywhere else. have svn repository , using git-svn access , work on it. some time ago, there empty directories in svn repository (empty, subfolders). git not track those. deleted them svn repository. still have them after running git svn rebase and when delete them hand, recreated during next git svn rebase how can rid of them? i checked using pure svn , not in repository. it bit rough, have found following solves problem: rm .git/svn/refs/remotes/trunk/unhandled.log git clean -df any subsequent git svn rebase will not recreate anything. since don't know how regenerate file without re-cloning repo, suggest making backup of first. text file, suppose edit content remove entries end creating

regex - MySQL REGEXP query -

i'm trying select rows in table database has following structure: <tr> <td> <p><strong>completion date:</strong></p> </td> <td> <p>april, 2012</p> </td> </tr> but month , year different. here current query statement: select * `posts` `content` regexp "<tr>\r\n<td>\r\n<p><strong>completion date:</strong></p>\r\n</td>\r\n<td>\r\n<p>april, 2012</p>\r\n</td>\r\n</tr>" currently pull rows have april, 2012 expect pull. tried replacing month with: ^[a-za-z]$ did not work nor other combination tired. could correct regular expression? thanks, -m this should give results looking for. note how need star, means 0 or more [a-za-z] , , 0 or more [0-9] characters. select * `posts` `content` regexp "<tr>\r\n<td>\r\n<p><strong>completion date:</strong></p>\r\n</td>\r\n&