Skip to content

Instantly share code, notes, and snippets.

@omerk
omerk / gist:9353095
Created March 4, 2014 18:53
vim cheatsheet

Open/Edit/Close

cd <folder> change to folder

r <file> insert file below cursor

r !<cmd> insert command output below cursor

o begin new line, insert

Keybase proof

I hereby claim:

  • I am omerk on github.
  • I am omerk (https://keybase.io/omerk) on keybase.
  • I have a public key whose fingerprint is 8E24 2EDC BB06 6A3E 9707 3943 229F 528E CE28 FC66

To claim this, I am signing this object:

@omerk
omerk / spotify_playing.sh
Created October 3, 2011 16:32
Spotify 'Now Playing'
#!/bin/bash
pgrep spotify 1>/dev/null 2>&1
if [ $? != 0 ]; then
exit 1
fi
xwininfo -root -tree | grep "Spotify -" | sed 's/[ ]*0x[0-9a-f]* "Spotify - \(.*\)": ("spotify" "Spotify").*/\1/'
@omerk
omerk / gist:2385330
Created April 14, 2012 15:47
Raspberry-Pi Unixbench Score
pi@raspberrypi:~/UnixBench$ ./Run
make all
make[1]: Entering directory `/home/pi/UnixBench'
Checking distribution of files
./pgms exists
./src exists
./testdir exists
./tmp exists
./results exists
make[1]: Leaving directory `/home/pi/UnixBench'
@omerk
omerk / gist:3380077
Created August 17, 2012 15:51
C function pointer demo
#include <stdio.h>
int add(int a, int b)
{
return a + b;
}
int addtimestwo(int (*fp)(int,int), int a, int b)
{
return (*fp)(a, b) * 2;
@omerk
omerk / gist:4645120
Last active December 11, 2015 18:58
Playing with the ADC on a PIC10F222
#include <xc.h>
#include <stdint.h>
#define _XTAL_FREQ 4000000 // required for __delay_ms()
#define DELAY 1000
#define THRESHOLD 100
#pragma config MCLRE=OFF, MCPU=OFF, CP=OFF, WDTE=OFF, IOSCFS=4MHZ
void
@omerk
omerk / gist:5061474
Last active December 14, 2015 08:59
pdfextract ()
{
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] ; then
echo "Usage: pdfextract <source doc> <first page> <last page>."
else
OUTPDF=$1_p$2-$3.pdf
pdftops $1 - | psselect -p$2-$3 | ps2pdf14 - $OUTPDF
echo "Output saved as: $OUTPDF"
fi
}
#include <stdio.h>
int
main (void)
{
FILE *f;
char name[255];
if( !(f = popen("uname -n", "r")) ){
perror("Can't execute cmd");
@omerk
omerk / gist:5162182
Created March 14, 2013 15:15
strtok() example
#include <stdio.h>
#include <string.h>
int
main (void) {
char test_string[] = "machinename.local";
char* result = NULL;
result = strtok(test_string, ".");