Posts

c - Why are the values of a struct corrupted after the struct is initialized? -

i trying initialize array of structs values, cannot values stay constant. use initial loop retrieve values string , assign them struct in array. once try iterate through array loop, of values not same. this code in question: void printorder(order *node) { printf("title is: %s\n",node->title); printf("price is: $%f\n",node->price); printf("id is: %d\n",node->custid); printf("category is: %s\n",node->category); } void initorder(order *neworder, char *title, double price, int custid, char *category) { neworder->title = title; neworder->price = price; neworder->custid = custid; neworder->category = category; neworder->next = null; printf("new order object initialized\n"); } char *title; char *pricetemp; char *idtemp; char *category; order localorders[numorders]; // num...

ruby - How can I remove a line in one file on Rails? -

i trying remove line in 1 file on rails. found method gsub_file, undefined method in rails 4. it's reverse method of insert_into_file of thor. e.g.) app/assets/stylesheets/application.css before *= require_tree . <- needs removed! *= require_self after *= require_self this should performed in rails application template. if implementing application template (for use rails new myapp -m option), try using thor gsub_file , this: gsub_file 'app/assets/stylesheets/application.css', /*= require_tree .\n/, "" take @ rails_apps_composer gem if you'd see lots of file manipulation using thor.

Scrollbar on JavaFX table leaves a white space when using custom CSS -

Image
a picture worth thousand words: . as can see i'm using custom css on table, cant fill upper-right corner. tried changing background of scroll-pane without result. here's actual css: .table-row-cell { -fx-background-color: rgba(71, 81, 80,0.5); } .table-row-cell:hover { -fx-background-color: rgba(40, 96, 93, 0.50); } .table-row-cell:hover:empty { -fx-background-color: rgba(71, 81, 80,0.5); } .table-row-cell .table-cell { -fx-border-width: 0px; } .table-view { -fx-border-color: rgba(1, 11, 12, 1); -fx-background-radius: 2; -fx-border-width: 1px; -fx-border-radius: 2; -fx-background-color: rgba(71, 81, 80,0.2); -fx-background-insets: 0; } .table-view .column-header { -fx-background-color: rgba(1, 11, 12, 1); } .scroll-bar { -fx-background-color: rgba(1, 11, 12, 1); } .scroll-bar .increment-button:hover { -fx-background-color: rgba(1, 11, 12, 1); } .scroll-bar .decrement-button:hover { -fx-background-color: rgba(1, 11, 12, 1); } .s...

c# - Count numbers of \r\r in a string -

this question has answer here: how count of sub-string occurrences? [duplicate] 8 answers i want count, how have \r\r in string variable. for example: string samplestring = "9zogl22n\r\r\nv4bv79gy\r\r\nkaz73ji8\r\r\nxw0w91qq\r\r\ns05jxqxx\r\r\nw08qsxh0\r\r\nuyggbaec\r\r\nu2izr6y6\r\r\n106iha5t\r"; the result in example 8. you can write simple extension method that: public static int linefeedcount(this string source) { var chars = source.tochararray(); bool found = false; int counter = 0; int count = 0; foreach(var ch in chars) { if (ch == '\r') found = true; else found = false; if (found) counter++; else counter = 0; if(counter != 0 && counter%2 == 0) count++; } return count; } then use it: int count = inputstring.linefeedcount(); ...

android - App crashing when trying to save to SD Card -

i'm trying make app averages colour , stuff, have. i've got colour in imageview , have made bitmap, want save on sd card. when press button try , make so, crashes. i'm hoping give its' own folder when saving, , custom file name. (in ideal world, i'd 1 increases 1 each time, swatch_01.png , swatch_02.png , etc.) if it's simple might cry little bit. edit: thank guys, it's fixed. hadn't created javerager_swatches folder , imageview wasn't converting bitmap correctly. had @ after amount of sleep , managed solve it. package com.colours.javerager; import java.io.file; import java.io.filenotfoundexception; import java.io.fileoutputstream; import java.io.ioexception; import java.io.outputstream; import android.app.actionbar; import android.app.activity; import android.content.intent; import android.graphics.bitmap; import android.graphics.drawable.bitmapdrawable; import android.os.bundle; import android.os.environment; import android.support.v4...

tcl - How to PUT xml content using method ::http::geturl -method PUT -

when tried fire fox open httprequest addon, able put sucessfully. put http://12.222.20.17:8080/qcbin/rest/domains/test/projects/runtest/runs/385762 accept: application/xml content-type: application/xml <entity type="run"> <fields> <field name="status"> <value>passed</value> </field> </fields> </entity> -- response -- 200 ok server: apache-coyote/1.1 but trying simulate same operation tcl put method http package, getting bad request response set xml {<entity type="run"><fields><field name="status"><value>passed</value></field></fields></entity>} set headers(cookie) $cookie set headers(accept) "application/xml" set headers(content-type) "application/xml" set headers(content) $xml set token [::http::geturl "http://12.222.20.17:8080/qcbin/rest/domains/test/projects/runtes...

crash - Debugging Python Fatal Error: GC Object already Tracked -

my python code has been crashing error 'gc object tracked' . trying figure out best approach debug crashes. os : linux. is there proper way debug issue. there couple of suggestions in following article. python memory debugging gdb not sure approach worked author. is there way generate memory dumps in such scenario analyzed. in windows world. found article on this. not entirely answers question: http://pfigue.github.io/blog/2012/12/28/where-is-my-core-dump-archlinux/ found out reason issue in scenario (not reason gc object crash). used gdb , core dumps debug issue. i have python , c extension code (in shared object). python code registers callback routine c extension code. in workflow thread c extension code calling registered call routine in python code. this worked fine when multiple threads did same action concurrently resulted in crash 'gc object tracked'. synchronizing access python objects multiple thread resolve issue. than...