Posts

vb.net - Visual Basic Change maker program -

i'm writing program class , i've been stuck day now. program needs give change user inputted decimal. in 9.41 9 dollars, 1 quarters, 1 dimes, 1 nickel, 1 penny. results aren't correct great thanks! public class tessitorenlab3 private sub btncalculate_click(sender object, e eventargs) handles btncalculate.click dim balance integer dim remainingbalance integer dim txtamount double txtamount = cdbl(txtamount1.text) 'i renamed text box txtamount1... balance = (cint(txtamount / 1)) lstresults.items.add(balance & " dollars") remainingbalance = balance * 100 balance = remainingbalance / 25 lstresults.items.add(balance & " quarters") remainingbalance = balance * 100 balance = remainingbalance / 10 lstresults.items.add(balance & " dimes") remainingbalance = balance * 100 balance = remainingbalance / 5 ...

rewrite - Nginx - Redirect url for certain file type -

i have nginx 1.2.1. want rewrite: http://mywebsite.com/[token].mp4 http://mywebsite.com/get.php?token=[token] return error 404, block: location ~* \.(mp4)$ { rewrite "^/([a-za-z0-9]{23})\$" /get.php?token=$1 break; } i tried this question nothing, returns error 404 according nginx.conf provided here , try below: location ^~ /videos/ { rewrite "^/videos/([a-za-z0-9]{23})\.mp4$" /get.php?token=$1 break; } this should match url: example.com/videos/abc01234567890123456789.mp4 , redirect example.com/get.php?token=abc01234567890123456789 disclaimer: config not tested, may have typos

Javascript trouble when copying element from one array to another. Extra square brackets, extra dimensions? -

starting out with: arraya = [ ["element0"], ["element1"], ["element2"] ]; and arrayb = []; after for-loop: arrayb[i] = arraya.splice(x,1); then arrayb = [ [["element0"]], [["element1"]], [["element2"]] ] any clue why happening? array.splice returns array of removed items. in arraya , each item array, array.splice returns array containing array. example, arraya.splice(0, 1) returns [["element0"]] . if use populate arrayb this, you'll end array in each element array containing single array, have. if use array.splice single element , want element returned, write arraya.splice(0, 1)[0] first element. also, want arraya array of arrays? or want array of strings? if so, arraya = ["element0", "element1", "element2"]; , result of arraya.splice(0, 1) "element0" .

if statement - Better way to check a list for specific elements - python -

i using try/except blocks substitute if/elif has bunch of and s. looking list , replacing elements if has x , x , x, etc. in project, have check upwards of 6 things drew me using try/except .index() throw error if element isn not present. an analogy looks this: colors = ['red', 'blue', 'yellow', 'orange'] try: red_index = colors.index('red') blue_index = colors.index('blue') colors[red_index] = 'pink' colors[blue_index] = 'light blue' except valueerror: pass try: yellow_index = colors.index('yellow') purple_index = colors.index('purple') colors[yellow_index] = 'amarillo' colors[purple_index] = 'lavender' except valueerror: pass so if colors array doesn't contain 'purple' 'yellow' , don't want array change. i bit wary of approach because seems abuse of try/except . shorter alternative because have grab elements...

gps - Android: Get current country offiline -

it easy country when online. possible country phone in right now, without internet connection ? you don't need internet connection use gps. gps information provided satellites in space. how current gps location programmatically in android? to figure out country, use offline reverse geocoder, such https://github.com/areallygoodname/offlinereversegeocode or, shape files of countries , see if gps co-ordinates inside shape. see http://www.gadm.org/ , http://www.naturalearthdata.com/

javascript - Google Charts API: more than one label rows on x axis? -

Image
i have chart bar chart showing multiple data. data divided year (2014, 2015) , quarter (q1,q2,q3,q4). can show either quarters on x-axis or year, not both. made screenshot , put years in there show i'd achieve. <html> <head> <script type="text/javascript" src="https://www.google.com/jsapi"></script> </head> <body> <script type="text/javascript"> google.load('visualization', '1.1', {packages: ['bar']}); google.setonloadcallback(drawbasic); function drawbasic() { //create data table object var data = google.visualization.arraytodatatable([ ['','sales', 'expenses'], ['q1',1000, 400], ['q2',1000, 400], ['q3',1170, 460], ['q4',900, 500], ['q1',1400, 420], ['q2',1240, 750], ['q3',1001, 360], ['q4',788, 800] ]); var option...

powershell - Serializing PsObject for Invoke-Command -

i'm looking best or proper way pass psobject remote function invoke-command. convertto-xml serializing there no built-in reverse cmdlet. solutions i've found online content specific. i implemented following functions works few objects tested seems rather hacky. going bite me? there better, yet still simple solution? function get-tmpfilename () {...} function serialize-psobject($obj) { $tmpfile = get-tmpfilename export-clixml -inputobject $obj -path $tmpfile $serializedobj = get-content $tmpfile remove-item $tmpfile $serializedobj } function deserialize-psobject($obj) { $tmpfile = get-tmpfilename $obj > $tmpfile $deserializedobj = import-clixml $tmpfile remove-item $tmpfile $deserializedobj } are aware powershell serializes objects sent through invoke-command ? if reason isn't enough or isn't working you, can use use built-in serialization directly: $clixml = [system.management.automation.psserializer]::...