Skip to content

Instantly share code, notes, and snippets.

View richard-to's full-sized avatar

Richard To richard-to

View GitHub Profile
@richard-to
richard-to / csv_to_sqlite3.py
Last active August 29, 2015 14:01
Random snippet to insert csv into sqlite3. Mainly just want to remember date time conversion to unix timestamp and associated issues with timezones, ie strptime seems to use local timezone and then mktime will be utc
import csv
import time
import sqlite3
from datetime import datetime
readings = []
with open('data.csv', 'r') as csvfile:
data = csv.reader(csvfile)
next(data)
for line in data:
@richard-to
richard-to / sb16.py
Created April 26, 2014 07:45
Random code for a class project
import logging
import socket
import SocketServer
import sys
import time
import threading
from ftplib import FTP
from os import listdir, remove, rename, stat
from os.path import isfile, join, splitext, isfile
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "opencv2/imgproc/imgproc.hpp"
@richard-to
richard-to / wip_sift.cpp
Created April 8, 2014 00:04
Partial/Buggy/Incorrect implementation of SIFT that I'm working on
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
@richard-to
richard-to / gaussian_blur.cpp
Created April 7, 2014 12:16
Basic implementations of gaussian blur, scaling image using linear interpolation, and shrinking an image by simple resampling
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
@richard-to
richard-to / x11_screen_grab.cpp
Created April 7, 2014 10:30
X11 Example code for grabbing screenshots of window and sending key events
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <X11/Xlib.h>
@richard-to
richard-to / basic_sd.ino
Last active August 29, 2015 13:57
Some Arduino sample code for SD card, LinkSprite Sim900 shield, and EEPROM
#include <SD.h>
#include <String.h>
const int CS_PIN = 10;
char BACKUP_FILE[] = "backup.txt";
char PENDING_FILE[] = "pending.txt";
void setup()
{
@richard-to
richard-to / naive_hough.cpp
Last active August 29, 2015 13:57
Rough implementation of hough transform with sobel. Needs more work.
#include <fcntl.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <iostream>
#include <sstream>
@richard-to
richard-to / dct.js
Created March 13, 2014 08:32
Very slow dct (n^4) implementation on a single 8x8 macroblock. Example data based on example in Wikipedia article on JPEG
var midpoint = 128;
var data = [
[52, 55, 61, 66, 70, 61, 64, 73],
[63, 59, 55, 90, 109, 85, 69, 72],
[62, 59, 68, 113, 144, 104, 66, 73],
[63, 58, 71, 122, 154, 106, 70, 69],
[67, 61, 68, 104, 126, 88, 68, 70],
[79, 65, 60, 70, 77, 68, 58, 75],
[85, 71, 64, 59, 55, 61, 65, 83],
@richard-to
richard-to / data.js
Last active August 29, 2015 13:57
Experimenting with modified Huffman codes to compress sprite image data
var waterData = [55,56,56,56,56,56,56,57,55,56,56,56,56,55,55,56,56,56,57,56,56,56,56,56,55,55,56,57,57,56,56,56,55,55,55,56,56,56,56,57,55,56,56,56,56,56,55,56,56,56,57,56,56,56,56,56,55,55,56,56,57,56,56,56,56,56,55,56,56,56,56,56,57,55,56,56,56,56,55,55,57,57,57,56,56,56,56,55,55,56,56,56,57,56,56,56,56,56,56,55,55,57,56,56,57,55,56,56,56,55,55,55,57,56,56,57,57,57,56,55,56,56,56,57,57,56,56,56,57,57,57,57,55,56,57,57,57,55,56,56,56,55,56,57,56,56,56,56,56,57,57,55,57,57,57,57,57,57,57,57,56,56,56,57,56,55,56,56,56,55,57,56,55,56,57,57,56,56,56,56,56,55,55,55,55,55,55,56,56,56,56,57,56,56,56,57,56,55,55,55,55,56,57,56,55,55,55,55,55,56,56,56,55,55,57,56,56,56,55,55,56,56,56,57,55,55,55,55,55,55,56,56,55,55,55,56,55,55,56,56,55,55,56,55,55,56,57,56,56,56,56,55,55,55,55,55,56,55,55,56,56,57,57,56,56,56,55,55,55,57,56,56,56,55,55,55,57,57,57,56,56,56,56,55,56,56,56,56,56,55,55,56,56,56,57,56,56,56,57,55,57,57,57,57,56,56,55,57,57,56,56,56,56,56,56,55,56,56,56,56,56,56,55,56,56,56,57,57,57,57,57,55,57,56,56,57