Posts

Showing posts from March, 2010

SQL Server stored procedure - C# PK - FK -

quite new sql server , discovered wonderful world of stored procedures - , gives me headache. came here help. scenario 1 : given table, wrote stored procedure , call in c# populate table. works expected. country sql table looks this stored procedure: create procedure [dbo].[insertrecord2] @countryname nvarchar(64), insert country(countryname) values (@countryname) return calling in c# private void button1_click(object sender, eventargs e) { readonly sqlconnection _connection = new sqlconnection(@"data source=rexgbasqlp042;initial catalog=isg_cid;integrated security=true"); _connection.open(); sqlcommand _command = _connection.createcommand(); _command.commandtype = commandtype.storedprocedure; _command.commandtext = "insertrecord2"; _command.parameters.add("@countryname", sqldbtype.nvarchar).value = countryname.text; _command.executenonquery(); _connection.close(); } scenario 2 : want

arrays - Position compression using relative coordinates in Javascript -

goodafternoon. have set of coordinates [ [ 52.52132, 4.52342 ], [ 52.52144, 4.52352 ], [ 52.52154, 4.52354 ], [ 52.52166, 4.52376 ] ] how can transform first position (the first 2 coordinates) become base. , following positions relative distances base? so, pseudo example: this [ [ 52.52132, 4.52342 ], [ 52.52144, 4.52352 ], [ 52.52154, 4.52354 ], [ 52.52166, 4.52376 ] ] would become this: [ [ 52.52132, 4.52342 ], [ 0.4123, 0.1232 ], [ 0.1232, 0.5523 ], [ 0.1233, 0.1232 ] ] where first part [ 52.52132, 4.52342 ] starting point. , other coordinates relative previous one. is after.. i'm not sure how getting 0.4123, 0.1232, 52.52144 - 52.52132 = 0.00012 also if after simple latlng compression / decompression system. i've done little 1 here, it's simple compressor,.. after works out different. multiple loops of multiplying diffs 1 10 100 1000, etc. , keeps track of return smallest stringified result. in store multiplier first element. eg. exa

Visual Studio + Git: Changing code in Branch#1 changes it in Branch#2 -

we changed tfs git 1 month ago , of new pcs have weird issue: if change code in branch#1 , switch branch #2, don't "uncommitted changes" notification. instead switches branch#2 , have code branch#1 in branch#2 (and branch#3/4/5...). that'sreally irritating. how can fix this? update: we/they switch/commit/pull etc. directly through visual studio ui. example if switch 1 branch another, open little dropdown below solution explorer , select branch want.

java - Spring boot Hibernate Teradata Unable to determine Dialect to use -

application.properties : spring.jpa.database-platform=org.hibernate.dialect.teradatadialect data source bean : @bean public datasource datasource() { return datasourcebuilder .create() .driverclassname("com.teradata.jdbc.teradriver") .username("dbc") .password("dbc") .url("jdbc:teradata://name/dbc") .build(); } but getting error : caused by: org.hibernate.hibernateexception: access dialectresolutioninfo cannot null when 'hibernate.dialect' not set try removing datasource bean java config , let spring-boot initilize datasource providing more properties in apllication.properties: #datasource configuration spring.datasource.driverclassname=com.teradata.jdbc.teradriver spring.datasource.url=jdbc:teradata://name/dbc spring.datasource.username=dbc spring.datasource.password=dbc #jpa/hibernate spring.jpa.database-platform=org.hibernate.dialect.teradatadialect

html - Box not vertically aligned with I add a navigation bar on top -

Image
upd : take @ snippe below please i trying create homepage navigation bar on top , box in center of homepage screen. took idea template. my problem cannot make box in center. the original script inspired me : * { margin: 0; padding: 0; } #wrapper { position: absolute; width: 100%; height: 100%; overflow: hidden; } .label { cursor: pointer; &:focus outline: none; } .menu{ position: absolute; top: 0; left: 0; background: #fff; width: 240px; height: 100%; transform: translate3d(-240px, 0, 0); transition: transform 0.35s; } .menu-toggle { position: absolute ; right: -60px; width: 60px; height: 60px; line-height: 0px ; display: block; padding: 0; text-indent: -9999px; background: #fff url(https://cdn4.iconfinder.com/data/icons/wirecons-free-vector-icons/32/menu-alt-512.png) 50% 50% / 25px 25px no-repeat } ul li > .label

gcc - Is C compiler able to optimize across object file? -

i'm considering between header-only vs. header&source design. i'm not sure if header&source allows compiler optimize across object files , across linkage ? such inlining optimization ? header files , source files typically compiled single translation unit (since headers included in source files). so, won't issue (unless have peculiar environment headers compiled separately). gcc support optimizations across different translation units. see link time optimization . see -flto option's documentation details: -flto[=n] this option runs standard link-time optimizer. when invoked source code, generates gimple (one of gcc's internal representations) , writes special elf sections in object file. when object files linked together, function bodies read these elf sections , instantiated if had been part of same translation unit. use link-time optimizer, -flto , optimization options should specified @ compile time , during fin

javascript - epoch time to human readable from SQL output. HTML -

i have query gets date database problem using epoch/unix time. working on easy website outputting creating date (dateadd in sql). query: select takeover realest id=objid dato ... i have in html: <tr class="tr{row}" valign="center"> <td class="td" align="left" nowrap>{'dato(do.dato).tostring("%d.%m.%y");'}</td> but doesnt work. how can fix that?

class - Instance Variables in Javascript Classes -

i code in php , java, work on front end of project , use javascript. create objects differently below, came across , caught interest being syntax similar program in. i poking around, trying figure out how use instance variables in javascript classes using syntax below. i've tried declaring instance variables name; , or _name; , or var name; , or of previous variables , adding = null; , still errors in console. errors my-file.js:2 uncaught syntaxerror: unexpected identifier . i'm trying set instance variable through constructor. how use instance variables in javascript, using syntax below? class myclass { var _name; constructor(name) { _name = name; alert("hello world, oo js!"); this.myfunction(); } myfunction() { document.getelementbyid("myelement").addeventlistener("click", function() { console.log("ant's function runs. hello!"); }); } } window.onload = function() { var person = &q

sql - Update and Select MYSQL, Convert Unixtime to timestamp -

got minor issue, im working on old old database layout did not self. the 1 hu created used unix timestamps everything, want converte in normal mysql timestamp, know can from_unixtimestam function. but need crap unix timestamp column called last_login , converte timestamp , save value last_login_sql how heck this? table name: kunstner column name of unix timestamp: last_login column name of timestamp: last_login_sql there id column ofc. hope can me out here. as saving new value, should work: update kunstner set last_login_sql = unix_timestamp(last_login)

javascript - How to fix JQuery DataTables mData error on table with html -

i used following html table paginate using jquery datatables <table class="table table-responsive datatable" id="products-table"> <thead> <tr><th>image</th> <th>code</th> <th>weight</th> <th>jarti</th> <th>wages</th> <th>amount</th> <th class="no-sort">status</th> <th colspan="3" class="no-sort">action</th> </tr></thead> <tbody> <tr> <td> <img src="/images/designs/4.jpg" style="width:120px;" class="img img-responsive" alt="gold ring"> </td> <td>rrs</td> <td>0.00000</td> <td>0.00000</td> <td>0.00000</td> &l

java - @jsonproperty serialize different pojo elements in the same attribute name -

i have simple pojo public class c { public string f1; public integer f2; } at runtime sure @ 1 of fields not null (i.e. if f1 "hello" , i'm sure f2 null , , vice versa) i serialize object using same name; example, with c c1 = new c(); c1.f1 = "hello" c c2 = new c(); c2.f2 = integer.valueof(99) i have c1 serialized {"samekey":"hello"} , c2 {"samekey":99} . i know can use @jsonproperty set serialized name, cannot set same name both fields. is there way that? here customserializer, checks if f2 value not null f2 value copied f1 , making f2=null.and excluding nulls in model 1 key&value other 1 null. public class customserializer extends jsonserializer<c> { @override public void serialize(final c c, final jsongenerator gen, final serializerprovider serializers) throws ioexception, jsonprocessingexception { if(c.getf2() != null) // considering need f1 key && value {

c# - Task that ReadsKey from keyboard doesnt work - Consumer/Producer Pattern -

i implementing single producer/consumer pattern using blockingcollection. when click 'c' keyboard want cancel operation using cancellationtoken. the strange thing if press 'c' fast can after run program, program listen event. if click 'c' later lets @ 45000th iteration program doesnt react. i have loop populates producer. (int = 0; < 50000; i++) { logger.addtoqueue("number flush " + i, true); } logger.dataitems.completeadding(); at constructor of logger call method: private task t; public void keypress() { t = task.run(() => { if (console.readkey(true).keychar == 'c') { cts.cancel(); } }); } i dont know if error relevant other methods post them in case: the addtoqueue (producer): public void addtoqueue(string text, bool isflushon) { consumer

excel - VBA; Multiple footer and header allignment, How can I allgine left Center and right footer? -

i know there codes like: activedocument.sections(i).footers(wdheaderfooterprimary).range .text = myfootervalue1 .paragraphformat.alignment = wdalignpagenumberleft .font.size = 10 'size 10 font end but want add, left (company name) right (date) , middle page number. you can tabstops. you need work out width of page (minus margins), add center , right tabstop , separate values tabs. sub insertfooters() dim pagewidth double, section section each section in activedocument.sections section.pagesetup pagewidth = (.pagewidth) - .leftmargin - .rightmargin end section.footers(wdheaderfooterprimary).range .text = "left" & vbtab & "center" & vbtab & "right" .paragraphformat .tabstops.clearall .tabstops.add pagewidth / 2, alignment:=wdalignmenttabalignment.wdcenter .tabstops.add pagewidth, alignment:=wda

gtk - playing a video by retrieving and manipulating frame by frame: is creating a new pixbuf at every frame the way to go or is there an easier way? -

using python3, gtk3. working on computer vision application needs manipulate , display (playback) frames video. currently, create new pixbuf static method new_from_data , fed sequence of bytes created numpy array contained manipulated frame, , having performance problems, such not being able play video @ 20fps. i wonder: way go kind of problem? creating new pixbuf every frame relatively cheap or expensive? should use other methods, such using new_from_stream ? (not familiar it) this not "easier" way, if you're having performance issues, should try using clutter via clutter-gtk use hardware acceleration draw frames. you can create gtkclutterembed widget, give clutterstage clutteractor. everytime have new frame, can create new clutterimage , clutter_image_set_data() (which new_from_data pixbuf) , set cluttercontent of clutteractor (eg: clutterstage) new clutterimage. this how gnome-ring plays video, can take @ source code here inspiration.

Reusing JQuery Plugins /CSS in wordpress project -

i've 3rd party jquery plugins need reuse across wordpress plugins on website project. better practice put these jquery plugins inside common folder (say inside wp-content) instead of putting them inside wordpress plugin , referencing ? i.e. instead of wp_enqueue_scripts('script_id', plugins_url() . '/plugin-abc/bootstrap-tagsinput.js', array('jquery'), $plugin_version, 'all'); ^^ above apprroach creates dependencies between plugins i.e. install plugin-xyz needs bootstrap-tagsinput.js, need have plugin-abc installed first or atleast in plugins directory. i can instead reference folder common-assets directly under wp-content wp_enqueue_scripts('script_id', content_url() . '/common-assets/bootstrap-tagsinput.js', array('jquery'), $plugin_version, 'all'); always use plugin directory, way packed together.

objective c - What are the differences between [[NSMutableArray alloc] init] and [@[] mutableCopy]? -

nsmutablearray *myarray = [[nsmutablearray alloc] init]; vs nsmutablearray *myarray = [@[] mutablecopy] what differences between declaring arrays in these 2 separate ways? think of 2nd line as: nsmutablearray *myarray = [[[nsarray alloc] init] mutablecopy]; so clear difference 1st way more efficient , 2nd way needlessly creates object promptly discarded.

javascript - Replace HTML between two tags -

what want replace in between 2 html tags. i'm using reference i'm still encountering problems: reference this i've tried: el.getvalue().replace(/<form.+<\/form>/, "<div></div>"); i need replace form tags dynamically. if use jquery, retrieve parent element of you'd replaced, , replace content .html() function. ex: var formparentelement = $('#formparentelement'); formparentelement.html("<div>my new content</div>"); if don't use jquery: var formparentelement = document.getelementbyid("formparentelement"); formparentelement.innerhtml = "<div>my new content</div>"; the example assumes parent element of form has id value "formparentelement".

angular ui - uib-datepicker-popup clipped by a fixed div -

i have page header uses position: fixed , , multiple uib-datepicker-popup inputs (from angular ui boostrap ) on page below, end underneath header whenever overlap. i can see directive uib-datepicker-popup uses position: absolute , , seems way can show above header moving entire calendar element body parent. is there standard way of solving problem? i've tried various z-index manipulations, no avail.

Storing file in Cassandra database -

because of situation end up, decided keep files cassandra database . don't feel confidence , i'm not pretty sure idea store files in database instead of keeping them standard file system. we need have massive file storage can expand time, have well-structured cassandra cloud , furthermore, our files chunked in small sizes , ready saving blob column of tables. we took @ current distributed file systems such ceph , beefs , lustre , others , found out that's task need separate infrastructure , admin guy maintain them, in way around, tried trivial approaches such nfs came inconsistency , reliability issues showed kinda approaches not scalable enough looking for. so conclusion, decided keep files in our current cassandra cloud having data model explained here . need know downsides of approach?

python - Drop row in dataframe based on condition in column -

i have dataframe looks follows class number 2015 0 0 0 ret real estate 1 0 ret empty 2 0 ret equity 3 0 ret participations 4 0 ret empty 5 0 ret private equity 6 0 ret hedge fund 7 0 ret high yield 8 0 ret loan, multitranchen, fsb, fss_fsb 9 0 ret empty 10 0 ret loan gr, fsb 11 0 ret

linux - Unexpected behavior with "set -o errexit" on AIX -

this script shell works fine on gnu/linux not on aix 5.3 #!/bin/sh echo $shell set -o nounset -o errexit [ 1 -eq 1 ] && { echo "zzz" } && echo "aaa" && [ 1 -eq 0 ] && echo "bbb" echo "ccc" on gnu/linux, i've got expected output : /bin/bash zzz aaa ccc on aix, i've got 1 : /bin/ksh zzz aaa without "set -o nounset -o errexit" works fine... don't understant why. explain me wrong in script shell. thanks, rémy edit 18 nov. : precision set -e when option on, if simple command fails of reasons listed in consequences of shell errors or returns exit status value >0, , not part of compound list following while, until, or if keyword, , not part of , or or list, , not pipeline preceded ! reserved word, shell shall exit. http://explainshell.com/explain?cmd=set+-e in example, second test "[ 1 -eq 0 ]" part of and, should see output

xml - Using dynamic href in XSLT import/include? -

the <xsl:import> , <xsl:include> elements seem behave quite specific. trying do: <xsl:import href="{$base}/themes/{/settings/active_theme}/styles.xsl" /> i want allow loading different themes application. have settings in app stores "currently active theme" folder name in xml node. unfortunately code above won't work. know workaround achieve want do? edit: confirmed xslt guru via twitter... there's no nice way of doing this. easiest solution in case seperate frontend , backend stylesheets , load them individually xsltprocessor... xsl:import assembles stylesheet prior execution. stylesheet can't modify while executing, trying achieve. if have 3 variants of stylesheet use in different circumstances, represented 3 modules a.xsl, b.xsl, , c.xsl, instead of trying import 1 of these module common.xsl contains common code, need invert structure: each of a.xsl, b.xsl, , c.xsl should import common.xsl, , should select a.xs

java - Interval continue working after onErrorResumeNext -

i´m using interval operator, , want continue emitting items if exception happens on pipeline. so try use onerrorresumenext emitting item in case of exception. seen after emitt item, interval stop emitting more items. here unit test. @test public void testintervalobservablewitherror() { subscription subscription = observable.interval(50, timeunit.milliseconds) .map(time -> "item\n") .map(item -> item = null) .map(string::tostring) .onerrorresumenext(t-> observable.just("item error emitted")) .subscribe(system.out::print, t->{ system.out.println(t); } ); testsubscriber testsubscriber = new testsubscriber((observer) subscription); testsubscriber.awaitterminalevent(20000, timeunit.milliseconds); } i´m confuse behaviour, why observable unsubscribe if it´s receiving item onerrorresumenext solution: after explan

ios - How to modify programmatically constraints of UIButton -

i have 2 buttons different constraints write in storyboard. in code, have tell first button take same constraint of second button (height, width, and position ) not know how without passing "subview". have 2 outlets buttons. @iboutlet weak var likesbutton: uibutton! @iboutlet weak var sharebutton: uibutton! my interface build : - view a)...view b)...view c) contentview 1)likebutton 2)sharebutton 3)... d)... i tried : self.contentview.translatesautoresizingmaskintoconstraints = false self.sharebutton.removeconstraints(self.sharebutton.constraints) // old constraints self.sharebutton.addconstraints(self.likebutton.constraints) // new constraints self.sharebutton.updateconstraintsifneeded() self.sharebutton.layoutifneeded() and after have error : *** terminating app due uncaught exception 'nsgenericexception', reason: 'unable install constraint on view. cons

wordpress - Javascript Share Bar URL Modification Issues -

i'm having hard time getting share bar on left hand side of following page work properly: https://www.tisaneteas.com/blog/understanding-how-the-ph-scale-works/ there's js file called social-share-kit-post.js has following code: function geturl(options, network, el) { var url, dataopts = getdataopts(options, network, el), shareurl = getshareurl(options, network, el, dataopts), title = typeof dataopts['title'] !== 'undefined' ? dataopts['title'] : gettitle(network), text = typeof dataopts['text'] !== 'undefined' ? dataopts['text'] : gettext(network), image = dataopts['image'] ? dataopts['image'] : getmetacontent('og:image'), via = typeof dataopts['via'] !== 'undefined' ? dataopts['via'] : getmetacontent('twitter:site'), paramsobj = { shareurl: shareurl, title: title, text: text,

python - How to introspect win32com wrapper? -

i have device, records spectroscopic data , controlled 3rd-party application. automization purposes, want use com interface of application retrieve data in python. since there no proper documentation using api python, collected following code different web sources, obtains first frame: comtypes.client.getmodule(('{1a762221-d8ba-11cf-afc2-508201c10000}', 3, 11)) import comtypes.gen.winx32lib winspeclib win32com.client.pythoncom.coinitialize() doc = win32com.client.dispatch("winx32.docfile") buffer = ctypes.c_float() frame = 1 spectrum = doc.getframe(frame, buffer) however, call getframe inconsistent definition in visual basic, provided manufacturer: sub getframe(frame integer, buffer variant) getframe copies data document visual basic array. if buffer empty variant, getframe creates array of proper size , data type , sets buffer point before copying data. this means in visual basic variable buffer filled data while function getframe has no r

C++ LinkList and Node Template Linking Errors -

i trying create node template use linked list template getting error constructors in node.h not defined. have node.h file , node.tem file created in visual studio. node.h file looks this: #ifndef node_h #define node_h #include <cstdlib> template <class type> class node { public: node(); node(type indata); type data; node<type>* next; node<type>* prev; }; #include "node.tem" #endif and node.tem file looks this: template <class type> node<type>::node() { next = nullptr; } template <class type> node<type>::node(type indata) { data = indata; next = nullptr; } after debugging, looks problem occurs in alloc function in linked list template on bit of code: template <class type> node<type>* linklist<type>::alloc(type indata) { node<type>* dynamicnode = new node(indata); //error occurs here return dynamicnode; } the errors are: 'node': class ha

python - Converting an if/else block with True/False statements into a dictionary -

i iterating through characters in string, , want determine type of each character. this can done if/else block: if char.isdigit(): char_type = 'number' elif char.isalpha(): char_type = 'letter' elif char in {'*', '/', '+', '-', '='}: char_type = 'operator' else: char_type = 'other' if code this: if val == 1: char_type = 'number' elif val == 2: char_type = 'letter' elif val == 3: char_type = 'operator' the dictionary be: d = {1: 'number', 2: 'letter', 3: 'operator'} but in case, each of statements either true or false . can converted dictionary? yes, can use d[char] syntax, hardly sees worth cost in complexity , readability. you encapsulate if/else in __getitem__ method of class, , use [] syntax retrieve character type, so: class chartype: def __g

javascript - Highlighting Exact Text Match -

i have following java userscript: function highlightword(word) { var xpath = "//text()[contains(., '" + word + "')]"; var texts = document.evaluate(xpath, document.body, null, xpathresult.unordered_node_snapshot_type, null); (n = 0; n < texts.snapshotlength; n++) { var textnode = texts.snapshotitem(n); var p = textnode.parentnode; var = []; var frag = document.createdocumentfragment(); textnode.nodevalue.split(word).foreach(function(text, i) { var node; if (i) { node = document.createelement('span'); node.style.backgroundcolor = 'lightgreen'; node.appendchild(document.createtextnode(word)); frag.appendchild(node); } if (text.length) { frag.appendchild(document.createtextnode(text)); } return a; }); p.replacechild(frag, textnode); } } highlightword('office'); would able me finding soluti

authentication - Express - Authenticating URI endpoints using facebook & Google -

i've got uri endpoint authentication working both facebook & google in express app through separate middlewares. facebook uses passport facebook-token strategy, whereas google wrote own middleware using nodejs client lib google api. want authenticate user on uri endpoint using both these middleware. /* //google controller file module.exports = function(req,res,next){ } */ googlectrl = require('google controller file'); //this works fine app.get('someurl',googlectrl,function(req,res){ //google user authenticated } //this works fine app.get('someurl',passport.authenticate('facebook-token',{session=false}),function(req,res){ //google user authenticated } but how combine 2 same uri. otherwise need use seperate uri google & fb. pls advice. pls note i've tried implementing google strategy , has not worked. you can use 1 array field user object named providers shown below: { "name": "asdasd", "pr

azure active directory - Office 365 API to detect when office app is launched -

i'm trying figure out if there way detect when user launches 1 of office apps (word, excel, powerpoint, onenote, onedrive, etc) can add logic perform tasks if it's first time user has launched particular office app. i hoping microsoft graph api me this, can't find guidance on how this. there way either notifications or polling/querying api? the closest thing you're asking azure ad reporting api sign-in activity : https://docs.microsoft.com/en-us/azure/active-directory/active-directory-reporting-api-sign-in-activity-reference note that, @ time, available in azure ad graph, not microsoft graph . https://graph.windows.net/contoso.com/activities/signinevents?api-version=beta you can filter user and/or appdisplayname . https://graph.windows.net/contoso.com/activities/signinevents?api-version=beta&$filter=appdisplayname eq 'office 365' doing quick testing launching office portal, outlook, sharepoint, etc, saw following entries: office

r - Writing a loop to extract Comtrade data and export them into multiple csv files -

i writing loop extract un comtrade export data each country (say country i) , export them individual csv files country later use. used "get.comtrade" function (written stefan a.) starting point , looped through each unique 3-digit country code in comtrade data. plus, interested in obtaining "commodity" "export" data (from country other countries) , have no use other information contained in "list" extracted using get.comtrade function, extract "year", "reporter", "partner", , "trade value" data each country , assemble them csv table. to illustrate example, begin usa (country code=842) in year 2006, wrote d <- get.comtrade(r="842", p="all", ps="2006", type="c", rg="2", freq="a") which gives me "list" --> d contains 2 items "validation" , "data" in latter (data) contains 35 variables , data frame of inter

python - Write a program that can read the file and display the number of students travelling by each mode of transport -

here scenario file “travel.txt” stores data students follows: first name, surname, programme, means of transport. sample data is: john farmer bsccse bus kevin khan bscmcs taxi janet zuber bscmis bus san jacky bscais privatecar sarah forceps bscis privatecar i want read file , display number of students traveling each mode of transport in such form: taxi 1 bus 2 privatecar 2 i've written following code: f1=open("travel.txt",'r') line=f1.readline() count1=0 count2=0 count3=0 while line!=" ": data=line.split() if data[3]=="bus": count1=count1+1 elif data[3]=="taxi": count2=count2+1 else: count3=count3+1 line=f1.readline() print("taxi","\t",count1) print("bus","\t",count2) print("private car","\t",count3) f1.close() but not working me even though might have an

c# - Serializing object at specific byte index -

in vs2015 , serialize data table file, beginning @ byte 16 , since file encrypted , iv uses bytes 0-15 . have not yet found serialization method taking offset parameter, should convert table byte array? there must cleaner approach. here 1 of functions: internal static void encryptdata(datatable dtable, string username, string password, string filename) { using (filestream fs = new filestream(filename, filemode.openorcreate, fileaccess.write, fileshare.none)) { using (aes aes = setaes(username, password)) // performs aes initialization { fs.write(aes.iv, 0, 16); // writing iv using (cryptostream cs = new cryptostream(fs, aes.createencryptor(), cryptostreammode.write)) { dtable.writexml(cs, xmlwritemode.writeschema); // overwriting bytes 0-15 :( } } } } edit: adding deserialization function, throws exception "length of data decrypt invalid" internal static void decryptd

python - How to append JSON objects to a list? -

i'm trying append json objects form list of json objects. def genindentifier(options): data=json.dumps([identifier,hex_dig]) return data the data here valid json object follows: ["27780741708467800000001", "e5073922dbb7a278769d52277d49c6ad3017b1ba"] afterwards, loop through genidentifier function generate many json objects: data=[] in range(0,2,1): ... data.append(genindentifier(options)) print data now list of json data not valid json format because of single quotations marks pop up: ['["27780741708467800000000", "f798d2cd9aec1b98fb48b34fd249fe19c06a4a1d"]', '["27780741708467800000001", "e5073922dbb7a278769d52277d49c6ad3017b1ba"]'] any idea how solve that? i've searched , googled in vain. the trouble dumping data json inside genindentifier, appending json string list. instead should move json conversion out of function, , @ end: def genindentifie

Android Studio - Logcat - "Show only selected application" -

i'm trying use logcat in android studio 2.2.2 in debugging logcat runs firehose , and there's content see. in android monitor when logcat tab selected there's dropdown 1 of choices " show selected application " selected didn't seem have effect. logcat runs firehose when i'm disconnected debug target. " show selected application " , how can tell "selected application" is? you should enable adb integration (it's disabled default now): tools->android->enable adb integration. then you'll able see debuggable processes in dropdown on left.

python - "Least Astonishment" and the Mutable Default Argument -

anyone tinkering python long enough has been bitten (or torn pieces) following issue: def foo(a=[]): a.append(5) return python novices expect function return list 1 element: [5] . result instead different, , astonishing (for novice): >>> foo() [5] >>> foo() [5, 5] >>> foo() [5, 5, 5] >>> foo() [5, 5, 5, 5] >>> foo() a manager of mine once had first encounter feature, , called "a dramatic design flaw" of language. replied behavior had underlying explanation, , indeed puzzling , unexpected if don't understand internals. however, not able answer (to myself) following question: reason binding default argument @ function definition, , not @ function execution? doubt experienced behavior has practical use (who used static variables in c, without breeding bugs?) edit : baczek made interesting example. of comments , utaal's in particular, elaborated further: >>> def a(): ... print("a exec

r - Preserve markdown in chunked file for knitr -

i have r script called rundataanalysis.r , in have call long analysis file actualanalysis.r . i want generate report knitr (i'm not using rstudio). so followed good advice , did following: i have ## @knitr runmostanalyses @ top of long analysis file. i have these lines in rundataanalysis.r file: --- output: html_document: toc: true --- ```{r echo=false} read_chunk('pathtofile/actualanalysis.r') ``` ```{r first} <<runmostanalyses>> ``` finally, run , report calling rmarkdown::render('rundataanalysis.r') . works part doesn't preserve markdown indicated in sourced file (at least not in same format works rmarkdown). example, have different title levels #' # , #' ## , #' ### . gets copied verbatim in report file , not interpreted titles (and included in table of contents). couldn't find relevant option in chunk options . is syntax different or doing wrong when evaluating chunk? if import rmd rmd f

c# - How to make Telerik's RadHtmlChart legend to be displayed in two columns -

i working on asp.net webforms project. using telerik's radhtmlchart control. display legend in 2 columns. displayed single column. tried make height of small 2 or more columns. didn't work. radhtmlchart2.legend.appearance.height.equals(20); thanks the main purpose of radhtmlchart's legend show information connected displayed data, there no property allows populating custom legend items. the namefield property specific pieseries, donutseries , bubbleseries, can achieve same appearance in barseries , columnseries setting name property: <telerik:columnseries datafieldy="yvalue" name="column series"></telerik:columnseries> specifying name property series creates "item" in legend. note property used setting series' names explicitly , namefield property equivalent in databind scenario. i attach sample page have databound columnseries , set name property, can check suggestions. <%@ page language="c#&q

Easy ROT13 Ruby "programme" mystery -

i made simple rot13 programme , don't understand 1 thing: a = 'abcdefghijklmnopqrstuvwxyz' (a.length+1).times |i| print a[i + 13] if i>13 print a[i %14] end end outputs: nopqrstuvwxyzabcdefghijklm if don't add +1 after a.length , iteration ends letter l . however, if use print a[i] inside iteration, starts a , ends z no +1 addition needed. can explain mystery me? as may know, .times loop invokes block specified number of times, passing each iteration incremented value. if 26.times {|i| puts i} print values 0 25. to, not including last value. now let's walk through loop. @ first iteration, i 0. print 14th character of string, "n" (at index 13, zero-based). don't go condition because 0 not greater 13. on second iteration print 15th character, "o" . , keep doing this, until reach i=14 . at point, "magic" begins. first, attempt print 27th character of string. there's no such char

mysql - Cloud SQL second generation - Unable to create failover -

i've created failover replica using cloud sql second generation, had delete , create 1 after few hours, prompts following message: "there instance name." i using same name of failover deleted earlier, changed name error occured: "could not complete operation." now after deleting first failover i'm unable create 1 using same database... anyone got ideas on this? thanks! this behavior indeed expected: 1 may reuse instance name, not right away. instance name unavailable week before can reused . however, 1 cannot replicate second try: creating failover different name. here, procedure work , differently named failover database created successfully. more detail on gcloud commands or gui menus steps followed might bring light on matter.

java - I am writing a program for a class that involves inputting and keeping track of totals and sub totals for each individual person in a restaurant -

package restaurantmenu; import java.util.scanner; public class restaurantmenu { public static void main(string[] args) { scanner input = new scanner(system.in); string[] itemname = { " ", "soup", "wings", "burger", "chicken sandwich", "fries", "pie", "ice cream", "soft drink", "coffee" }; double[] itemprice = { 0, 2.50, .15, 4.95, 5.95, 1.99, 2.95, 2.99, 1.50, 1.00 }; double grandtotal = 0; double total = 0; system.out.println("how many people in party? "); int partynumber = input.nextint(); (int = 0; < partynumber; i++) { system.out.println("discount type:"); system.out.println("--------------"); system.out.println("1: child"); system.out.println("2. teen"); system.out.println(&quo