Skip to content

Instantly share code, notes, and snippets.

View jywarren's full-sized avatar

Jeffrey Warren jywarren

View GitHub Profile
@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
@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.
@n00neimp0rtant
n00neimp0rtant / gist:9515611
Last active April 6, 2025 23:25
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
@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
@mathdoodle
mathdoodle / doodle.json
Last active August 28, 2023 20:31
Warping with WebGL
{
"uuid": "f27b5235-e517-4fc9-8467-1270bbac7bbf",
"description": "Warping with WebGL",
"dependencies": {},
"operatorOverloading": false
}
@jywarren
jywarren / database.yml
Last active August 26, 2015 19:13
c9.io setup scripts
# Warning: The contents of the database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql2
username: <username>
password:
database: publiclab_test
encoding: utf8
pool: 5
anonymous
anonymous / ant.js
Created September 15, 2015 14:48
An ant script saved from https://github.com/jywarren/antfarm
// set basic attributes here;
// "this" means this ant you're editing now
this.speed = 1;
this.color = 'red';
this.height = 40;
this.width = 40;
// runs every frame:
onRun = function () {
@oliyh
oliyh / image-url-to-data-uri.js
Created November 7, 2015 22:17
Convert an image url to a data URI without canvas
// hard won knowledge from http://stackoverflow.com/questions/20035615/using-raw-image-data-from-ajax-request-for-data-uri
var xmlHTTP = xhr.XMLHttpRequest();
xmlHTTP.open('GET', url, true);
xmlHTTP.responseType = 'arraybuffer';
xmlHTTP.onload = function(e) {
var arr = new Uint8Array(this.response);
var raw = String.fromCharCode.apply(null,arr);
var b64 = base64.encode(raw);
var dataURL="data:image/png;base64," + b64;
};
@montanaflynn
montanaflynn / youtube-cors-proxy.js
Created August 1, 2016 17:40
YouTube cors proxy
var express = require('express');
var request = require('request');
var app = express();
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
@sagarpreet-chadha
sagarpreet-chadha / sagarpreet_chadha.md
Last active August 22, 2018 09:04
GSOC 2018 Work Product - Sagarpreet Chadha

GSoC with PublicLab

Finally, the GSoC coding period is coming to an end as I finish up my project. In this post I aim to summarize all of the work I have done during the past months.

GSoC 2018 Work Product - Sagarpreet Chadha