Dynamically allocate array of 2 pointers to functions returning int and taking no argument.
|
int test1() {printf "test1"; return 0;} int test2() {printf "test2"; return 0;} int main(int argc, char* argv[]) { int (*(*f_arr))() = malloc(sizeof(int (*)()) * 2); f_arr[0] = &test1; f_arr[1] = &test1; } |
Statically allocate array of 2 pointers to functions returning int and taking no argument.
|
int test1() {printf "test1"; return 0;} int test2() {printf "test2"; return 0;} int main(int argc, char* argv[]) { int (*f_arr[2])() = {test1, test2}; return testRunner(f_arr, 2); } |
… Read more »
Command eval is builtin shell builtin, part of POSIX. In practice, eval takes a string as argument and evaluates that string as if you would typed it if it was… Read more »
One of my most favorite C# snippet is following oneliner useful when quick debugging or checking on something is needed.
|
Newtonsoft.Json.JsonConvert.SerializeObject(new {foo = "bar")) |
Which returns String containing JSON representation of arbitrary C#… Read more »
TLDR Make sure MySQL is discoverable from your path Run:
|
mysql -uroot -ppassword < createDatabase.sql > outputCreate.log |
to run createDatabase.sql as user root with password password More detailed version Recently I was working on a little… Read more »
Recently I encountered following problem in C#.
|
System.InvalidOperationException was unhandled by user code Message: The 'Id' property on 'SomeDAO' could not be set to a 'System.Decimal' value. You must set this property to a non-null value of type 'System.Int64'. |
This error is pretty obvious in certain context, but if you don’t read it carefully enough, in some situations you might get… Read more »
All keys are strings (unlike in Python) Even though this is a basic, got me really hard times debugging my code after writing a lot in python, where this statement… Read more »
In almost every programming language there some sort of math module with various trigonometric functions including functions called atan and atan2. atan(x,y) Now everybody knows atan, it’s just inverse tangent,… Read more »
Simple script to calculate circular / directional mean of some angular data. Samples is assumed to be in range of <0,2PI>. To get more information about mean of circular quantities,… Read more »
Recently I’ve coded couple of modules for my data visualisation project and I wanted to ensure all my methods and classes are working as they should. I had this structure… Read more »
I can’t think of how many times have just wondered about how awesome the python’s list comprehensions are. I found them extremely handy while I was preprocessing data for my… Read more »