Posts

Showing posts from January, 2011

c# - Populating multiple dropdowns from single source and changing data dynamically -

i have table named employee. fetching data table 5 drop-downs fields empno, unit, location, onsite/offshore etc., when selecting value in of drop-downs values in drop-downs have change. can pls me how can acheive this?? server side solution there selectedindexchanged event dropdown control. in event, need reset other dropdowns or reload other data. client side solution (with jquery) listen change event of first dropdown , clear other dropdown content in event. $(function(){ $("#idoffirstdropdown").change(function(e){ $("#idofsecond").html(""); }); });

How do I revert to the original perspective on Eclipse for ADT? -

i original perspective installed eclipse adt. unfortunately, have messed perspectives when trying debug.how revert original perspective on eclipse fro adt ? thank cch4adt go window , select 'reset perspective' option. reset default perspective.

asp.net - How to lock screen on Jquery Onclick and ajax call -

i have submit button id "go" retrieving data server side due data length large taking large long time load .for reason want add screen locker on go button click dont have idea how through jquery on client side.. please direct me link can jquery screen locker ... here code... $(document).ready(function () { $("#go").click(function (e) { e.preventdefault(); $("#gridid").gridunload(); gridload(); }); }); function gridload() { $.ajax({ url: 'default2.aspx/mymethod?fromdate=' + $("#fromdate").val() + '&todate=' + $("#todate").val(), datatype: 'json', contenttype: "application/json; charset=utf-8", type: 'post', success: function (reportdatanew, textstatus, xmlhttprequest) { //debugger;

firewall - How can I block some special User-agents Via IPTables -

i need block packets source includes special user agents using iptables. don’t want manage via .htaccess or apache. there way? you can this: iptables -a input -p tcp --dport 80 -m string --algo bm --string "mozilla/4.0 (compatible; msie 6.0; windows nt 5.1)" -j drop

.net - Can't install package for Node.js on Windows -

Image
i try install iconv package node.js on windows 8.1. first, installed visual c + + 2005 express edition, because console returns error: but now, console returns different error: are libraries first screen installed? second screenshot says compilers can not find project file on path d:\schedule\node_modules\iconv\build\iconv.vcproj try open project in vs , compile her, , try again install iconv npm

c++ - Target Eye Autoupdate: fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt -

i found target eye's unique autoupdate mechanism on codeproject autoupdating script. but got error when building vs2010: 1>link : fatal error lnk1123: failure during conversion coff: file invalid or corrupt 1> 1>build failed. i tried stackoverflow: failure during conversion coff , gave me error: 1>stdafx.obj : warning lnk4075: ignoring '/editandcontinue' due '/incremental:no' specification the obvious thing file search through rc files vs_version_info, may have 1 defined, or alternatively may have same .rc file included twice ... that said, i've had vs2010 wierd things me before resource , source files, , way resolve remove file solution, , re-add it

swing - How can we add JScrollPane on JTextArea in java? -

Image
can tell me problem in following program? want fit jscrollpane on jtextarea when add jtextarea not visible. import javax.swing.*; import java.awt.*; import java.awt.event.*; class area extends jframe { private jtextarea ta; private jtextfield tf; jscrollpane jp; public area() { super("text area"); tf=new jtextfield(); tf.setbounds(100,350,300,30); add(tf); ta=new jtextarea(); ta.setbounds(100,100,300,200); jp= new jscrollpane(ta); add(jp); setlayout(null); setsize(500,500); setvisible(true); setdefaultcloseoperation(jframe.exit_on_close); } public static void main(string...s) { new area(); } } i see several problems: don't use null layout; use real layout . the default layout of jframe borderlayout ; default position center ; 1 component can occupy position @ time; example below uses north & center . use appropriate con

javascript - chart.js in meteor not drawing -

in meteor project, have copied demo code chart.js client folder follows: function drawchart(){ var data = { labels : ["january","february","march","april","may","june","july"], datasets : [ { fillcolor : "rgba(220,220,220,0.5)", strokecolor : "rgba(220,220,220,1)", pointcolor : "rgba(220,220,220,1)", pointstrokecolor : "#fff", data : [65,59,90,81,56,55,40] }, { fillcolor : "rgba(151,187,205,0.5)", strokecolor : "rgba(151,187,205,1)", pointcolor : "rgba(151,187,205,1)", pointstrokecolor : "#fff", data : [28,48,40,19,96,27,100] } ] } //get context jquery - using jquery's .get() method. var ctx = $("#mychart").get(0).getcontext("2d"); //this first returned node in jquery collection. var mynewchar

android - The nested type maintype cannot hide an enclosing type -

public class mainactivity extends activity implements onclicklistener { public class mainactivity extends activity { what going wrong here? solved it public class mainactivity extends activity implements onclicklistener {

php - Local include path alias -

this might silly question annoys me. began program in sublime text 2 short while ago, , love it. 1 thing don't know how set way include scripts has included differently on server. on server have include library, save "secure" files. directory placed outside of root, using apache, php script can access scripts writing include "filename.php"; . love feature prevents me receiving documentation , list on functions , variables. if want receive these informations, have include classes/files this: include "../path/filename.php" . this, won't work on server. i know silly, think work comment out path variable every time have upload, test , uncomment again when writing code. hope understand trying achieve, , please tell me if there easy solution. mentioned sublime text 2 because know there lot og packages (plugins) , perhaps have thought plugin automatically checks every include/require command , if no path defined, checks whether or not in local fol

android - One button random sounds -

i have 1 simple app 1 button. when push it, play 1 sound(btn001). play random sounds raw folder. have there 47 soundfiles named btn001 btn047. there simple way modify code make work. know there alot same questions on web. i've tryed of them have found. i'ts frustrating have'nt got work. here code: import android.media.mediaplayer; import android.os.bundle; import android.app.activity; import android.view.menu; import android.view.view; import android.widget.button; public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button pushme = (button) findviewbyid(r.id.button1); final mediaplayer cheer = mediaplayer.create(mainactivity.this, r.raw.btn001); pushme.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) {

cygwin - bash script to read/ping a list of ip addresses from a text file and then write the results to another file? -

i have text file lists of ip addresses called address.txt contains following 172.26.26.1 wlan01 172.26.27.65 wlan02 172.26.28.180 wlan03 i need write bash script reads ip addresses, ping them , output text file this: 172.26.26.1 up 172.26.27.65 down 172.26.28.180 down i new bash scripting not sure start this. appreciated. in linux work: awk '{print $1}' < address.txt | while read ip; ping -c1 $ip >/dev/null 2>&1 && echo $ip || echo $ip down; done i don't have cygwin test, should work there too. explanation: with awk first column input file , pipe loop we send single ping $ip , , redirect standard output , standard error /dev/null doesn't pollute our output if ping successful, command after && executed: echo $ip up if ping fails, command after || executed: echo $ip down somewhat more readable, expanded format, put in script: #!/bin/sh awk '{print $1}' < address.

webfonts - Packaging a font with a Google Chrome extension -

i want use other standard fonts chrome extension. excited possibility of using google web fonts, seems incur penalty transferring web font on network whenever extension uses it, point of affecting performance of extension. have option packaging font extension work on chrome-supported platforms (windows/mac/etc.)? in advance choose font. example i'll take "stint ultra expanded" . there example how add page: <link href='http://fonts.googleapis.com/css?family=stint+ultra+expanded' rel='stylesheet' type='text/css'> take href , open in browser. you'll see smth this: @font-face { font-family: 'stint ultra expanded'; font-style: normal; font-weight: 400; src: local('stint ultra expanded'), local('stintultraexpanded-regular'), url(http://themes.googleusercontent.com/static/fonts/stintultraexpanded/v1/feigx-wddghmckuhekhedwmdhyvwfbygze-w47q2x_f3rgvtstkpsbdajuo5ueqw.woff) format('woff')

java - Display a sublist using the list option selected -

i creating ecommerce website in java in have categories such clothing, books, electronics, etc. wish when choose category, e.g. electronics, should list sub-options such mobiles, tv, ipod, etc. how can accomplish this? you can build categories class static getsubcategories() method returns set of sub-categories each possible category: categories.java import java.utils.list; import java.utils.arrays; class categories { private final statis categories categories = null; private map<string, list<string>> subcategories = null; private categories() { subcategories = new hashmap<>(); subcategories.put("eletronics", arrays.aslist("mobiles", "tv", "ipod")); } public static categories getinstance() { if (categories == null) { categories = new categories(); } return categories; } public static getsubcategories(string category) {

Read From Pipe in Bash Script -

i've got bash script ever going invoked via pipe. i'm curious what's best way read data pipe? command like: $ output_gen | process my script process. not homework, learning exercise. when program receiving data pipeline, it's received via stdin. read stdin, use read builtin. here example: myprog: while read -r line; <something "$line"> done command: printf 'foo\nbar\n' | ./myprog

c - compare 2 inputs from keyboard with strcmp leads to segmentation fault -

i new student in c language , come this. code: #include <stdio.h> #include <string.h> int main(void) { char str[80]; printf("enter sth: "); char st1 = gets(str); printf("enter sth: "); char st2 = gets(str); if(strcpy(st1,st2)) printf("same\n"); else printf("different\n"); return 0; } my goal check if 2 strings enter keyboard same. compile , warnings: hello.c: in function ‘main’: hello.c:9:16: warning: initialization makes integer pointer without cast [enabled default] hello.c:12:16: warning: initialization makes integer pointer without cast [enabled default] hello.c:14:5: warning: passing argument 1 of ‘strcpy’ makes pointer integer without cast [enabled default] /usr/include/string.h:128:14: note: expected ‘char * restrict ’ argument of type ‘char’ hello.c:14:5: warning: passing argument 2 of ‘strcpy’ makes pointer integer without cast [enabled default]

python - cant set up the nginx server (port forwarding) -

Image
i'm using django , nginx , gunicorn setup application. when port forwarding 80---->80 , go ip works. when use "german god" anonymity program, not respond. mean that, when go own ip computer, program works fine. when same outside, have no response. thought internet service provider blocks port 80. what tried setup port forwarding 8001 ----> 80 still not work. thats nginx config file. server { listen 80; access_log /var/www/shop/00/access.log; error_log /var/www/shop/00/error.log; location /static/ { alias /var/www/shop/00/static/; } location / { proxy_pass http://127.0.0.1:8888; } } thats nginx config file. bind = u"127.0.0.1:8888" logfile = u"/var/www/shop/00/gunicorn.log" workers = 3 and port forwarding so: thanks in advance.

integer - Binomial coefficient function C++ incorrect answer n>13 -

i'm trying learn c++ , hence i'm trying function calculate binomial coefficient. code works n of 12, larger values generated result incorrect. i'm grateful input. long double binomial(int n, int k) { int d = n-k; int = 1, t = 1, n1 = 1, n2 = 1; if (d == 0) { return 1; } else if (n==0) { return 1; } else { while (i <=n) { t *= i; if (i == d) { n1 = t; cout << t; } if (i == k) { n2 = t; cout << t; } i++; } } return t/n1/n2; } int main() { int n, k; cout << "select integer n: \n"; cin >> n; cout << "select integer k: \n"; cin >> k; long double v = binomial(n,k); cout << "the binomial coefficient is: " << v << "\n"; return 0; } if int 32 bits long on system (very common nowadays), factorial of 13 doesn't fit ( 6227020800 > 2147483647 ). either tr

Different replace for the same word notepad++ -

i have these words: top , lock . have 49 times word replace different word lot of times. example, first time luc , second times pile . i make automatically. have list of replace words in text file. use notepad++. i have searched on many sites, cannot find solution. i don't have notepad ++ can highlight , right click there's option replace? or highlighting clicking format @ top , clicking replace , using ctrl + f , replacing way? sorry if not :)

mysql - How to query specific category or all categories inside the same query? -

i have table column name "category". in php, use sql prepare statement select records belonging specified category. category=? , add variable category value. works fine. however, how can select categories within same query? i tried using null , '' category value did not work. copying whole code part query might create spagetti code, wondering if there better option. there? thanks! building on @jamesmarks offering, simpler use query like $query = "select * table category = ? or 1 = ?;" then pass $category first parameter, , either 1 or 0 second parameter. if pass 1, second term becomes 1 = 1 . that's true, whole expression true. if pass 0, second term 1 = 0 , that's false, whole expression true if category = $category matches. that's simpler , better style designating special value 0 "any category." an alternative solution build query dynamically: $where = array(); if ($category) { $where[] = "c

image - iOS CATiledLayer and TilingView scale problems? -

i using tilingview apple photoscroller example tile images. works great of images, have few weird scale values. set level of detail 4. images scaled @ different values, 100,50,25,12.5 scales tiled 256x256 @ levels. in tilingview drawrect method, scale here must 1 of 4 values , 1.0,0.50,0.25,0.125. since store images off based on these scale values when weird scale value breaks , cannot load images. example have image @ .50 scale actual value 0.499798. any ideas whats going on here? if tell catiledlayer have 4 levels of detail, how end these weird values? cgfloat scale = cgcontextgetctm(context).a; nslog(@"scale = %f",scale); catiledlayer *tiledlayer = (catiledlayer *)[self layer]; cgsize tilesize = tiledlayer.tilesize; how can ensure image size pass return me 1 of 4 scales 100,50,25,12,5 image size specify? there several bugs in sample's code, 1 of involves proper rounding of scale values, leads issue seeing. there other subtle issues. please

javascript - AJAX function behaving weird -

i have ajax function supposed pass on data php code supposed enter data database happening ajax not working way should. <?php session_start(); include_once("../engine/database.php"); if (isset($_post["name"],$_post["password"]) ) { $uname = htmlspecialchars(mysql_real_escape_string($_post["name"]) ); $passwd = htmlspecialchars(mysql_real_escape_string($_post["password"]) ); $query = "select * users username ='".$uname."' , password='".$passwd."' limit 1"; $query= mysql_query($query); if(mysql_num_rows($query) == 1) { $_session['admin'] = "welcome admin panel {$_post['name']} "; $_session['onoff'] = 'on'; ?> <!doctype html> <html> <head> <meta charset="utf-8">

java - Most compressed way to store String Object -

i have string object want save file, , dont care if saved plain text or binary. have tried saving plain text , 27 bytes. tried objectoutputstream , 24 bytes. there better way of saving string objects file? string 189:25:600:-324324214& , intend have thousands of them. thats why want compressed, , of course each string bit different wrap fileoutputstream inside deflatoroutputstream inside objectoutputstream create file. (write entire array single object.) wrap fileinputstream inside inflatorinputstream inside objectinputstream read.

c++ - boost::intrusive_ptr changing pointer address -

i have base class provides intrusive_ptr_add_ref , intrusive_ptr_release subclasses use boost::intrusive_ptr . the code in question works 100% on macos x , linux. on windows (visual studio 2010, 64-bit relwithdebinfo optimizations disabled), works classes, breaks on 1 particular subclass (nothing weird or special it). have sequence of events stopped in debugger type this: 1. t * t = get_pointer_from_lua(); // correct value returned: 0x..7a38 2. boost::intrusive_ptr p(t); // ... , passed in here ... , in ensuing intrusive_ptr_add_ref , value of pointer 0x..7a40 . 8 bytes ahead. i'm looking @ stack trace right - 0x..38 goes intrusive_ptr 's constructor, hits reference increment function 0x..40. how can figure out what's happening here? third party libraries release builds, can't trace intrusive_ptr - can't imagine it's blatantly broken. i'm @ end of rope here. suggestions? edit : after posted this, obvious alignment issue jumped out @ me. m

javascript - I cant update my collection in backbone -

all running ,but when add new item collection ,the view not update collection display it. here code app.views.contacts = backbone.view.extend({ tagname: 'tbody', initialize: function(){ this.collection.on('sync',this.addone,this); }, render: function(){ this.collection.each(this.addone,this); return this; }, addone: function(contact){ var contactview = new app.views.contact({model:contact}); this.$el.append(contactview.render().el); } }); i don't know ,why sync not working i guess have ho render items on sync event , render 1 on add event. this: initialize: function(){ this.listento(this.collection, 'sync', this.render); this.listento(this.collection, 'add', this.addone); },

mysql - Error in SQL Syntax? Have to Check Manual...right syntax to use near 'WHERE id=''' at line 11 -

i've been trying make settings page users of website. when open mysettings.php page, page retrieves info db. when click save, error: you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'where id=''' @ line 11 i have made sure data values correct corresponding database field names. unaware why happening. my code is: mysql_query("update nb_user set `first_name` = '$data[first_name]', `last_name` = '$data[last_name]', `country` = '$data[country]', `lang` = '$data[lang]', `tel` = '$data[tel]', `level` = '$data[level]', `p_desc` = '$data[p_desc]', `p_post` = '$data[p_post]', `p_progress` = '$data[p_progress]', id='$_session[user_id]' ") or die(mysql_error()); //header("location: mysettings.php?msg=profile sucessfully saved"

gcc - Copy file, but error double free or corruption in C -

int main(int argc, char **argv) { file *fe, *fs; unsigned char buffer[2048]; int bytesreader; fe = fopen(argv[1], "rb"); fs = fopen(argv[2], "wb"); while((bytesreader = fread(buffer, 1, 2048, fe))) fwrite(buffer, 1, bytesreader, fs); fclose(fe); fclose(fs); return 0; } and error is... *** glibc detected *** ./doc2: double free or corruption (top): 0x096b7008 *** sorry, correct, dont undertand. fail? you need check return values of fopen() 0. calling fclose() on 0 results in error seeing. also, check argc valid range of arguments. int main(int argc, char **argv) { file *fe, *fs; unsigned char buffer[2048]; int bytesreader; if(argc != 3) { fprintf(stderr, "usage: %s file1 file2\n", argv[0]); exit(1); } fe = fopen(argv[1], "rb"); if(fe == 0) { fprintf(stderr, "%s: failed open %s read\n", argv[0], argv[1]);

javascript - Function executing instantly, not waiting for setTimeout -

i disable dropdown while while colors(interval) firing. in case manually set cutoff after 5 seconds. i'm experiencing when place re-activator in case block, not wait settimeout. or both calls firing @ same time , while settimeout firing (aka waiting 5 seconds) next call (the re-activator) fires well? the other question —and reason wanted deactivate dropdown while colors firing —is noticed while colors firing, if clicked on dropdown again —aka fire off call it, second call result in colors endlessly firing (assuming infinite loops created somehow). thoughts on why? function timetohexcolor(){ var time = new date(); var timestamp = time.tostring("hh:mm:ss"); document.getelementbyid("board").innerhtml += "#" + timestamp.split(":").join("") + "<br/>"; } function colors(interval) { this.interval = interval; switch (this.interval) { case 'second'

php - Function works when returning true or false but not when returning 0 or 1 -

function date2_in_the_past($day, $month, $year) { $datestring = $year . "-" . $month . "-" . $day; if (date ('y-m-d', strtotime($datestring)) < date('y-m-d', strtotime("now",time()))) { $b = 1; **// want $b = true**; } else { $b = 0; **// want $b = false;** } return $b; } //echo date2_in_the_past(24, 10, 2013); // returns 0 but doesn't return $b = true or $b = false; . idea how make function work assigning $b boolean rather writing '==1' or '==0' ? the problem in echo commented. if want check if variable either true or false should use var_dump($variable) instead of echo $variable;

Android get first Installation Time returns error -

hi getting strange error in app when asking first installation time using packageinfo! devices error rare , not often. why happening , there workaround? packagemanager manager = this.getpackagemanager(); info = manager.getpackageinfo(this.getpackagename(), 0); vpname = info.packagename; vname = info.versionname; vvers = info.versioncode; installdate = info.firstinstalltime; gives java.lang.nosuchfielderror: android.content.pm.packageinfo.firstinstalltime minsdkversion="7" a list of devices returns error: optimus 1 (thunderg) lg-p920 (p920) defy (umts_jordan) infuse (sgh-i997) that's because "firstinstalltime" introduced on api 9 (gingerbread) , above: http://developer.android.com/reference/android/content/pm/packageinfo.html#firstinstalltime in order avoid such errors, advised run lint check (using "v" button near run button, example). lint has plenty of errors , warning

python - How do I use Gimp / OpenCV Color to separate images into coloured RGB layers? -

i have jpg image, , find way to: decompose image red, green , blue intensity layers (8 bit per channel). colorise each of these 'grayscale' images appropriate color produce 3 output images in appropriate color, of each channel. for example if have image: dog.jpg i want produce: dog_blue.jpg dog_red.jpg , dog_green.jpg i not want grayscale images each channel. want each image represented correct color. i have managed use decompose function in gimp layers, each 1 grayscale , can't seem add color it. i using opencv , python bindings other projects suitable code side may useful if not easy gimp maybe figured 1 out, here's wants "see" separated channels in own color (that - red in red, green in green etc.). each channel single value image, may interpreted monochromatic image. can "add color" adding 2 fake empty channels ( zero_channel below), , cv2.merge multichannel image. #!/usr/bin/env python import cv2 import numpy

php - PhpExcel creates multiple worksheets -

Image
hello trying create excel template using phpexcel for reason image creates new worksheet instead of using current one. when open excel file i've created there worksheet , worksheet1 instead of single one. objphpexcel = new phpexcel(); $objworksheet = $objphpexcel->createsheet(); // set active excel worksheet sheet 0 $objphpexcel->setactivesheetindex(0); //taslak verileri $objphpexcel->getactivesheet()->setcellvalue('d'.'1', 'firm'); $objphpexcel->getactivesheet()->setcellvalue('j'.'1', 'sfuformu - fr.ps.21'); $objphpexcel->getactivesheet()->setcellvalue('j'.'3', 'no:'); $objphpexcel->getactivesheet()->setcellvalue('d'.'2', 'name surname signature'); $objphpexcel->getactivesheet()->setcellvalue('a'.

c++ - opengl shader directional lights specular reflection increasing with distance -

Image
the title says all.. using opengls built in lighting system, specularlight not increase or decrease distance object, shader implementation does. vertex shader: #version 330 layout (location = 0) in vec3 position; layout (location = 1) in vec2 texcoord; layout (location = 2) in vec3 normal; out vec2 texcoord0; out vec3 normal0; out vec3 worldpos0; uniform mat4 transform; uniform mat4 normalrotation; uniform mat4 transformprojected; void main() { gl_position = transformprojected * vec4(position, 1.0); texcoord0 = texcoord; normal0 = normalize((normalrotation * vec4(normal, 0.0))).xyz; worldpos0 = (transform * vec4(position, 1.0)).xyz; } fragment shader: #version 330 in vec2 texcoord0; in vec3 normal0; in vec3 worldpos0; out vec4 fragcolor; struct baselight { vec3 colordiffuse; vec3 colorspecular; float intensitydiffuse; }; struct directionallight { baselight base; vec3 direction; }; uniform vec3 tint; uniform sampler2d sampler; u

html - Avoid Items in List to shift -

i trying create dynamic unordered list built 3 list items there maybe either 1 or 2 items in list. problem when there 1 or 2 items in ul contents shifted up. how can avoid ? html: <html><head> <title>dashboard</title> </head> <body> <div id="wrapper"> <div id="coldow"> <div id="collef"> <ul id="days"> <div id="colrig"> <ul class="format" id="schedule1"> <li> event 3</li> <li>test space</li> <li>fit everthing , beyond</li> </ul> <ul class="format" id="schedule2"> <li> event 3</li> <li>test space</li> <li>fit everthing , beyond</li> </ul> <ul

linux - renaming files with strange unicode names -

recently downloaded files website, names contain strange unicode characters, console doesn't show them properly. want rename these files able use these files, following error: mv: cannot stat`filename': no such file or directory but sure these files exist. wonder how can rename these files, properly. ideas? using globbing characters (like ? or * ): mv *some-typeable-and-unique-substring* ... using tab-completion of favourite shell: start typing mv , beginning of filename, press tab , , can enter second parameter. if there other files in directory, might have move them directory able use tab-completion or wildcards.

c - How to access address of an array that is contained in a struct? -

i trying create program reading input file using getline. i have created following struct struct misc_struct { char *buf; file *some_input_file; }; in main file create buffer , multiple pthreads. char buf[1024]; file *some_input_file; struct misc_struct *pthread_arguments; ... pthread_arguments = (struct misc_struct *)malloc(sizeof(struct misc_struct)); pthread_arguments->buf = buf; pthread_arguments->some_input_file = some_input_file; pthread_create(&t1, null, start, (void *)pthread_arguments); now in start function: void *start(void *args) { size_t len; struct misc_struct *pthread_arguments = (struct misc_struct *)pthread_arguments; getline(&args->buf,&len,args->some_input_file); ... } unfortunately crashing @ getline() call. don't have trouble accessing args->buf when need use &args->buf getline function crashes "pointer being realloc'd not allocated" what should doing differently? thanks!

Distributing Java Application and files -

i have written java application talk blood machine. , posts data web server using oauth security , xml, , application works great. but need distribute customers have these machines. program in .jar file , requires other .jar files in project/dist folder. during execution uses little .png files displayed icons on screen, user can click etc. i want how wrap of (including images) , distribute them either installer or can use web server. what best way accomplish this, tried copy .jar , dist folder (as per instructions came out of netbeans) when run java -jar myfile.jar prints out text had ioexception because have not included .png files. code png files: im using this: try { databaseimage = imageio.read(new file("image/database.png")); databasedisconnectedimage = imageio.read(new file("image/database_delete.png")); } catch (ioexception ioe) { system.out.println("problem creating systray: "+ioe.get

Attempting to show progress bar icons in taskbar with Java, but all I get is a single black line -

Image
i've attempted create progress bar images using following code: public static void makeimage(int percent) { bufferedimage img = new bufferedimage(100, 30, bufferedimage.type_int_argb); graphics g = img.getgraphics(); g.setcolor(color.light_gray); g.fillrect(0, 0, 100, 30); (int x = 0; x < percent; x++) { (int y = 0; y < img.getheight(); y++) { img.setrgb(x, y, color.green.darker().getrgb() ); } } imgutility.save("/home/xxx/java/myproj/src/myproj/resources/progressbars/" + percent + ".png", img); } this creates bunch of 100x30 images 1.png 100.png, this: then, i'm trying show these images in tray, , cycle through them 1 one, show illusion of animated progress bar (in actual usage, want use these images show progress of task being done): tray tray = display.getdefault().getsystemtray(); trayitem trayitem = new trayitem(tray, swt.none); (int p

Getting rid of magic numbers in Java -

how rid of magic numbers in java without declaring massive amount of finals or static finals? keep in mind looping, arrays not allowed. doesn't seem possible? appreciated. thanks. example code: drawoval(5, 5, width, height); drawoval(10, 10, width, height); drawoval(15, 15, width, height); drawoval(20, 20, width, height); drawoval(25, 25, width, height); defining constants option. what's opposition using them? worth space in context. future developers rather see constants confused numbers mean.

c++ - Insertion Sort Variation -

#include <iostream> using namespace std; void print_array(int array[], int size) { cout<< "insertion sort steps: "; int j; (j=0; j<size;j++) cout <<" "<< array[j]; cout << endl; } void insertion_sort(int a[], int n) { int i; for(int j = 1; j < n; j++) { = 0; while ((a[j] > a[i])) { = i+1; } int m = a[j]; for(int k = 0; k <= (j-i-1); k++) { a[j-k] = a[j-k-1]; } a[i] = m; print_array(a,n); } } int main() { int array[6]= {3,2,4,5,1,6}; insertion_sort(array,6); return 0; } i trying modify insertion sort uses linear search technique inserts jth element in correct place first comparing (j − 1)st element, (j − 2)th element if necessary, , on. so says i = 0; should i = j-1; my attempt: void insertion_sort(int a[], int n) { int i; for(int j = 1; j

objective c - UIImagePickerController as Camera mode crashes on ios 7? -

these 4 lines causes app crash. if change uiimagepickercontrollersourcetypephotolibrary source type works charm. has nothing current app. create new project , added these 4 lines uibutton , still crashes. uiimagepickercontroller* picker = [[uiimagepickercontroller alloc] init]; picker.sourcetype = uiimagepickercontrollersourcetypecamera; [self addchildviewcontroller:picker]; [self.view addsubview:picker.view]; i've tried [self presentviewcontroller:picker animated:yes completion:^{}]; and popcontroller = [[uipopovercontroller alloc] initwithcontentviewcontroller:picker]; [popcontroller presentpopoverfromrect:button.bounds inview:button permittedarrowdirections:uipopoverarrowdirectionany animated:yes]; it cause crash: * terminating app due uncaught exception 'nsinvalidargumentexception', reason: '* -[__nsplaceholderdictionary initwithobjects:forkeys:count:]: attempt insert nil object objects[0]' * first throw call stack: (0x2e17af53 0x38

sql - MOD operator in where clause -

am getting invalid number exception how use mod in where clause, want update or odd rows based on id. update employee set respstr1 = 'ep' mid = 7246 , (mod(id/2) = 1) correct syntax mod is mod(id,2)

javascript - how to draw on canvas element in phonegap with touch -

i new @ phonegap, working on canvas drawing in phonegap canvas element not responding on touch events using samsung note testing.please me example of drawing in canvas element in phonegap.. here's phonegap 2.0.0-based example application on github demonstrates how use touch events , canvas draw: https://github.com/rockncoder/pgatouchpaint

Haskell Type error with where -

type ni = int type age = int type balance = int type person = (ni, age, balance) type bank = [person] sumallaccounts :: ni -> bank -> int sumallaccounts n l = filter nimatch l nimatch n (a,_,_) | n == = true | otherwise = false when run function type error couldnt match type (person, t0, t1) -> bool bool however when make own function works personnimatchs :: ni -> person -> bool personnimatchs n (a,_,_) | n == = true | otherwise = false let's @ type of filter filter :: (a -> bool) -> [a]-> [a] the type of nimatch ni -> person -> bool so haskell unifies a ni , person -> bool doesn't work! that's not bool , hence confusing error message. see visually haskell unifying -> bool -- ^ ^ unification error! ni -> (person -> bool) now assume type bank = [person] want sumallaccounts n = sum . map getbalance . filter matchni matchni (a, _, _)

dom - php - Having Issues extracting link information from within multiple nested tables and div using DOMXPath -

i'm trying extract specific link attributes within multiple nested table structure. document format old, explain rampant use of table element design page. here relevant document i'm trying parse using domxpath:: each table width of 100% has same level of nested childs, i.e. tbody, tr, td, a, div, etc. <table width="1000px"> <tbody> <tr></tr> <tr> <td> <br> <span></span> <span></span> <div></div> <div> <div></div> <div> <center></center> <hr> <table width="100%"></table> <table width="100%"> <tbody>

ios - CorePlot - CPTTimeFormatter gives me the same time for every element of my bar plot -

i have graph using core-plot (cptbarplot) , want show days on x axis, different day each bar in order. have tried set cpttimeformatter follows x x axis. nsdateformatter *dateformatter = [[nsdateformatter alloc] init] ; dateformatter.datestyle = kcfdateformattermediumstyle; cpttimeformatter *timeformatter = [[cpttimeformatter alloc] initwithdateformatter:dateformatter]; nsdate *refdate = [nsdate date]; timeformatter.referencedate = refdate; x.labelformatter = timeformatter; inside of numbersforplot returning set of numbers representing elapsed seconds, , since want have sequential days looks 0, 86400, 172800, 259200, 345600, 432000, 518400 etc. i expected x axis labels in case sequential list of dates starting @ refdate , going number of seconds in numbersforplot. instead see same date repeating on , on every bar on x axis. can explain me doing wrong , how might able fix it? thanks. edit: numbersforplot function looks ins

css - CSS3 - Verticle Angled 80% OUTER Box Shadow -

Image
i know how make box shadow run down element possible have extend down 80% of element instead of entire height of element? also how make shadow angle out (this thing im struggling most) something this? jsfiddle here there bunch of ways achieve this.. set shadow, , overlayed triangle. here alternative without blurred shadow.. http://jsfiddle.net/bheaz/1/ html - pretty simple <div></div> css div { width: 100px; height: 200px; position: relative; border: 1px solid black; box-shadow: 20px -10px 30px black; margin: 40px; } div:after { position: absolute; left: 102px; top: 100px; content: "\a"; width: 0; height: 0; border-bottom: 90px solid white; border-right: 50px solid white; border-top: 90px solid transparent; }

Migration from ASP.NET web service with SOAP Header and Mtom, WSE-3 to WCF -

i need migration asp.net web service wcf. current code this: server side: public class mytype { public int x; public string s; } public class myservice : webservice { public mytype myobj; [webmethod] [soapheader("myobj", direction=soapheaderdirection.inout)] public string somemethod() // no parameter!!! { if (myobj.x > 5) return myobj.s; else return "less 5"; } } </code> client side: myservice service = new myservice(); mytype m = new mytype(); m.x = 10; m.s = "that's it!!!"; service.myobj = m; string s = service.somemethod(); this works smoothly. need change wcf. found many topics how sign soap header wcf, how use messagecontract attribute of class given operation parameter. this: <code> [messagecontract] public class mytype { public int x; public strin

c# - Saving temporary image file in a session -

there user registration module requires users’ logo upload before register. i’m facing problem of store uploaded image, because @ time user uploading logo, actual user item not created. as solution that, can think of saving uploaded image (until create actual user item) in session variable. idea in terms of performance , longtime use of system? sounds bad idea. using session state adversely affect ability scale application , putting large binary blobs session put significant memory pressure on application. better solution store images temp area in file system , implement regular sweep function clear out uploaded images uploaded users didn't convert registered users (for example, images more day old). obviously, when user complete registration move image out of temporary storage.

asp.net - EDIT-UPDATE BUTTONS IN Repeater control -

i have repeater control collapsible panel inside div.(class header , class detail).when click edit button inside detail division - cancel , update button showing when click edit button div collapsing , can see update , cancel button after clicking row 1 more time.. every thing working fine except below stated one. each time click edit button division collapsing how can make class detail stable until edit/cancel/update. thanks <style> .header { font-size: larger; font-weight: bold; cursor: hand; cursor:pointer; background-color:#cccccc; font-family: verdana; } .details { display:none; visibility:hidden; font-family: verdana; } </style> &nbsp;<div style="overflow: scroll; overflow-x: hidden; overflow-y: auto;background- color:gray; height: 500px; width: 895px"> <asp:repeater id="repeater1" runat="server" datasourceid="sqldatasource1"> <itemtemplate> <div id='h<

ios - Retaining the same tab bar in a new view -

i newbie regards ios development, need regarding matter. have been working in program in have slide bar tab bar. however, when click item slide bar, goes new view , tab bar disappears. tried embedding new view navigation controller , adding push segue between tab bar controller new view.. still, tab bar won't show up. what retain or use existing tab bar in new view? so, visible new view. thanks! appreciated. :) first, gotta perform push, not modal. then, use method hidesbottombarwhenpushed in view controller pushes, should trick. if not, maybe can clarify more or post code :)

telecommunication - Mobile Value Added Service, MVAS protocols -

i study construction of mobile networks , began study mvas. not find specific iinformation protocols used in vas or mvas. i understood main protocol using sms - smpp.   great if made ​​a list of protocols used, or links read more information protocols used. there such list; published 3gpp in specification ts 23.039. 3gpp (earlier etsi) specified gsm, umts , lte systems, standard protocols of interfaces. did not specify standard protocol between short message service centres , external messaging servers though. instead, left open, , each smsc developer specified own protocol. , successful smsc developer irish company called aldiscon, later taken on logica. developed short message peer-to-peer protocol (smpp), , published open standard, reason why it's used today.

amazon web services - Auto Scaling Group launch config changes -

i wonder if there simple way or best practices on how ensure instances within autoscaling group have been launched current launch-configuration of autoscaling group. to give example, imagine auto-scaling group called www-asg 4 desired instances running webservers behind elb. want change ami or userdata used start instances of auto-scaling group. create new launch configuration www-cfg-v2 , update www-asg use that. # create new launch config as-create-launch-config www-cfg-v2 \ --image-id 'ami-xxxxxxxx' --instance-type m1.small \ --group web,asg-www --user-data "..." # update asg use new config as-update-auto-scaling-group www-asg --launch-configuration www-cfg-v2 by 4 running instances still use old launch configuration. wonder if there simple way of replacing running instances new instances enforce new configuration, but ensure minimum of instances kept running. my current way of achieving follows.. save list of current running instances g