Skip to content

Instantly share code, notes, and snippets.

View jywarren's full-sized avatar

Jeffrey Warren jywarren

View GitHub Profile
@Sreyanth
Sreyanth / AutoCalib.js
Last active August 29, 2015 14:07
AutoCalib code for SWB.
attempt_autocalibrate = function(min_required_intensity) {
//The following two are copied from end; before calling attempt_autocalib
flotoptions.grid.markings = []
$W.plot = $.plot($("#graph"),$W.data,flotoptions);
var max_limit = 5
//min_required_intensity = 20
var max_green = -1000 // We need to find the maximum value of G first
@n00neimp0rtant
n00neimp0rtant / gist:9515611
Last active March 14, 2024 06:30
simple squash without rebase
## within current branch, squashes all commits that are ahead of master down into one
## useful if you merged with upstream in the middle of your commits (rebase could get very ugly if this is the case)
## commit any working changes on branch "mybranchname", then...
git checkout master
git checkout -b mybranchname_temp
git merge --squash mybranchname
git commit -am "Message describing all squashed commits"
git branch -m mybranchname mybranchname_unsquashed
git branch -m mybranchname
@natevw
natevw / webrtc-dataconnection.html
Last active May 8, 2016 20:52
WebRTC data connection testing, works in both Chrome and Firefox but not expected to between until they gain interop (and this only communicates within a single page anyway…) You'll likely need to host "somewhere" (e.g. `python -m SimpleHTTPServer`) rather than opening file directly.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>WebRTC p2p data</title>
<script src="https://webrtc-samples.googlecode.com/svn/trunk/apprtc/js/adapter.js"></script>
</head>
<body>
Testing WebRTC connection.
@bendangelo
bendangelo / PaperclipStringFile
Created May 23, 2012 15:47
Paperclip string to file
module Paperclip
#converts a string into a file for paperclip to save
# useage
# self.avatar = Paperclip::string_to_file('bob.png', 'image/png', 'BASE64 here')
def self.string_to_file(name, type, data)
image = StringIO.new(data)
image.class.class_eval { attr_accessor :original_filename, :content_type }
image.original_filename = name
image.content_type = type
@leommoore
leommoore / font-Awesome.markdown
Last active October 13, 2017 03:30
Using Font-Awesome with Rails 3.1 using CSS

#Using Font-Awesome with Rails 3.1 using CSS

  1. Download font-awesome from https://github.com/FortAwesome/Font-Awesome

  2. Put the font folder in the app/assets. I renamed the folder from font to fonts to make it clearer

  3. Add config.assets.paths << "#{Rails.root}/app/assets/fonts" to config/application.rb. This is to include the apps/assets/fonts folder in the asset pipeline

  4. Put the font-awesome.css file in the app/assets/stylesheets folder

@lrvick
lrvick / bitcolor.js
Created March 18, 2012 20:02
Javascript functions for doing fast binary/hex/RGB color conversions using bitwise operations.
// convert 0..255 R,G,B values to binary string
RGBToBin = function(r,g,b){
var bin = r << 16 | g << 8 | b;
return (function(h){
return new Array(25-h.length).join("0")+h
})(bin.toString(2))
}
// convert 0..255 R,G,B values to a hexidecimal color string
RGBToHex = function(r,g,b){
@DGuidi
DGuidi / leaflet.google.js
Created March 7, 2012 12:27
leaflet+google integration
/*
* Here the 'inspiration': http://goo.gl/OKL9A
* Adapted from: http://psha.org.ru/leaflet/Google.js
* Demo: http://psha.org.ru/leaflet/bel.html
* This code works well with jquerymobile:
* the original code maintain a div.height of 0 for the internal google container
* REMARKS: this
* NOTE: jQuery required!
*/
@Pretz
Pretz / generate.py
Created February 8, 2012 21:04
CSV to WAV: Needed a way to convert a list of numbers in a CSV file to a wave audio file. Go python.
#!/usr/bin/python
import wave
import numpy
import struct
import sys
import csv
from scikits.samplerate import resample
def write_wav(data, filename, framerate, amplitude):
@jywarren
jywarren / ArduinoTemperatureFlashlight.ino
Created December 12, 2011 22:32 — forked from kylemcdonald/ArduinoTemperatureFlashlight.ino
Thermal Flashlight RGB LED + Melexis 90614
#include <i2cmaster.h>
#include "Wire.h"
#include "BlinkM_funcs.h"
const float lowReading = 75;
const float highReading = 110;
const int blinkm_addr = 0;
const unsigned char separatorCharacter = 255;
void setup(){
@kvorion
kvorion / naivebayes.py
Created December 7, 2010 03:34
naive bayes implementation
#Author: Krishnamurthy Koduvayur Viswanathan
from __future__ import division
import collections
import math
class Model:
def __init__(self, arffFile):
self.trainingFile = arffFile
self.features = {} #all feature names and their possible values (including the class label)