Skip to content

Instantly share code, notes, and snippets.

@thomasweng15
thomasweng15 / audiotoolserror.txt
Created June 3, 2013 03:04
Audiotools Unsupported File Error
thomas@thomas-PBL21:~/Code/Pi-Voice$ python listen.py
Recording...
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
Cannot connect to server socket err = No such file or directory
Cannot connect to server socket
jack server is not running or cannot be started
* recording
@thomasweng15
thomasweng15 / Ordinal.rb
Created April 15, 2014 01:04
rubocop is the worst thing ever
# encoding: utf-8
# authors: jason liu and thomas weng
# NORMAL
class Normal
attr_accessor :result
def num_ord(n)
if (n.is_a? String) || n.nil? || Integer(n) != n || n <= 0
@result = nil
@thomasweng15
thomasweng15 / delayed_jobs shift submission error
Created April 23, 2014 06:04
delayed_jobs shift submission error
ActiveRecord::StatementInvalid in ReportsController#update
Mysql2::Error: Table 'db/shifts_development.delayed_jobs' doesn't exist: SHOW FULL FIELDS FROM `delayed_jobs`
Rails.root: /home/thomas/shifts
Application Trace | Framework Trace | Full Trace
activerecord (3.2.13) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `query'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `block in execute'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
@thomasweng15
thomasweng15 / gist:e3230e81fd7ceadf54c6
Created August 8, 2014 06:24
mockup for changing every href on a webpage using jQuery
$(document).ready(function () {
$('a[href]').each(function () {
var src = $(this).attr('href');
// check that the origin is the same
// if (window.location.origin != origin)
//query parameter handling needs to be more safe than this
src += "?knowledgepreview=true";
@thomasweng15
thomasweng15 / gist:9c498de6c772aee0930b
Created December 23, 2014 04:31
Attempt at changing colorframes for the Kinect using openCV
//this.colorBuffer.Lock();
//colorFrame.CopyConvertedFrameDataToIntPtr(
// this.colorBuffer.BackBuffer,
// (uint)(colorFrameDescription.Width * colorFrameDescription.Height * 4),
// ColorImageFormat.Bgra);
//this.colorBuffer.AddDirtyRect(new Int32Rect(0, 0, this.colorBuffer.PixelWidth, this.colorBuffer.PixelHeight));
//this.colorBuffer.Unlock();
@thomasweng15
thomasweng15 / gist:681564d548b5a34445c4
Created January 14, 2015 03:07
Saving a properties string in a Visual Studio project
String toSave = "";
for (int i = 0; i < numObjects; i++)
{
String coords = this.objColorCoords[i].row + "," + this.objColorCoords[i].col;
toSave += coords + ";";
}
toSave = toSave.Substring(0, toSave.Length - 1);
Properties.Settings.Default.ObjectThresholdValues = toSave;
Properties.Settings.Default.Save();
"" General
set number " Show line numbers
set showmatch " Highlight matching brace
set noerrorbells " Use visual bell (no beeping)
set novisualbell
set hlsearch " Highlight all search results
set gdefault " Always sub all matches in a line
set incsearch " Searches for strings incrementally
@thomasweng15
thomasweng15 / gist:b3e84805be1c832fd534
Created January 14, 2015 23:58
Converting byte array back into iplimage
BitmapSource bitmap = BitmapSource.Create(
640, 480,
96, 96, pf, null,
buffer, rawStride);
// save image to stream
MemoryStream ms = new MemoryStream();
BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bitmap));
encoder.Save(ms);
@thomasweng15
thomasweng15 / gist:6e4ea6ada9f7d68ef8d7
Created January 21, 2015 17:12
two ways to copy a System.Drawing.Bitmap into a 1D rgb pixel array.
Bitmap bmpOrig = new Bitmap(@"C:\Users\Thomas\Desktop\picture.png");
Bitmap bmpResized = new Bitmap(bmpOrig, new System.Drawing.Size(640, 480));
Bitmap bmp = bmpResized.Clone(new Rectangle(0,0,bmpResized.Width,bmpResized.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb);
//byte[] bytes = new byte[bmp.Width * bmp.Height * 3];
//int index = 0;
//for (int i = 0; i < bmp.Height; i++)
//{
// for (int j = 0; j < bmp.Width; j++)
// {
// System.Drawing.Color color = bmp.GetPixel(j,i);
@thomasweng15
thomasweng15 / .vimrc
Last active April 12, 2018 02:59
.vimrc
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required