Posts

Showing posts from May, 2014

c# - Remove Insignificant Whitespace From Xml Document -

i've got xml file contains both significant , insignificant whitespace. read file in , write file out disk, removing insignificant whitespace. when considering significant vs insignificant whitespace, want make sure spaces within mixed content elements (as defined schema) maintained. how can using c#? based on this article read, sounded might need use validating xml reader reader know elements contain mixed content per schema. below 1 example of code tried did not maintain significant whitespace between elements within parent element containing mixed content. xmldocument doc = new xmldocument(); doc.preservewhitespace = true; using (xmltextreader rdr = new xmltextreader(xmlfilepath1)) { rdr.whitespacehandling = whitespacehandling.significant; xmlschemaset sc = new xmlschemaset(); sc.add(null, @"c:\my-schema.xsd"); doc.load(xmlreader.create(rdr, new xmlreadersettings() { validationtype = system.xml.validationtype.schema, schemas = sc })); using

c++ - Function call is giving me the error expression must have class type -

i have made function call in simple terms, displays content of list have values for. here function definition: void display_list(list<string>*type_list) { cout << "you made function call" << endl; (list<string>::iterator dis = type_list.begin(); dis != type_list.end(); ++dis) { cout << *dis; cout << "\n"; } } all supposed make easier on me, because there numerous times throughout code have display contents of list, tried make easier on myself , make function call have make function call: display_list(&list_name_here); although works fine, can see added test 'cout' make sure function call works correctly, doesn't display contents, , error highlights the type_list and error pops says expression must have class type? now did change code this: void display_list(list<string>*type_list) { cout << "you made function call" << endl; l

javascript - jQuery Scrolling Length -

i working script scroll element on click. it's working properly, either scrolls way up, or way down. i'm new jquery, , i'm wondering how make scroll little @ at time. example, clicking scroll down once take down length, clicking again scrolls length again. also, jitters , bugs out when scrolling up. insight on how fix appreciated well! thanks. code below: <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script> <script> $(function() { var ele = $('#scroll'); var speed = 25, scroll = 5, scrolling; $('#scroll-up').click(function() { // scroll element scrolling = window.setinterval(function() { ele.scrolltop( ele.scrolltop() - scroll ); }, speed); }); $('#scroll-down').click(function() { // scroll element down scrolling = window.setinterval(function() { ele.scrolltop( ele.scrolltop() + sc

osx - Mac Audio Cuts Out Randomly - thoughts? -

recently, several colleagues , have noticed issue our macs - audio cut out @ random , cannot attained unless user restarts computer. google-fu shows issue apparent when audio played chrome long time of time or flash. google chrome has been culprit in our case. below specs: mac os x 10.92 typically happens in day while chrome playing audio audio can go out if user not restart computer i have gone system preferences , attempted change outputs toggle headphones , builtin speakers - result = fail. anybody have experience resolving issue? thanks, this issue seems have been resolved in latest version of mavericks. since installing 10.9.4, have not had issues.

c# - How do i get a specific process name memory usage? -

i tried code: public static string getprocessmemoryusage(string processname) { while (true) { performancecounter performancecounter = new performancecounter(); performancecounter.categoryname = "process"; performancecounter.countername = "working set"; performancecounter.instancename = process.getcurrentprocess().processname; processname = ((uint)performancecounter.nextvalue() / 1024).tostring(processname); return processname; } } if process name example: bfbc2game method getprocessmemoryusage return me name: bfbc2game want return me memory usage value number in task manager in windows example when run task manager see on bfbc2game: 78% , 198.5mb memory usage. thats want in returned string processname: 78% , 198.5mb that. , iwll update time in loop. same in task manager. use var workingset = (uint)p

google app engine - Python 2.7 and blobkeys: how to return the filename instead of the url? -

very new python/google app engine , trying work way around pretty massive application. have: file_keys = self.request.get_all('blobkey').filename file_links = [] key in file_keys: file_links.append('https://www.mysite.com/admin/downloads/%s' % key) this return similar this: https://www.mysite.com/admin/downloads/4nlnpxrzz0vjozcopzzpiqvoasesxlzukbq0amyflmgydhnzrwarasbxl8tc6gjw how go returning file name? (it's form enter information , provide file, , return specific file's filename in email sent out instead of generated url). i think filename work shown here: https://developers.google.com/appengine/docs/python/blobstore/blobinfoclass but have not had luck that. any input appreciated. this solution came with: file_keys = self.request.get_all('blobkey') blob_info_list = blobstore.blobinfo.get(file_keys) file_info_list = [] blob in blob_info_list: info = {"file_name":blob.filename, "key"

ruby on rails - How to notify an API user once a process has been finished? -

i have api users can create, call, orders. i enqueue orders , process them via sidekiq gem. when process done, send email user. however, looking on how notify him programatically. so, sending user post request particular endpoint, telling him order has been processed. i wondering kind of security or other technical things should take account when doing this, or if there kind of gem me on developing this. you can check pub/sub pattern this... when sidekiq finish processing publish event... , register browser listen event... better sending user post request particular endpoint, telling him order has been processed. there many libraries out there can implementing pub/sub pattern check following... pubnub pusher bunny rabbitmq redis please note have use rails app publisher , front end subscriber ( can check equivalent libs js ) and if interested in implementing pub/sub within same rails app... i've looked lot , found working solutions ( app publi

graphics - Texture argument in the Line class -

in kivy garden plot module, texture parameter passed line() constructor, , subsequently used anti-aliasing. couldn't find documentation on argument in official docs . looking @ source of line , looks parameter not parsed altogether. is legacy parameter? if so, how used , how can functionality achieved now? this works because smoothlineplot using custom fragment shader, defined here . uses information in texture achieve antialiasing effect. the normal line does use texture (actually vertexinstructions can take texture parameter , have vertices including texture coordinates), in trivial way doesn't work more antialiasing, , isn't taken advantage of kivy's default fragment shader . covered in source of line, texture property checked here , , information texture coordinates use set when constructing vertices later, e.g. here . assuming you're using kivy master (some of these changes recent, line used parse (0,0) coordinate of texture), think shoul

angularjs - How can I load jQuery before navigating to a new page with ui-router? -

i have angularjs application uses ui-router. it's spa application , want keep initial load time down as possible. when user clicks on link go map page on application need load jquery. here's ui-router config code: var homemap = { name: 'home.map', parent: 'home', url: '/:map', views: { 'root': { templateurl: '/content/app/home/partials/home.html', }, 'content': { templateurl: function (stateparams) { return '/content/app/home/partials/' + stateparams.content + '.html'; }, } } }; is there way can loading of jquery , confirm has finished before moving user new page. note need kind of resolve inside ui-router code block rather coding script elements in page load. in resolve block, setup promise , return it, load jquery, poll until exists on window object. once does, resolve promise: resolve:{

sql - Specifying "AND" Condition with more than 1 time for same column in MYSQL -

i have table like: product_id | attribute_id | text -------------------------------- 52 | 16 | 1.0 inch - 2.9 inches 52 | 15 | radio 52 | 14 | simple phones 134 | 16 | 1.0 inch - 2.9 inches 134 | 15 | wifi 134 | 14 | dual sim phones i writing query getting products simple phones 1.0 inch - 2.9 inches screen. i want place 2 conditions 1 column. when writing query: select * product_attribute (text = '1.0 inch - 2.9 inches') , (text = 'simple phones') so getting "0 results". while running following query: select * product_attribute text in('1.0 inch - 2.9 inches','simple phones') then getting following result: product_id | attribute_id | text -------------------------------- 52 | 16 | 1.0 inch - 2.9 inches 52 | 14 | simple phones 13

html - convert PDF to JPEG in PHP using ZEND server -

Image
i'm using script convert pdf jpg online. when run script on zend server , upload pdf file file upload on server & show broken images on browser. i use 1 folder , 1 index file code written. upload folder index.php file here script running: <html> <head> <style type="text/css"> img {border-width: 0} * {font-family:'lucida grande', sans-serif;} </style> </head> <body> <?php $message = ""; $display = ""; if($_files) { $output_dir = "uploads/"; ini_set("display_errors",1); if(isset($_files["myfile"])) { $randomnum = time(); $imagename = str_replace(' ','-',strtolower($_files['myfile']['name'])); $imagetype = $_files['myfile']['type']; //"image/png", image/jpeg etc. $imageext = substr($imagename, strrpos($imagename, 

c# - Entity Framework is sometimes not loading the contents of Child Objects/Collections -

i've started have problem child collections in entity framework not being loaded lazy loading. the prominent example of orders object - each order has 1 or more order lines associated (ie. list of products have been ordered , how many). sometimes, when program run, can open orders , order lines (for every order) blank. restart program, , might re-appear. it's pretty intermittent. i have confirmed there no entries in child collection through logging & debugging: private observablecollection<orderline> loadorderlines() { log.debug("loading {0} order lines...", this.model.orderlines.count); var result = new observablecollection<orderline>(); foreach (var orderline in this.model.orderlines) { result.add(orderline); } return result; } sometimes "loading 0 order lines..." , "loading 4 order lines..." same order. i can't use eager loading when load

linux - MySQL on two ports using IPTables - self-access -

i'm trying make mysql available 2 ports: 3306 , 3339 added rule iptables: iptables -t nat -a prerouting -i bond0 -p tcp --dport 3339 -j redirect --to-port 3306 and everythin great remote connections. if i'm trying connect locally, i'm getting error: mysql -u username -ppassword --port=3339 -h host.name error 2003 (hy000): can't connect mysql server on 'host.name' (111) any ideas how can edit iptables local access via 3339 port? since prerouting isn't used loopback interface have add 1 more rule: iptables -t nat -i output -p tcp -o lo --dport 3339 -j redirect --to-ports 3306

cakephp - Using Access Tokens with JavaScript in OAuth2 -

this i've tried information on i've never found actual answer or solution problem. can clarify , point me in right direction. i've split problems 3 questions @ bottom, if answered 1,2,3 that'd make things easier digest , me head around this. so basically, have oauth2 sever setup using cakephp following javascript can communicate allow user login , access token , make various requests different endpoints using token send , receive data. var access_token, refresh_token; var app = { init: function() { $(document).ready(function(){ users.checkauthenticated(); }); }(), splash: function() { var contentlogin = '<input id="username" type="text"> <input id="password" type="password"> <button id="login">log in</button>'; $('#app').html(contentlogin); }, home: function() { var contenthome = '<h1&g

jquery - How to make rotate to 45 deg and animate change left same time? -

how make in duration rotate angle 45 deg , stop? can't find way make angle in below demo increase 45 during animate change margin-left, how it?? http://jsfiddle.net/8tp9d/37/ var angle = 0; $('.btn').click(function(){ $("#a").animate ({ "margin-left": "+=200px" }, { step: function (now, fx) { angle += 1; $(this).css({ "-moz-transform":"rotate("+angle+"deg)", "-webkit-transform":"rotate("+angle+"deg)", "-ms-transform":"rotate("+angle+"deg)", "-o-transform":"rotate("+angle+"deg)" }); }, duration: 300 }, "linear"); }); there no reason increment rotation each step can use .animate , give target value , automatically step value (and fluently) if doing this, use .css , css transitions performs better jqu

java - Creating dot-function for android calculator -

im doing small project, gathering random calculator codes net , improving them learn java , android development... so, im trying implement dot-function calculator code, doesn't work it's supposed to. instead of adding dot, adds value 46 (why 46??). me create functional dot-function? java code: package com.example.elof_calculator; import android.os.bundle; import android.app.activity; import android.view.menu; import android.view.view; import android.widget.button; import android.widget.edittext; public class mainactivity extends activity { public string str =""; character op = 'q'; double i,num,numtemp; edittext showresult; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); showresult = (edittext)findviewbyid(r.id.result_id); } public void btn1clicked(view v){ insert(1); } public void btn2cli

java - Are hashCodes unique for Strings? -

recently, came across piece of code, map<integer, string> used, integer (key) hashcode of string , string value corresponding that. is right thing do? because now, equals not called string when calling get . ( get done using hashcode() method on string object. or, hashcode(s) unique unique strings? i checked equals od string class. there logic written that. confused. a hashmap does use equals() compare keys. uses hashcode() find bucket key located, , drastically reduce number of keys compare equals() . obviously, hashcode() can't produce unique values, since int limited 2^32 distinct values, , there infinity of possible string values. in conclusion, result of hashcode() not fit key of map .

Results of comparing integers in C -

if x , y both int , x-y < 0 return same result x < y ? no. if x-y causes overflow or underflow, behavior undefined (because int signed type). for example int_min - 1 < 0 undefined behavior, whereas int_min < 1 defined (and true). when there's no overflow, 2 expressions, x-y < 0 , x < y same. because compiled code may whatever likes when there's undefined behavior, c compiler allowed rewrite x-y < 0 x < y if wishes. isn't true if x , y unsigned types, overflow well-defined, , x-y < 0 , x < y not equivalent.

c++ - Makefile weird percent text-pattern behaviour -

good day, consider following portion of makefile: objects := $(patsubst %.cpp,%,$(wildcard tests/*.cpp)) test_executable := $(patsubst tests/%, tests/run-%,$(objects)) testf_executable := $(patsubst tests/%, tests/runf-%,$(objects)) all: $(objects) test: $(test_executable) test_formatted: $(testf_executable) runf-%:% ./$^ --output_format=xml --log_level=test_suite > $(^)-report.xml run-%:% ./$^ summary : focus on test_executable , contains list of target object files corresponding c++ files in test/ folder. produces lot of executables want call executables in make test or make test_formatted . so, both test , test_formatted call run , runf , executing executables. problem : understanding of runf-% when have run-tests/executable , should match pattern of runf- , % replace tests/executable ./tests/executable should work. not case. when get make: *** no rule make target `run-tests/executable', needed `test'. stop. i thou

javascript access the counter of a for in loop -

how can access counter of for..in loop? i have array , object. want iterate on object properties while doing same array, without explicitly declaring counter. var colors = ['red','yellow','purple','blue']; var flowers = {'rose':'','sunflower':'','violet':'','hydrangea':''}; (prop in flowers) { flowers[prop] = colors[i]; } follow question. if not possible, how create own loop functionality require. here's how it's working find i'm doing , want create reusable. var colors = ['red','yellow','purple','blue']; var flowers = {'rose':'','sunflower':'','violet':'','hydrangea':''}; var = 0; (prop in flowers) { flowers[prop] = colors[i]; i++; } (ecmascript 2015 changes things, see update @ end of answer.) i have array , object. want iterate on object pro

javascript - How to save select value of dropdown to MySQl table -

i have 2 drop down. in 2nd drop down items added dynamically based on 1st drop down selection. now want selected value of 5th subject store in mysql table. not able value of option selected in 2nd drop down. how can selected value items dynamically added in option tag here code <script> function setsubject(objlanguage) { var objmedia = document.getelementbyid("5thsub"); objmedia.options.length = 0; objmedia.disabled = false; switch (objlanguage.value) { case "humanity": objmedia.options.add(new option("hindi")); objmedia.options.add(new option("ip")); break; case "commerce": objmedia.options.add(new option("ip")); objmedia.options.add(new option("other")); break; case "sci[pcm]": objmedia.options.add(new option("cs")); objmedia.options.add(new option("ip")); break;

asp.net - Error Failure Sending Mail -

i trying send email using asp.net vb. email send through company server. have many suggestion internet error same. 'failure sending mail' here code far: protected sub btnsend_click(sender object, e eventargs) handles btnsend.click try dim message new mailmessage() dim client new smtpclient("blablabla@myhost.com") message.from = new mailaddress(txtfrom.text) message.to.add(new mailaddress(txtto.text)) message.subject = txtsubject.text message.body = txtmessage.text message.isbodyhtml = true message.priority = mailpriority.high client.port = 25 client.enablessl = true client.send(message) lblinfo.visible = true lblinfo.text = "your message has been sent" catch ex exception lblinfo.visible = true lblinfo.text = ex.message end try end sub and here web.config <system.net> <mailsettings> <smtp deliveryme

working with workspaces and Pydev in Eclipse -

Image
im not sure did.. working through tutorials speed on python, , started getting error message... ideas on how fix this? error, looked message, , looks wham press run button looking file no longer there.... i'm not working on file anymore... i'm trying run different not refer previous file. what work if run as.. id rather not every time. i'm sure there setting i'm not aware of messed up. eclipse pydev share | improve question asked jun 2 '14 @ 2:50 stilllearningtocode 505 2 8 19 add comment  |