Skip to content

Instantly share code, notes, and snippets.

@rvill
rvill / SplitFolder
Created April 13, 2015 20:56
split folder into n items
ls -1 | sort -n | head -2000 | xargs -i mv "{}" /dest/folder/
@rvill
rvill / FullPath
Created April 13, 2015 20:36
Get full path of all files in directory, output to path.txt
find `pwd` -maxdepth 1 > path.txt
@rvill
rvill / UDID
Created January 16, 2015 04:05
get iOS device UDID without xcode or itunes, using linux cmd line
lsusb -v 2> /dev/null | grep -e "Apple Inc" -A 2
@rvill
rvill / opencv - flags
Created November 24, 2014 03:43
opencv - check for parameter names
>>> import cv2
>>> flags = [i for i in dir(cv2) if i.startswith('COLOR_')]
>>> print flags
@rvill
rvill / compile opencv g++
Created November 19, 2014 01:15
compile opencv g++
g++ -o test_1 test_1.cpp `pkg-config opencv --cflags --libs`
@rvill
rvill / mount cmd
Created November 13, 2014 17:11
usb pen drive unrecognized by ubuntu 14.04
sudo mount /dev/sdb1 /mnt
@rvill
rvill / regex flickr url id in python
Last active August 29, 2015 14:08
Grab image id from flickr URL with regular expression in python
url = 'https://farm4.staticflickr.com/3943/15386021170_c2607cb639_z.jpg'
#\d+ match digits; \D+ match a non-digit which is "/" after the 1st 4 digits; (d\+) get the last set of digits, in group(6)
re.search(r'^(https://)?(farm4\.)?(staticflickr\.com/)?(\d+)?(\D+)(\d+)',url).group(6)
#returns 15386021170
@rvill
rvill / nvidia drivers on linux
Created September 12, 2014 01:58
run ./nvidiaxxx.run with no check flag
Add the --no-x-check flag in terminal:
sudo ./NVIDIAxxxx.run --no-x-check
@rvill
rvill / mount_root
Created September 12, 2014 01:06
mount / on linux recovery
mount -o remount, rw /
@rvill
rvill / HTTPheaderObjC
Created August 5, 2014 17:09
Set HTTP headers in objective c
NSURL *theURL = [NSURL URLWithString:@"yourURL"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:theURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:20.0f];
//Specify method of request(Get or Post)
[theRequest setHTTPMethod:@"GET"];
//Pass some default parameter(like content-type etc.)
[theRequest setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[theRequest setValue:@"application/json; charset=UTF-8" forHTTPHeaderField:@"Content-Type"];