This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <assert.h> | |
#define CEILING(x,y) (((x) + (y) - 1) / (y)) | |
#define LEADINGBIT(r) ((sizeof(unsigned long int)*8) - __builtin_clzl(r)) | |
#define BITLAST(k,n) ((k) & ((1<<(n))-1)) // for geting subset of bits | |
#define BITSUBSET(k,m,n) BITLAST((k)>>(m),((n)-(m))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ `date +%w` -eq 6 ]; then | |
echo "Enjoy your life. Do not work on Sunday!" | |
exit 1 | |
fi | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
files=$(git diff-index --name-only HEAD | grep -P '\.js$') | |
for file in $files; do | |
esvalidate $file | |
if [ $? -eq 1 ]; then | |
echo "Syntax error: $file" | |
exit 1 | |
fi | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <math.h> | |
#ifndef M_PI | |
# define M_PI 3.1415926535 | |
#endif | |
#ifndef ABS | |
# define ABS(a) ((a) > 0 ? (a) : -(a)) | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Stack-based Douglas Peucker line simplification routine | |
returned is a reduced GLatLng array | |
After code by Dr. Gary J. Robinson, | |
Environmental Systems Science Centre, | |
University of Reading, Reading, UK | |
*/ | |
function GDouglasPeucker (source, kink) | |
/* source[] Input coordinates in GLatLngs */ | |
/* kink in metres, kinks above this depth kept */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Generate keys on local machine: `ssh-keygen` | |
2. Create `~/.ssh` directory on remote machine | |
3. Copy `local:~/.ssh/id_rsa.pub` to `user@remote:~/.ssh/authorized_keys` | |
method a) `ssh-copy-id -i ~/.ssh/id_rsa.pub user@host` | |
method b) cat .ssh/id_rsa.pub | ssh user@host 'cat >> .ssh/authorized_keys' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a=a|b, b=a^b, a=a^b | |
//aka | |
a=a+b, b=a-b, a=a-b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define likely(x) __builtin_expect((x),1) | |
#define unlikely(x) __builtin_expect((x),0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static inline uint64_t kbi_popcount64(uint64_t y) // standard popcount; from wikipedia | |
{ | |
y -= ((y >> 1) & 0x5555555555555555ull); | |
y = (y & 0x3333333333333333ull) + (y >> 2 & 0x3333333333333333ull); | |
return ((y + (y >> 4)) & 0xf0f0f0f0f0f0f0full) * 0x101010101010101ull >> 56; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <time.h> | |
int main() | |
{ | |
clock_t tic = clock(); | |
my_expensive_function_which_can_spawn_threads(); | |
clock_t toc = clock(); |