Questions Tagged with #C

C is a general-purpose computer programming language used for operating systems, libraries, games and other high performance work. This tag should be used with general questions concerning the C language, as defined in the ISO 9899 standard (the latest version, 9899:2018, unless otherwise specified—also tag version-specific requests with c99, c89, etc). C is distinct from C++ and it should not be combined with the C++ tag absent a rational reason.

Redirecting exec output to a buffer or file

I'm writing a C program where I fork(), exec(), and wait(). I'd like to take the output of the program I exec'ed to write it to file or buffer. For example, if I exec ls I want to write file1 file2..

How do I execute a Shell built-in command with a C function?

I would like to execute the Linux command "pwd" through a C language function like execv(). The issue is that there isn't an executable file called "pwd" and I'm unable to execute "echo $PWD", since ..

#pragma pack effect

I was wondering if someone could explain to me what the #pragma pack preprocessor statement does, and more importantly, why one would want to use it. I checked out the MSDN page, which offered some i..

How do I link object files in C? Fails with "Undefined symbols for architecture x86_64"

So I'm trying trying to use a function defined in another C (file1.c) file in my file (file2.c). I'm including the header of file1 (file1.h) in order to do this. However, I keep getting the following..

What is a difference between unsigned int and signed int in C?

Consider these definitions: int x=5; int y=-5; unsigned int z=5; How are they stored in memory? Can anybody explain the bit representation of these in memory? Can int x=5 and int y=-5 have same bi..

printf formatting (%d versus %u)

What is difference between %d and %u when printing pointer addresses? For example: int a = 5; // check the memory address printf("memory address = %d\n", &a); // prints "memory address = -12" pr..

How to disable GCC warnings for a few lines of code

In Visual C++, it's possible to use #pragma warning (disable: ...). Also I found that in GCC you can override per file compiler flags. How can I do this for "next line", or with push/pop semantics aro..

For vs. while in C programming?

There are three loops in C: for, while, and do-while. What's the difference between them? For example, it seems nearly all while statements can be replaced by for statements, right? Then, what's the ..

Convert double/float to string

I need to convert a floating point number to an equivalent string in decimal (or other base). Conversion at first needs to be done in the format xE+0 where x is the floating point number. The idea I ..

Signed to unsigned conversion in C - is it always safe?

Suppose I have the following C code. unsigned int u = 1234; int i = -5678; unsigned int result = u + i; What implicit conversions are going on here, and is this code safe for all values of u and i..

What is the printf format specifier for bool?

Since ANSI C99 there is _Bool or bool via stdbool.h. But is there also a printf format specifier for bool? I mean something like in that pseudo code: bool x = true; printf("%B\n", x); which would ..

How to throw an exception in C?

I typed this into google but only found howtos in C++, how to do it in C?..

Graphical user interface Tutorial in C

I have a project in C language and the teacher ordered to make a Gui of project. I can only use C or C++ for the GUI part. Can anyone please suggest me Some easy open source Graphics Library Tutorial..

Copy struct to struct in C

I want to copy an identical struct into another and later on use it as a comparance to the first one. The thing is that my compiler gives me a warning when Im doing like this! Should I do it in anothe..

How to read string from keyboard using C?

I want to read a string entered by the user. I don't know the length of the string. As there are no strings in C I declared a pointer: char * word; and used scanf to read input from the keyboard: ..

When to use malloc for char pointers

I'm specifically focused on when to use malloc on char pointers char *ptr; ptr = "something"; ...code... ...code... ptr = "something else"; Would a malloc be in order for something as trivial as th..

strdup() - what does it do in C?

What is the purpose of the strdup() function in C?..

warning: assignment makes integer from pointer without a cast

When I declare a char * to a fixed string and reuse the pointer to point to another string /* initial declaration */ char *src = "abcdefghijklmnop"; ..... /* I get the "warning: assignment makes i..

C++ preprocessor __VA_ARGS__ number of arguments

Simple question for which I could not find answer on the net. In variadic argument macros, how to find the number of arguments? I am okay with boost preprocessor, if it has the solution. If it makes..

do { ... } while (0) — what is it good for?

Possible Duplicate: Why are there sometimes meaningless do/while and if/else statements in C/C++ macros? I've been seeing that expression for over 10 years now. I've been trying to think wh..

How do I list the symbols in a .so file

How do I list the symbols being exported from a .so file? If possible, I'd also like to know their source (e.g. if they are pulled in from a static library). I'm using gcc 4.0.2, if that makes a dif..

Do I cast the result of malloc?

In this question, someone suggested in a comment that I should not cast the result of malloc, i.e. int *sieve = malloc(sizeof(int) * length); rather than: int *sieve = (int *) malloc(sizeof(int) *..

What is the difference between const int*, const int * const, and int const *?

I always mess up how to use const int*, const int * const, and int const * correctly. Is there a set of rules defining what you can and cannot do? I want to know all the do's and all don'ts in terms ..

What does this GCC error "... relocation truncated to fit..." mean?

I am programming the host side of a host-accelerator system. The host runs on the PC under Ubuntu Linux and communicates with the embedded hardware via a USB connection. The communication is performed..

How to make child process die after parent exits?

Suppose I have a process which spawns exactly one child process. Now when the parent process exits for whatever reason (normally or abnormally, by kill, ^C, assert failure or anything else) I want the..

Why aren't programs written in Assembly more often?

It seems to be a mainstream opinion that assembly programming takes longer and is more difficult to program in than a higher level language such as C. Therefore it seems to be recommend or assumed tha..

Warning: X may be used uninitialized in this function

I am writing a custom "vector" struct. I do not understand why I'm getting a Warning: "one" may be used uninitialized here. This is my vector.h file #ifndef VECTOR_H #define VECTOR_H typedef struct..

How to Convert double to int in C?

double a; a = 3669.0; int b; b = a; I am getting 3668 in b, instead of 3669. How do I fix This problem? And if have 3559.8 like that also I want like 3559 not 3560...

How to convert a string to character array in c (or) how to extract a single char form string?

I need to convert a string to a char array in C; how can I do this? Or at least, how can I extract single chars from a string incrementally?..

How to split a string to 2 strings in C

I was wondering how you could take 1 string, split it into 2 with a delimiter, such as space, and assign the 2 parts to 2 separate strings. I've tried using strtok() but to no avail. ..

Why should we typedef a struct so often in C?

I have seen many programs consisting of structures like the one below typedef struct { int i; char k; } elem; elem user; Why is it needed so often? Any specific reason or applicable area?..

What is the difference between a static and const variable?

Can someone explain the difference between a static and const variable?..

Converting from signed char to unsigned char and back again?

I'm working with JNI and have an array of type jbyte, where jbyte is represented as an signed char i.e. ranging from -128 to 127. The jbytes represent image pixels. For image processing, we usually wa..

How to convert an int to string in C?

How do you convert an int (integer) to a string? I'm trying to make a function that converts the data of a struct into a string to save it in a file...

Proper way to empty a C-String

I've been working on a project in C that requires me to mess around with strings a lot. Normally, I do program in C++, so this is a bit different than just saying string.empty(). I'm wondering what ..

C library function to perform sort

Is there any library function available in C standard library to do sort? ..

How to read numbers separated by space using scanf

I want to read numbers(integer type) separated by spaces using scanf() function. I have read the following: C, reading multiple numbers from single input line (scanf?) how to read scanf with spaces ..

How can I do GUI programming in C?

I want to do Graphics programming in C. I had searched a lot about the compiler that provides a rich set of functions for doing GUI programming in C, but I couldn't find anything. Basically I want to..

char *array and char array[]

if I write this char *array = "One good thing about music"; I actually create an array? I mean it's the same like this? char array[] = {"One", "good", "thing", "about", "music"}; ..

Printing hexadecimal characters in C

I'm trying to read in a line of characters, then print out the hexadecimal equivalent of the characters. For example, if I have a string that is "0xc0 0xc0 abc123", where the first 2 characters are c..

Read .csv file in C

I have a .csv file : lp;imie;nazwisko;ulica;numer;kod;miejscowosc;telefon;email;data_ur 1;Jan;Kowalski;ul. Nowa;1a;11-234;Budry;123-123-456;[email protected];1980.05.13 2;Jerzy;Nowak;ul. Konopnicka;13a/3;00-..

Why does scanf() need "%lf" for doubles, when printf() is okay with just "%f"?

Why is it that scanf() needs the l in "%lf" when reading a double, when printf() can use "%f" regardless of whether its argument is a double or a float? Example code: double d; scanf("%lf", &d);..

clearing a char array c

I thought by setting the first element to a null would clear the entire contents of a char array. char my_custom_data[40] = "Hello!"; my_custom_data[0] = '\0'; However, this only sets the first ele..

Undefined reference to `sin`

I have the following code (stripped down to the bare basics for this question): #include<stdio.h> #include<math.h> double f1(double x) { double res = sin(x); return 0; } /* The ..

What does it mean to write to stdout in C?

Does a program that writes to "stdout" write to a file? the screen? I don't understand what it means to write to stdout...

How to draw text using only OpenGL methods?

I don't have the option to use but OpenGL methods (that is glxxx() methods). I need to draw text using gl methods only. After reading the red book, I understand that it is possible only through the gl..

The real difference between "int" and "unsigned int"

int: The 32-bit int data type can hold integer values in the range of -2,147,483,648 to 2,147,483,647. You may also refer to this data type as signed int or signed. unsigned int : The 32-bit uns..

How to convert an integer to a character array using C

I want to convert an integer number to a character array in C. Input: int num = 221234; The result is equivalent to: char arr[6]; arr[0] = '2'; arr[1] = '2'; arr[2] = '1'; arr[3] = '2'; arr[4] = '3';..

What is a "static" function in C?

The question was about plain c functions, not c++ static methods, as clarified in comments. I understand what a static variable is, but what is a static function? And why is it that if I declare a f..

Tokenizing strings in C

I have been trying to tokenize a string using SPACE as delimiter but it doesn't work. Does any one have suggestion on why it doesn't work? Edit: tokenizing using: strtok(string, " "); The code is ..

uint8_t vs unsigned char

What is the advantage of using uint8_t over unsigned char in C? I know that on almost every system uint8_t is just a typedef for unsigned char, so why use it?..

How do you implement a class in C?

Assuming I have to use C (no C++ or object oriented compilers) and I don't have dynamic memory allocation, what are some techniques I can use to implement a class, or a good approximation of a class? ..

Build a simple HTTP server in C

I need to build a simple HTTP server in C. Any guidance? Links? Samples?..

How to convert integer to char in C?

How to convert integer to char in C?..

Difference between "while" loop and "do while" loop

What is the difference between while loop and do while loop. I used to think both are completely same.Then I came across following piece of code: do { printf("Word length... "); ..

C: How to free nodes in the linked list?

How will I free the nodes allocated in another function? struct node { int data; struct node* next; }; struct node* buildList() { struct node* head = NULL; struct node* second = NULL..

The "backspace" escape character '\b': unexpected behavior?

So I'm finally reading through K&R, and I learned something within the first few pages, that there is a backspace escape character, \b. So I go to test it out, and there is some very odd behavior..

How to prevent scanf causing a buffer overflow in C?

I use this code: while ( scanf("%s", buf) == 1 ){ What would be the best way to prevent possible buffer overflow so that it can be passed strings of random lengths? I know I can limit the input s..

How to use EOF to run through a text file in C?

I have a text file that has strings on each line. I want to increment a number for each line in the text file, but when it reaches the end of the file it obviously needs to stop. I've tried doing some..

In C/C++ what's the simplest way to reverse the order of bits in a byte?

While there are multiple ways to reverse bit order in a byte, I'm curious as to what is the "simplest" for a developer to implement. And by reversing I mean: 1110 -> 0111 0010 -> 0100 This i..

segmentation fault : 11

I'm having a problem with some program, I have searched about segmentation faults, by I don't understand them quite well, the only thing I know is that presumably I am trying to access some memory I s..

What REALLY happens when you don't free after malloc?

This has been something that has bothered me for ages now. We are all taught in school (at least, I was) that you MUST free every pointer that is allocated. I'm a bit curious, though, about the real..

How to free memory from char array in C

I created a char array like so: char arr[3] = "bo"; How do I free the memory associated with array I named "arr"?..

How to get the string size in bytes?

As the title implies, my question is how to get the size of a string in C. Is it good to use sizeof if I've declared it (the string) in a function without malloc in it? Or, if I've declared it as a po..

C Linking Error: undefined reference to 'main'

I have read the other answers on this topic, and unfortunately they have not helped me. I am attempting to link several c programs together, and I am getting an error in response: $ gcc -o runexp.o s..

How to compile a static library in Linux?

I have a question: How to compile a static library in Linux with gcc, i.e. I need to compile my source code into a file named out.a. Is it sufficient to simply compile with the command gcc -o out.a ou..

How to correctly assign a new string value?

I'm trying to understand how to solve this trivial problem in C, in the cleanest/safest way. Here's my example: #include <stdio.h> int main(int argc, char *argv[]) { typedef struct { ..

How can I create C header files

I want to be able to create a collection of functions in a header file that I could #include in one of my C Programs...

How to initialize a struct in accordance with C programming language standards

I want to initialize a struct element, split in declaration and initialization. This is what I have: typedef struct MY_TYPE { bool flag; short int value; double stuff; } MY_TYPE; void function..

Difference between static, auto, global and local variable in the context of c and c++

I’ve a bit confusion about static, auto, global and local variables. Somewhere I read that a static variable can only be accessed within the function, but they still exist (remain in the memory) af..

Recursive mkdir() system call on Unix

After reading the mkdir(2) man page for the Unix system call with that name, it appears that the call doesn't create intermediate directories in a path, only the last directory in the path. Is there a..

Speed comparison with Project Euler: C vs Python vs Erlang vs Haskell

I have taken Problem #12 from Project Euler as a programming exercise and to compare my (surely not optimal) implementations in C, Python, Erlang and Haskell. In order to get some higher execution tim..

Convert char * to LPWSTR

I am trying to convert a program for multibyte character to Unicode. I have gone through the program and preceded the string literals with L so they look like L"string". This has worked but I am now..

Fastest way to check if a file exist using standard C++/C++11/C?

I would like to find the fastest way to check if a file exist in standard C++11, C++, or C. I have thousands of files and before doing something on them I need to check if all of them exist. What can ..

How to set up a cron job to run an executable every hour?

I need to set up a cron job that runs an executable compiled using gcc once every hour. I logged in as root and typed crontab -e Then I entered the following and saved the file. 0 * * * * /path_to..

C function that counts lines in file

When I try to run my program, I get the wrong number of lines printed. LINES: 0 This is the output although I have five lines in my .txt file Here is my program: #include<stdio.h> #include&..

Why does the C preprocessor interpret the word "linux" as the constant "1"?

Why does the C preprocessor in GCC interpret the word linux (small letters) as the constant 1? test.c: #include <stdio.h> int main(void) { int linux = 5; return 0; } Result of..

Struct memory layout in C

I have a C# background. I am very much a newbie to a low-level language like C. In C#, struct's memory is laid out by the compiler by default. The compiler can re-order data fields or pad additional ..

Why is C so fast, and why aren't other languages as fast or faster?

In listening to the StackOverflow podcast, the jab keeps coming up that "real programmers" write in C, and that C is so much faster because it's "close to the machine." Leaving the former assertion fo..

How do I check if an integer is even or odd?

How can I check if a given number is even or odd in C?..

Variably modified array at file scope

I want to create a constant static array to be used throughout my Objective-C implementation file similar to something like this at the top level of my ".m" file: static const int NUM_TYPES = 4; stat..

What is the newline character in the C language: \r or \n?

What is the newline character in C? I know that different OS have different line-ending characters, but they get translated into the C newline character. What is that character?..

Directly assigning values to C Pointers

I've just started learning C and I've been running some simple programs using MinGW for Windows to understand how pointers work. I tried the following: #include <stdio.h> int main(){ int *..

How to use nanosleep() in C? What are `tim.tv_sec` and `tim.tv_nsec`?

What is the use of tim.tv_sec and tim.tv_nsec in the following? How can I sleep execution for 500000 microseconds? #include <stdio.h> #include <time.h> int main() { struct timespec t..

What should be the sizeof(int) on a 64-bit machine?

Possible Duplicate: size of int, long, etc Does the size of an int depend on the compiler and/or processor? What decides the sizeof an integer? I'm using a 64-bit machine. $ uname -m x..

C Programming: How to read the whole file contents into a buffer

I want to write the full contents of a file into a buffer. The file actually only contains a string which i need to compare with a string. What would be the most efficient option which is portable ev..

Combining C++ and C - how does #ifdef __cplusplus work?

I'm working on a project that has a lot of legacy C code. We've started writing in C++, with the intent to eventually convert the legacy code, as well. I'm a little confused about how the C and C++ ..

How do function pointers in C work?

I had some experience lately with function pointers in C. So going on with the tradition of answering your own questions, I decided to make a small summary of the very basics, for those who need a qu..

C non-blocking keyboard input

I'm trying to write a program in C (on Linux) that loops until the user presses a key, but shouldn't require a keypress to continue each loop. Is there a simple way to do this? I figure I could possi..

How to convert a string to integer in C?

I am trying to find out if there is an alternative way of converting string to integer in C. I regularly pattern the following in my code. char s[] = "45"; int num = atoi(s); So, is there a bette..

What is the best free memory leak detector for a C/C++ program and its plug-in DLLs?

I have a .exe and many plug-in .dll modules that the .exe loads. (I have source for both.) A cross-platform (with source) solution would be ideal, but the platform can be narrowed to WinXP and Visual ..

Correct way to read a text file into a buffer in C?

I'm dealing with small text files that i want to read into a buffer while i process them, so i've come up with the following code: ... char source[1000000]; FILE *fp = fopen("TheFile.txt", "r"); if(..

When to use pthread_exit() and when to use pthread_join() in Linux?

I am new to pthreads, and I am trying to understand it. I saw some examples like the following. I could see that the main() is blocked by the API pthread_exit(), and I have seen examples where the m..

Difference between signed / unsigned char

So I know that the difference between a signed int and unsigned int is that a bit is used to signify if the number if positive or negative, but how does this apply to a char? How can a character be po..

How to use boolean datatype in C?

I was just writing code in C and it turns out it doesn't have a boolean/bool datatype. Is there any C library which I can include to give me the ability to return a boolean/bool datatype?..

lvalue required as left operand of assignment

Why am I getting lvalue required as left operand of assignment with a single string comparison? How can I fix this in C? if (strcmp("hello", "hello") = 0) Thanks!..

C: socket connection timeout

I have a simple program to check if a port is open, but I want to shorten the timeout length on the socket connection because the default is far too long. I'm not sure how to do this though. Here's th..

Using floats with sprintf() in embedded C

Guys, I want to know if float variables can be used in sprintf() function. Like, if we write: sprintf(str,"adc_read = %d \n",adc_read); where adc_read is an integer variable, it will store the str..

What is time(NULL) in C?

I learning about some basic C functions and have encountered time(NULL) in some manuals. What exactly does this mean?..

C multi-line macro: do/while(0) vs scope block

Possible Duplicates: What’s the use of do while(0) when we define a macro? Why are there sometimes meaningless do/while and if/else statements in C/C++ macros? do { … } while (0..

How to check if an excel cell is empty using Apache POI?

I am taking input from an excel sheet using Poi.jar and wanted to know how to check if a cell is empty or not. Right now I m using the below code. cell = myRow.getCell(3); if (cell != null) { ce..

Split a string using C++11

What would be easiest method to split a string using c++11? I've seen the method used by this post, but I feel that there ought to be a less verbose way of doing it using the new standard. Edit: I w..

Maintaining the final state at end of a CSS3 animation

I'm running an animation on some elements that are set to opacity: 0; in the CSS. The animation class is applied onClick, and, using keyframes, it changes the opacity from 0 to 1 (among other things)...

C++ initial value of reference to non-const must be an lvalue

I'm trying to send value into function using reference pointer but it gave me a completely non-obvious error to me #include "stdafx.h" #include <iostream> using namespace std; void test(float..

Close a div by clicking outside

I want to hide a div by clicking on the close link in it, or by clicking anywhere outside that div. I am trying following code, it opens and close the div by clicking close link properly, but if I ha..

Resize image in the wiki of GitHub using Markdown

I'm writing a wiki page on GitHub, and I'm using Markdown. My problem is that I'm putting a large image (this image is in its own repository) and I need resize it. I have tried different solutions,..

How to create Java gradle project

How to create Java Gradle project from command line? It should create standard maven folder layout like on the picture below. UPDATE: .1. From

Python - A keyboard command to stop infinite loop?

Possible Duplicate: Why can't I handle a KeyboardInterrupt in python? I was playing around with some Python code and created an infinite loop: y = 0 x = -4 itersLeft = x while(itersLe..

How to pass optional arguments to a method in C++?

How to pass optional arguments to a method in C++ ? Any code snippet.....

How to get the selected value from RadioButtonList?

I have a RadioButtonList on my page that is populated via Data Binding <asp:RadioButtonList ID="rb" runat="server"> </asp:RadioButtonList> <asp:Button Text="Submit" OnClick="submit" ru..

ASP.NET MVC3 - textarea with @Html.EditorFor

I have ASP.NET MVC3 app and I have also form for add news. When VS2010 created default view I have only text inputs for string data, but I want to have textarea for news text. How I can do it with Raz..

Iterate over model instance field names and values in template

I'm trying to create a basic template to display the selected instance's field values, along with their names. Think of it as just a standard output of the values of that instance in table format, wi..

Finding the type of an object in C++

I have a class A and another class that inherits from it, B. I am overriding a function that accepts an object of type A as a parameter, so I have to accept an A. However, I later call functions that ..

Java ElasticSearch None of the configured nodes are available

Just downloaded and installed elasticsearch 1.3.2 in past hour Opened IP tables to port 9200 and 9300:9400 Set my computer name and ip in /etc/hosts Head Module and Paramedic Installed and running ..

Android Studio cannot resolve R in imported project?

I'm trying the new Android Studio. I've exported a project from eclipse, using the build gradle option. I've then imported it in Android Studio. The file under gen has a j in a little red circl..

Bi-directional Map in Java?

I have a simple integer-to-string mapping in Java, but I need to be able to easily retrieve string from integer, and also integer from string. I've tried Map, but it can retrieve only string from inte..

Handling key-press events (F1-F12) using JavaScript and jQuery, cross-browser

I want to handle F1-F12 keys using JavaScript and jQuery. I am not sure what pitfalls there are to avoid, and I am not currently able to test implementations in any other browsers than Internet Explo..

Google Maps V3 - How to calculate the zoom level for a given bounds

I'm looking for a way to calculate the zoom level for a given bounds using the Google Maps V3 API, similar to getBoundsZoomLevel() in the V2 API. Here is what I want to do: // These are exact bounds..

PSEXEC, access denied errors

While I'm using PSEXEC.exe getting 'Access denied' error for remote systems. Any idea about how to solve this?..

Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive

I just installed vs 2010, followed by IIS in window 7. when building a website in .net framework 4.0 and convert this into application in IIS then its shows this error If i remove the targetFramew..

WordPress query single post by slug

For the moment when I want to show a single post without using a loop I use this: <?php $post_id = 54; $queried_post = get_post($post_id); echo $queried_post->post_title; ?> The problem is..

IF a == true OR b == true statement

I can't find a way to have TWIG interpret the following conditional statement: {% if a == true or b == true %} do stuff {% endif %} Am I missing something or it's not possible?..

Android soft keyboard covers EditText field

Is there a way to make the screen scroll to allow the text field to be seen?..

Spring Boot - Error creating bean with name 'dataSource' defined in class path resource

I have Spring Boot web application. It's centered around RESTful approach. All configuration seems in place but for some reason MainController fails to handle request. It results in 404 error. How to ..

Creating a .p12 file

Using openssl, I've created a private key as follows: openssl genrsa -out myKey.pem Then, to generate the csr demanded by the CA, I've executed the following: openssl req -new -key myKey.pem -out ..

How do I check particular attributes exist or not in XML?

Part of the XML content: <section name="Header"> <placeholder name="HeaderPane"></placeholder> </section> <section name="Middle" split="20"> <placeholder name="C..

Generate Row Serial Numbers in SQL Query

I have a customer transaction table. I need to create a query that includes a serial number pseudo column. The serial number should be automatically reset and start over from 1 upon change in custome..

How do you concatenate Lists in C#?

If I have: List<string> myList1; List<string> myList2; myList1 = getMeAList(); // Checked myList1, it contains 4 strings myList2 = getMeAnotherList(); // Checked myList2, it contains 6 ..

How to unit test abstract classes: extend with stubs?

I was wondering how to unit test abstract classes, and classes that extend abstract classes. Should I test the abstract class by extending it, stubbing out the abstract methods, and then test all the..

Value Change Listener to JTextField

I want the message box to appear immediately after the user changes the value in the textfield. Currently, I need to hit the enter key to get the message box to pop out. Is there anything wrong with m..

Checking Bash exit status of several commands efficiently

Is there something similar to pipefail for multiple commands, like a 'try' statement but within bash. I would like to do something like this: echo "trying stuff" try { command1 command2 c..

How to read and write into file using JavaScript?

Can anybody give some sample code to read and write a file using JavaScript?..

How to remove and clear all localStorage data

I need to clear all data i set into localStorage. By this, I mean completely reset localStorage to null when users remove their accounts. How can i do that with a simple function? I tried this: fu..

EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) on dispatch_semaphore_dispose

I am getting EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) on dispatch_semaphore_dispose but don't really know how to track down the root cause of this. My code makes use of dispatch_async, ..

How to set the title of UIButton as left alignment?

I need to display the email address from left side of a UIButton, but it is being positioned in the centre. Is there any way to set the alignment to the left side of a UIButton? This is my current ..

CMD: How do I recursively remove the "Hidden"-Attribute of files and directories

I can't find a command or simple batch of commands to recursively remove the "Hidden"-Attribute from files and directories. All commands like "attrib" and "for" seem to skip hidden files. E.g.: attri..

How to Inspect Element using Safari Browser

I am developing websites and creating applications. I want to know how to inspect an element through web browsers like safari. In normal Chrome, Firefox, Explorer or any other browsers, we will righ..

Can I set text box to readonly when using Html.TextBoxFor?

I have the following tag with a Html.TextBoxFor expression and I want the contents to be read only, is this possible? <%= Html.TextBoxFor(m => Model.Events.Subscribed[i].Action)%> ..

How to display text in pygame?

I can't figure out to display text in pygame. I know I can't use print like in regular python IDLE but i dont know how import pygame, sys from pygame.locals import * BLACK = ( 0, 0, 0) WHITE = (25..

Java recursive Fibonacci sequence

Please explain this simple code: public int fibonacci(int n) { if(n == 0) return 0; else if(n == 1) return 1; else return fibonacci(n - 1) + fibonacci(n - 2); } I'm ..

Cross origin requests are only supported for HTTP but it's not cross-domain

I'm using this code to make an AJAX request: $("#userBarSignup").click(function(){ $.get("C:/xampp/htdocs/webname/resources/templates/signup.php", {/*params*/}, function(response)..

SQL Server Service not available in service list after installation of SQL Server Management Studio

I have Windows 7 Home edition SP1 installed on my system, and downloaded SQL Server 2008 R2 Management Studio and got it installed. But when I try to connect via .\SQLEXPRESS, SSMS shows error A netw..

Trim a string in C

Briefly: I'm after the equivalent of .NET's String.Trim in C using the win32 and standard C api (compiling with MSVC2008 so I have access to all the C++ stuff if needed, but I am just trying to trim..

Object of class DateTime could not be converted to string

I have a table with string values in the format of Friday 20th April 2012 in a field called Film_Release I am looping through and i want to convert them in datetime and roll them out into another tab..

PHP Parse HTML code

Possible Duplicate: Best methods to parse HTML How can I parse HTML code held in a PHP variable if it something like: <h1>T1</h1>Lorem ipsum.<h1>T2</h1>The quick re..

HTML/CSS: Making two floating divs the same height

I have a little peculiar problem that I currently solve using a table, see below. Basically, I want to have two divs take up 100% of the available width, but only take up as much vertical space as ne..

Alert handling in Selenium WebDriver (selenium 2) with Java

I want to detect whether an alert is popped up or not. Currently I am using the following code: try { Alert alert = webDriver.switchTo().alert(); // check if alert exists ..

White space showing up on right side of page when background image should extend full length of page

Our webpage background images are having problems in FireFox as well as Safari in iOS on iPads/iPhones with white space showing up on the right side of the page. The background images extend fine on..

Making a div vertically scrollable using CSS

This _x000D_ _x000D_ <div id="" style="overflow:scroll; height:400px;">_x000D_ _x000D_ _x000D_ gives a div that the user can scroll in both in horizontally and vertically. How do I change it ..

What is the best way to give a C# auto-property an initial value?

How do you give a C# auto-property an initial value? I either use the constructor, or revert to the old syntax. Using the Constructor: class Person { public Person() { Name = "In..

How to delete a certain row from mysql table with same column values?

I have a problem with my queries in MySQL. My table has 4 columns and it looks something like this: id_users id_product quantity date 1 2 1 2013 1 ..

Error with multiple definitions of function

I am trying to relearn C++ after taking an intro course a few years ago and I’m having some basic problems. My current problem occurs when trying to use a friend function. Here is my code in 2 files..

Get a JSON object from a HTTP response

I want to get a JSON object from a Http get response: Here is my current code for the Http get: protected String doInBackground(String... params) { HttpClient client = new DefaultHttpClient(); ..

how to create 100% vertical line in css

I want to create a vertical line that cover whole page like this here is my code #menu { border-left: 1px solid black; height: 100%; } result show like this ..

Python error when trying to access list by index - "List indices must be integers, not str"

I have the following Python code : currentPlayers = query.getPlayers() for player in currentPlayers: return str(player['name'])+" "+str(player['score']) And I'm getting the following er..

How to normalize an array in NumPy to a unit vector?

I would like to convert a NumPy array to a unit vector. More specifically, I am looking for an equivalent version of this function def normalize(v): norm = np.linalg.norm(v) if norm == 0: ..

What is the difference between absolute and relative xpaths? Which is preferred in Selenium automation testing?

What is the difference between absolute and relative xpaths? Which is preferred in Selenium automation testing? I am preparing test scripts using Selenium and Robot framework...

Choose newline character in Notepad++

I notice that when I load a text file, Notepad++ will recognize and use whatever the newline character in that file is, \n or \r\n. Is there some option where I can select which to use in a new docum..

How to make responsive table

I have a table to represent some data in my html page. I'm trying to make this table as responsive. How can I do this? Here is the Demo...

The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication

The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state. What is this error all about, and how would I go ab..

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in

struggling with my web design assignment. I've been following a tutorial to add in a search feature for my website, but I've been getting the following error: Warning: mysqli_num_rows() expects param..

How to export all data from table to an insertable sql format?

I have a Table (call it A_table) in a database (call it A_db) in Microsoft SQL Server Management Studio, and there are 10 rows. I have another database (call it B_db), and it has a Table (call it B_t..

sudo service mongodb restart gives "unrecognized service error" in ubuntu 14.0.4

I just installed mongoDB on ubuntu 14.0.4. I tried to start the shell but I'm getting a connection refused error. me@medev:/etc/init.d$ mongo MongoDB shell version: 2.6.5 connecting to: test 2014-1..

"This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded"

I'm getting the error: "This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded." I have a .NET 4.0 dll project that is being called by a .NET 2.0 project. I..

java- reset list iterator to first element of the list

I need to know how to "reset" LinkedList iterator to its first element. For example: LinkedList<String> list; Iterator iter=list.listIterator;;; Over and over again..

How do I change the UUID of a virtual disk?

I am trying to create a new virtual machine with Oracle VirtualBox, using an already-existing hard disk. When I try to select the existing hard disk file, a .vhd file, it displays an error saying the ..

Get unicode value of a character

Is there any way in Java so that I can get Unicode equivalent of any character? e.g. Suppose a method getUnicode(char c). A call getUnicode('÷') should return \u00f7...

Command-line tool for finding out who is locking a file

I would like to know who is locking a file (win32). I know about WhoLockMe, but I would like a command-line tool which does more or less the same thing. I also looked at this question, but it seems o..

Get button click inside UITableViewCell

I have a view controller with a table view and a separate nib for the table cell template. The cell template has some buttons. I want to access the button click along with the index of the cell clicke..

javascript variable reference/alias

Is it possible in javascript to assign an alias/reference to a local var someway? I mean something C-like: function foo() { var x = 1; var y = &x; y++; alert(x); // prints 2 } = EDIT ..

How to uninstall/upgrade Angular CLI?

When I try to create a new project with Angular CLI, with: ng n app I get this error: fs.js:640 return, stringToFlags(flags), mode); ..

How to set up gradle and android studio to do release build?

I want to build android app and start signing it. For that I need to have Release version of apk. Google documentation suggests only Eclipse and ant ways to have release builds: http://developer.andr..

Check if an image is loaded (no errors) with jQuery

I'm using JavaScript with the jQuery library to manipulate image thumbnails contained in a unordered list. When the image is loaded it does one thing, when an error occurs it does something else. I'm ..

Get specific ArrayList item

public static ArrayList mainList = someList; How can I get a specific item from this ArrayList? mainList[3]?..

Content Type text/xml; charset=utf-8 was not supported by service

I have a problem with a WCF service. I have a console application and I need to consume the service without using app.config, so I had to set the endpoint, etc. by code. I do have a service reference ..

Reload content in modal (twitter bootstrap)

I'm using twitter bootstrap's modal popup. <div id="myModal" class="modal hide fade in"> <div class="modal-header"> <a class="close" data-dismiss="modal">×</a> ..

When to use Hadoop, HBase, Hive and Pig?

What are the benefits of using either Hadoop or HBase or Hive ? From my understanding, HBase avoids using map-reduce and has a column oriented storage on top of HDFS. Hive is a sql-like interface for..

Uncaught Error: SECURITY_ERR: DOM Exception 18 when I try to set a cookie

I get the following error in Chrome's developer tools window when I try to set a cookie using this jQuery plugin: Uncaught Error: SECURITY_ERR: DOM Exception 18 What does this error mean and how..

Python ValueError: too many values to unpack

I am getting that exception from this code: class Transaction: def __init__ (self): self.materials = {} def add_material (self, m): self.materials[m.type + m.purity] = m ..

How do I parse a URL into hostname and path in javascript?

I would like to take a string var a = "" and process it into an object such that a.hostname == "" and a.pathname == "/aa/bb" ..

Remove Unnamed columns in pandas dataframe

I have a data file from columns A-G like below but when I am reading it with pd.read_csv('data.csv') it prints an extra unnamed column at the end for no reason. colA ColB colC colD colE ..

fatal: does not appear to be a git repository

Why am I getting this error when my git repository url is correct? jitendra@JITENDRA-PC /c/mySite (master) $ git push beanstalk master fatal: '[email protected]/gittest.git' does not appear ..

Where to find 64 bit version of chromedriver.exe for Selenium WebDriver?

Can anybody tell where I can find 64 bit version of chromedriver.exe? I tried it with 32bit also but it doesn't call main method...

How to check if another instance of my shell script is running

GNU bash, version 1.14.7(1) I have a script is called "" I have to check this from script only... inside it I have written following statement status=`ps -efww | grep -w "" | grep..

How to implement a simple scenario the OO way

After starting to read a book on OO programming, I am attempting to make my android app more OO. However I am stumped on a simple scenario. I have a Book object, which can have many say Chapter objec..

How do I capture the output of a script if it is being ran by the task scheduler?

Using Windows Server 2008, how do I go about capturing the output of a script that is being ran with the windows task scheduler? I'm testing a rather long custom printing batch-script, and for debugg..

set dropdown value by text using jquery

I have a dropdown as: <select id="HowYouKnow" > <option value="1">FRIEND</option> <option value="2">GOOGLE</option> <option value="3">AGENT</option><..

Is there an arraylist in Javascript?

I have a bunch of things I want to add into an array, and I don't know what the size of the array will be beforehand. Can I do something similar to the c# arraylist in javascript, and do myArray.Add(o..

How can you print multiple variables inside a string using printf?

I want to find the maximum value of two numbers, and print it. I want to print all three numbers. I am using the following code. #include<stdio.h> #include<conio.h> main() { //clrscr..

Why do I need 'b' to encode a string with Base64?

Following this python example, I encode a string as Base64 with: >>> import base64 >>> encoded = base64.b64encode(b'data to be encoded') >>> encoded b'ZGF0YSB0byBiZSBlbmNvZ..

Simple post to Web Api

I'm trying to get a post request to work with the web api. Following is my api controller. public class WebsController : ApiController { [HttpPost] public void PostOne(string id) { } ..

How can I change the color of my prompt in zsh (different from normal text)?

To recognize better the start and the end of output on a commandline, I want to change the color of my prompt, so that it is visibly different from the programs output. As I use zsh, can anyone give m..

Counting array elements in Python

How can I count the number of elements in an array, because contrary to logic array.count(string) does not count all the elements in the array, it just searches for the number of occurrences of string..

How I can filter a Datatable?

I use a DataTable with Information about Users and I want search a user or a list of users in this DataTable. I try it butit don't work :( Here is my c# code: public DataTable GetEntriesBySearch(s..

Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=

I recently upgraded my n-tier solution from .NET 3.5 vs 2008 to 4.5 visual studio 2012. Every thing went fine apart from crystal reports and I had to install new runtime crystal reports for visual stu..

Programmatically set image to UIImageView with Xcode 6.1/Swift

I'm trying to set UIImageView programmatically in Xcode 6.1: @IBOutlet weak var bgImage: UIImageView! var image : UIImage = UIImage(named:"afternoon")! bgImage = UIImageView(image: image)

How do I subtract minutes from a date in javascript?

How can I translate this pseudo code into working js [don't worry about where the end date comes from except that it's a valid javascript date]. var myEndDateTime = somedate; //somedate is a valid j..

What is http multipart request?

I have been writing iPhone applications for some time now, sending data to server, receiving data (via HTTP protocol), without thinking too much about it. Mostly I am theoretically familiar with proce..

Change text from "Submit" on input tag

I have a tag, <input type="submit" class="like"/>. I want to have the text inside the button say "Like", but right now, it says "Submit". class="like" is the CSS of the button, by the way...

File path to resource in our war/WEB-INF folder?

I've got a file in my war/WEB-INF folder of my app engine project. I read in the FAQs that you can read a file from there in a servlet context. I don't know how to form the path to the resource though..

Android lollipop change navigation bar color

In my app I need to change the bottom navigation bar color. I watched many post but cant find with the solution. I am using appCompat library. v21/styles.xml <style name="AppTheme" parent="Them..

$(document).on("click"... not working?

Is there a well-known mistake I could be making here? I've got a script that's using .on() because an element is dynamically generated, and it isn't working. Just to test it out, I replaced the se..

Create a unique number with javascript time

I need to generate unique id numbers on the fly using javascript. In the past, I've done this by creating a number using time. The number would be made up of the four digit year, two digit month, two..

How to select specific columns in laravel eloquent

lets say I have 7 columns in table, and I want to select only two of them, something like this SELECT `name`,`surname` FROM `table` WHERE `id` = '1'; In laravel eloquent model it may looks like thi..

Add data to JSONObject

I'm trying to figure out how to add the following data to my json object. Could someone show me how to do this. Website Example $(document).ready(function() { $('#example').dataTable( { "aoCo..

How to install a Notepad++ plugin offline?

I am trying to install a Notepad++ plugin from Plugins -> Plugin Manager, but my office firewall is restricting its download. Is there any alternate way to download plugin offline?..

Android add placeholder text to EditText

How can I add a placeholder text to EditText in the class that isn't in the XML? I have the following EditText in my code which will be shown in alertdialog: final EditText name = new EditText(t..

UITableView, Separator color where to set?

I have added a UITableView in IB and set the "delegate" and "datasource" and all is working well. What I wanted to do next was change the separator color, but the only way I could find to do this was ..

Excel: last character/string match in a string

Is there an efficient way to identify the last character/string match in a string using base functions? I.e. not the last character/string of the string, but the position of a character/string's ..

How to get first record in each group using Linq

Considering the following records: Id F1 F2 F3 ------------------------------------------------- 1 Nima 1990 10 2 Nim..

Parse JSON in C#

I'm trying to parse some JSON data from the Google AJAX Search API. I have this URL and I'd like to break it down so that the results are displayed. I've currently written this code, but I'm pretty lo..

List all column except for one in R

Possible Duplicate: Drop Columns R Data frame Let's say I have a dataframe with column c1, c2, c3. I want to list just c1 and c2. How do I do that? I've tried: head(data[column!="c3"]) h..

How to configure Glassfish Server in Eclipse manually

I have GlassFish server3.1.2.2 pre installed on my machine. Which I want to use in my Eclipse Luna How do I manually configure it to use in Eclipse? When I tried using Eclipse Market Place i got an ..

Matplotlib color according to class labels

I have two vectors, one with values and one with class labels like 1,2,3 etc. I would like to plot all the points that belong to class 1 in red, to class 2 in blue, to class 3 in green etc. How can ..

How can I create a marquee effect?

I'm creating a marquee effect with CSS3 animation. _x000D_ _x000D_ #caption {_x000D_ position: fixed;_x000D_ bottom: 0;_x000D_ left: 0;_x000D_ font-size: 20px;_x000D_ line-height:..

How do I append text to a file?

What is the easiest way to append text to a file in Linux? I had a look at this question, but the accepted answer uses an additional program (sed) I'm sure there should be an easier way with echo or ..

How do I enable saving of filled-in fields on a PDF form?

Some PDF forms can be saved, including all filled-in field data: Some others can not be saved, and all filled-in field data are lost: How do I enable saving of filled-in fields on my PDF form?..

How to have the cp command create any necessary folders for copying a file to a destination

When copying a file using cp to a folder that may or may not exist, how do I get cp to create the folder if necessary? Here is what I have tried: [root@file nutch-0.9]# cp -f urls-resume /nosuchdire..

Text file with 0D 0D 0A line breaks

A customer is sending me a .csv file where the line breaks are made up of the sequence 0xD 0xD 0xA. As far as I know line breaks are either 0xA from Mac or Unix or 0xD 0xA from Windows. Is the 0xD 0x..

Loop Through All Subfolders Using VBA

I'm looking for a VBA script that will loop through all subfolders of a specified folder. When I say all subfolders, I mean each folder inside the specified folder, and each folder inside of that, and..

Is it possible to use jQuery to read meta tags

Is it possible to use jQuery to read meta tags. If so do you know what the basic structure of the code will be, or have links to any tutorials...

What is Join() in jQuery?

What is Join() in jquery? for example: var newText = $("p").text().split(" ").join("</span> <span>"); ..

JavaScript override methods

Let's say you have the below code: function A() { function modify() { x = 300; y = 400; } var c = new C(); } function B() { function modify(){ x = 3000; ..

Developing C# on Linux

I'd like to know if there are effective and open source tools to develop C# applications on Linux (Ubuntu). In particular, I have to develop Windows Forms applications. I know about the Mono project,..

Resolve Git merge conflicts in favor of their changes during a pull

How do I resolve a git merge conflict in favor of pulled changes? Basically I need to remove all conflicting changes from a working tree without having to go through all of the conflicts with a git ..

How can I rollback an UPDATE query in SQL server 2005?

How can I rollback an UPDATE query in SQL server 2005? I need to do this in SQL, not through code...

Setting up PostgreSQL ODBC on Windows

I have the latest 64 bit version of PostgreSQL. I am running Win 7 64 bit. I had installed the ODBC driver (via the initial installer) when I installed PG, and upgraded it to the latest version from h..

How to get Javascript Select box's selected text

This things works perfectly <select name="selectbox" onchange="alert(this.value)"> But I want to select the text. I tried in this way <select name="selectbox" onchange="alert(this.text)"..

Navigation drawer: How do I set the selected item at startup?

My code works perfectly: every time an item in Navigation Drawer is clicked the item is selected. Of course I want to start the app with a default fragment (home), but Navigation Drawer doesn't have ..

Row numbers in query result using Microsoft Access

I always use this query in sql server to get Row number in a table: SELECT * FROM (SELECT *, Row_number() OVER( ORDER BY [myidentitycolumn]) RowID..

Regular expression for a hexadecimal number?

How do I create a regular expression that detects hexadecimal numbers in a text? For example, ‘0x0f4’, ‘0acdadecf822eeff32aca5830e438cb54aa722e3’, and ‘8BADF00D’...

What is "String args[]"? parameter in main method Java

I'm just beginning to write programs in Java. What does the following Java code mean? public static void main(String[] args) What is String[] args? When would you use these args? Source code an..

How to do case insensitive search in Vim

I'd like to search for an upper case word, for example COPYRIGHT in a file. I tried performing a search like: /copyright/i # Doesn't work but it doesn't work. I know that in Perl, if I give the..

complex if statement in python

I need to realize a complex if-elif-else statement in Python but I don't get it working. The elif line I need has to check a variable for this conditions: 80, 443 or 1024-65535 inclusive I tried ..

How can I erase all inline styles with javascript and leave only the styles specified in the css style sheet?

If I have the following in my html: <div style="height:300px; width:300px; background-color:#ffffff;"></div> And this in my css style sheet: div { width:100px; height:100px; ..

Find unused npm packages in package.json

Is there a way to determine if you have packages in your package.json file that are no longer needed? For instance, when trying out a package and later commenting or deleting code, but forgetting to..

How to change active class while click to another link in bootstrap use jquery?

I have a html as sidebar, and use Bootstrap. <ul class="nav nav-list"> <li class="active"><a href="/">Link 1</a></li> <li><a href="/link2">Link 2<..

Using HeapDumpOnOutOfMemoryError parameter for heap dump for JBoss

I was told I can add the -XX:+HeapDumpOnOutOfMemoryError parameter to my JVM start up options to my JBoss start up script to get a heap dump when we get an out of memory error in our application. I w..

Eclipse Error: "Failed to connect to remote VM"

I’m getting the following error when I start Debug from the Eclipse IDE. Message: “Failed to connect to remote VM. Connection Refused” What could be the reason?..

Get the length of a String

How do you get the length of a String? For example, I have a variable defined like: var test1: String = "Scott" However, I can't seem to find a length method on the string...

How do I show the changes which have been staged?

I staged a few changes to be committed; how can I see the diff of all files which are staged for the next commit? I'm aware of git status, but I'd like to see the actual diffs - not just the names of ..

What do the terms "CPU bound" and "I/O bound" mean?

What do the terms "CPU bound" and "I/O bound" mean?..

Difference between thread's context class loader and normal classloader

What is the difference between a thread's context class loader and a normal class loader? That is, if Thread.currentThread().getContextClassLoader() and getClass().getClassLoader() return different c..

Change background color of R plot

All right, let's say I have the following plot. df = data.frame(date=c(rep(2008:2013, by=1)), value=c(303,407,538,696,881,1094)) barplot(df$value, main="TITLE", col="gray", ylab="Peo..

How do I get HTTP Request body content in Laravel?

I am making an API with Laravel 5 and I'm testing it with PHPUnit. I need to test legacy functionality for compatibility, which is an XML POST. As of right now, my first test looks like: public funct..

foreach loop in angularjs

I was going through the forEach loop in AngularJS. There are few points that I did not understood about it. What is the use of the iterator function? Is there any way to go without it? What is the s..

1114 (HY000): The table is full

I'm trying to add a row to an InnoDB table with a simply query: INSERT INTO zip_codes (zip_code, city) VALUES ('90210', 'Beverly Hills'); But when I attempt this query, I get the following: ERR..

Get a UTC timestamp

How can I get the current UTC timestamp in JavaScript? I want to do this so I can send timestamps from the client-side that are independent of their timezone...

What is the difference between x86 and x64

What is the difference between x86 and x64 binaries here, we would like to download binaries for Windows 7, Ubuntu 12.04 (32 bit options)..

How can I implement prepend and append with regular JavaScript?

How can I implement prepend and append with regular JavaScript without using jQuery?..

pass JSON to HTTP POST Request

I'm trying to make a HTTP POST request to the google QPX Express API [1] using nodejs and request [2]. My code looks as follows: // create http request client to consume the QPX API var requ..

Difference between JE/JNE and JZ/JNZ

In x86 assembly code, are JE and JNE exactly the same as JZ and JNZ?..

Calculating the area under a curve given a set of coordinates, without knowing the function

I have one list of 100 numbers as height for Y axis, and as length for X axis: 1 to 100 with a constant step of 5. I need to calculate the Area that it is included by the curve of the (x,y) points, a..

How to call Base Class's __init__ method from the child class?

If I have a python class as: class BaseClass(object): #code and the init function of the base class And then I define a child class such as: class ChildClass(BaseClass): #here I want to call the i..

Play audio with Python

How can I play audio (it would be like a 1 second sound) from a Python script? It would be best if it was platform independent, but firstly it needs to work on a Mac. I know I could just execute the..

Convert Python dictionary to JSON array

Currently I have this dictionary, printed using pprint: {'AlarmExTempHum': '\x00\x00\x00\x00\x00\x00\x00\x00', 'AlarmIn': 0, 'AlarmOut': '\x00\x00', 'AlarmRain': 0, 'AlarmSoilLeaf': '\x00\x..

How to enable native resolution for apps on iPhone 6 and 6 Plus?

Xcode 6 GM now includes simulators for iPhone 6 and 6 Plus, and by default they run apps in a scaled mode. To enable the new screen size I tried adding [email protected] which seems to do a part of..

C++ - Decimal to binary converting

I wrote a 'simple' (it took me 30 minutes) program that converts decimal number to binary. I am SURE that there's a lot simpler way so can you show me? Here's the code: #include <iostream> #inc..

How to customize the background/border colors of a grouped table view cell?

I would like to customize both the background and the border color of a grouped-style UITableView. I was able to customize the background color by using the following: tableView.contentView.backgrou..

How can I trigger another job from a jenkins pipeline (jenkinsfile) with GitHub Org Plugin?

How can I trigger build of another job from inside the Jenkinsfile? I assume that this job is another repository under the same github organization, one that already has its own Jenkins file. I als..

fork: retry: Resource temporarily unavailable

I tried installing Intel MPI Benchmark on my computer and I got this error: fork: retry: Resource temporarily unavailable Then I received this error again when I ran ls and top command. What is ca..

How do you change the colour of each category within a highcharts column chart?

I have have a column chart which has a number of categories, each with a single data point (e.g. like this one). Is it possible to change the colour of the bar for each category? i.e. so each bar woul..

Call an activity method from a fragment

Trying to call a method in my activity from a fragment. I want the fragment to give the method data and to get the data when the method return. I want to achieve similar to call on a static method, bu..

How can I force gradle to redownload dependencies?

How can I tell gradle to redownload dependencies from repositories?..

Bash: Syntax error: redirection unexpected

I do this in a script: read direc <<< $(basename `pwd`) and I get: Syntax error: redirection unexpected in an ubuntu machine /bin/bash --version GNU bash, version 4.0.33(1)-release (x8..

How to sort an ArrayList?

I have a List of doubles in java and I want to sort ArrayList in descending order. Input ArrayList is as below: List<Double> testList = new ArrayList(); testList.add(0.5); testList.add(0.2); ..

Start systemd service after specific service?

I have a general question. How does one start a systemd unit *.service after a particular *.service has started successfully? More specific question is, how do I start website.service only after mong..

How can I change UIButton title color?

I create a button programmatically.......... button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown]; [..

Visual Studio Community 2015 expiration date

I have downloaded the Visual Studio Community 2015 (free version) and I don't see when the expiration date is. I have tried to see the expiration date at Help Menu -> About Microsoft Visual Studio an..

MySQL - Meaning of "PRIMARY KEY", "UNIQUE KEY" and "KEY" when used together while creating a table

Can anyone explain about the purpose of PRIMARY KEY, UNIQUE KEY and KEY, if it is put together in a single CREATE TABLE statement in MySQL? CREATE TABLE IF NOT EXISTS `tmp` ( `id` int(11) NOT NULL ..

PHP strtotime +1 month adding an extra month

I have a simple variable that adds one month to today: $endOfCycle = date("Y-m", strtotime("+1 month")); Today is January 2013, so I would expect to get back 2013-02 but I'm getting 2013-03 instead..

How to read an external local JSON file in JavaScript?

I have saved a JSON file in my local system and created a JavaScript file in order to read the JSON file and print data out. Here is the JSON file: {"resource":"A","literals&q..

How to fix Python Numpy/Pandas installation?

I would like to install Python Pandas library (0.8.1) on Mac OS X 10.6.8. This library needs Numpy>=1.6. I tried this $ sudo easy_install pandas Searching for pandas Reading

Best way to select random rows PostgreSQL

I want a random selection of rows in PostgreSQL, I tried this: select * from table where random() < 0.01; But some other recommend this: select * from table order by random() limit 1000; I ha..

Batch Extract path and filename from a variable

How can I extract path and filename from a variable? Setlocal EnableDelayedExpansion set file=C:\Users\l72rugschiri\Desktop\fs.cfg I want to do that without using any function or any GOTO. is it po..

Can pandas automatically recognize dates?

Today I was positively surprised by the fact that while reading data from a data file (for example) pandas is able to recognize types of values: df = pandas.read_csv('test.dat', delimiter=r"\s+", nam..

How to Force New Google Spreadsheets to refresh and recalculate?

There were some codes written for this purpose but with the new add-ons they are no longer applicable...

jQuery .search() to any string

I saw this code snippet: $("ul li").text().search(new RegExp("sometext", "i")); and wanted to know if this can be extended to any string? I want to accomplish the following, but it dosen't work: ..

H.264 file size for 1 hr of HD video

I'm looking for an order of magnitude estimate for expected on-disk file size for 1 hour of H.264 encoded HD video transcoded from HDV (HD on a MiniDV tape). I want to archive approximately 100 hours ..

Excel VBA Run Time Error '424' object required

I am totally new in VBA and coding in general, am trying to get data from cells from the same workbook (get framework path ...) and then to start application (QTP) and run tests. I am getting this er..

How to search a specific value in all tables (PostgreSQL)?

Is it possible to search every column of every table for a particular value in PostgreSQL? A similar question is available here for Oracle. ..

ORA-06550: line 1, column 7 (PL/SQL: Statement ignored) Error

I am getting following error for the stored procedure and not able to understand the issue (must be from db side) While googling, I found similar issues but couldn't get the solution. Can any one help..

How to read request body in an core webapi controller?

I'm trying to read the request body in the OnActionExecuting method, but I always get null for the body. var request = context.HttpContext.Request; var stream = new StreamReader(request.Body); var bod..

What are .a and .so files?

I'm currently trying to port a C application to AIX and am getting confused. What are .a and .so files and how are they used when building/running an application?..

How can I use jQuery to move a div across the screen

I need to make multiple divs move from right to left across the screen and stop when it gets to the edge. I have been playing with jQuery lately, and it seem like what I want can be done using that. ..

Unable to find the requested .Net Framework Data Provider. It may not be installed. - when following mvc3 tutorial

I am following the ASP.NET MVC 3 Music store application tutorial but I keep getting stuck in part 4: It keeps telling me that I do not have th..

How to clear all <div>s’ contents inside a parent <div>?

I have a div <div id="masterdiv"> which has several child <div>s. Example: <div id="masterdiv"> <div id="childdiv1" /> <div id="childdiv2" /> <div id="childdiv..

Java Generics With a Class & an Interface - Together

I want to have a Class object, but I want to force whatever class it represents to extend class A and implement interface B. I can do: Class<? extends ClassA> Or: Class<? extends Interfa..

How do I break out of a loop in Scala?

How do I break out a loop? var largest=0 for(i<-999 to 1 by -1) { for (j<-i to 1 by -1) { val product=i*j if (largest>product) // I want to break out here ..

How do you read scanf until EOF in C?

I have this but once it reaches the supposed EOF it just repeats the loop and scanf again. int main(void) { char words[16]; while(scanf("%15s", words) == 1) printf("%s\n",..

Iterating through all the cells in Excel VBA or VSTO 2005

I need to simply go through all the cells in a Excel Spreadsheet and check the values in the cells. The cells may contain text, numbers or be blank. I am not very familiar / comfortable working with..

How to get table cells evenly spaced?

I'm trying to create a page with a number of static html tables on them. What do I need to do to get them to display each column the same size as each other column in the table? The HTML is as foll..

Purpose of ESI & EDI registers?

What is the actual purpose and use of the EDI & ESI registers in assembler? I know they are used for string operations for one thing. Can someone also give an example?..

Spark - SELECT WHERE or filtering?

What's the difference between selecting with a where clause and filtering in Spark? Are there any use cases in which one is more appropriate than the other one? When do I use DataFrame newdf = df...

from list of integers, get number closest to a given value

Given a list of integers, I want to find which number is the closest to a number I give in input: >>> myList = [4, 1, 88, 44, 3] >>> myNumber = 5 >>> takeClosest(myList, my..

Use jQuery to hide a DIV when the user clicks outside of it

I am using this code: $('body').click(function() { $('.form_wrapper').hide(); }); $('.form_wrapper').click(function(event){ event.stopPropagation(); }); And this HTML: <div class="form_w..

How do you input command line arguments in IntelliJ IDEA?

I usually input command line arguments in Eclipse via run configuration. But I don't know how do achieve the same task in IntelliJ IDEA...

Installing and Running MongoDB on OSX

If someone can provide some insights here I would GREATLY appreciate it. I am new to MongoDB, and (relatively) new to the command line. I had a express/node.js app running on MongoDB locally succe..

How to solve privileges issues when restore PostgreSQL Database

I have dumped a clean, no owner backup for Postgres Database with the command pg_dump sample_database -O -c -U Later, when I restore the database with psql -d sample_database -U app_name However,..

Splitting a Java String by the pipe symbol using split("|")

The Java official documentation states: The string "boo:and:foo", for example, yields the following results with these expressions Regex Result : { "boo", "and", "foo" }" And that's the way ..