Skip to content

Instantly share code, notes, and snippets.

View icodeforlove's full-sized avatar
:octocat:
Indefinitely In Bangkok

Chad icodeforlove

:octocat:
Indefinitely In Bangkok
View GitHub Profile
@icodeforlove
icodeforlove / overlay.jsx
Created July 25, 2014 10:14
react directive-like overlay
var WrappedOverlayExample = React.createClass({
handleClose: function () {
this.refs.overlay.fadeOut(function () {
this.props.onClose();
}.bind(this));
},
render: function () {
return (
<Overlay ref="overlay">
@icodeforlove
icodeforlove / RCSPreprocess.js
Last active August 29, 2015 14:04
playing around with the idea of vars and inline js
// this would add variable support and inline JS support
var RCSPreprocess = (function () {
var varRegExp = /\$([a-z0-9-_]+)/ig,
singleVarRegExp = /\$([a-z0-9-_]+)/i,
codeRegExp = /\$\{([\s\S]+)\}\$/igm,
varDefineRegExp = /\$([a-z0-9-_]+): ([^;]+);/ig,
rcsVars = {};
function process (example) {
example = example.replace(varDefineRegExp, function (string, name, value) {
@component TestName {
width: 100px;
height: 100px;
.state-test & {
width: 223px;
}
.header {
width: 100px;
/* Component CSS for TestName */
.app-component.app-test-name {
width: 100px;
height: 100px;
}
.app-component.app-test-name.app-test-name_state-test {
width: 223px;
}
.app-component.app-test-name .app-test-name_header {
width: 100px;
// Easing.easeInElastic(percent);
var Easing = {
// t: current time, b: begInnIng value, c: change In value, d: duration
swing: function (x, t, b, c, d) {
if (arguments.length === 1) {
t = arguments[0]; x = 0; b = 0; c = 1; d = 1;
}
return Easing.easeOutQuad(x, t, b, c, d);
},
@icodeforlove
icodeforlove / usd_exchange_rates.sql
Created March 1, 2015 11:27
historic usd to GBP/EUR rates
INSERT INTO usd_exchange_rates (`date`,`EUR`,`GBP`) VALUES
("1975-01-02 00:00:00", 0.7633, 0.4281),("1975-01-03 00:00:00", 0.7585, 0.4271),("1975-01-06 00:00:00", 0.7524, 0.4252),("1975-01-07 00:00:00", 0.751, 0.4246),("1975-01-08 00:00:00", 0.7554, 0.4258),("1975-01-09 00:00:00", 0.7551, 0.4256),("1975-01-10 00:00:00", 0.7534, 0.4251),("1975-01-13 00:00:00", 0.754, 0.4248),("1975-01-14 00:00:00", 0.7588, 0.4261),("1975-01-15 00:00:00", 0.7562, 0.4254),("1975-01-16 00:00:00", 0.7546, 0.4249),("1975-01-17 00:00:00", 0.7537, 0.4249),("1975-01-20 00:00:00", 0.7503, 0.4244),("1975-01-21 00:00:00", 0.7487, 0.4231),("1975-01-22 00:00:00", 0.7416, 0.4183),("1975-01-23 00:00:00", 0.7404, 0.42),("1975-01-24 00:00:00", 0.7384, 0.4196),("1975-01-27 00:00:00", 0.7324, 0.4168),("1975-01-28 00:00:00", 0.7357, 0.4197),("1975-01-29 00:00:00", 0.7429, 0.4218),("1975-01-30 00:00:00", 0.7418, 0.421),("1975-01-31 00:00:00", 0.7423, 0.42),("1975-02-03 00:00:00", 0.745, 0.4211),("1975-02-04 00:00:00", 0.7518, 0.4221),("1975-02-05
(function () {
function TaskWorker ($config) {
this.worker = this.createWorker();
this.worker.addEventListener('message', this.onWorkerMessage.bind(this));
this.tasks = [];
this.onTaskComplete = $config.onTaskComplete;
this.lastTaskTimestamp = null;
}
TaskWorker.prototype = {
functionToObjectURL: function (func) {
@icodeforlove
icodeforlove / rgb.js
Created July 15, 2015 20:30
String rgb support for console
String.prototype.rgb = function (r, g, b) {
return "\x1b[38;2;" + r + ";" + g + ";" + b + "m" + this + "\x1b[0m";
};
var userActivity = [
1.2,
2,
0,
74,
6,
3,
0
];
import flash.display.Loader;
import flash.display.LoaderInfo;
/*
* pull a var from the embed and return it, if there is no param matching the name
* return a default value
*/
function getEmbedParam(name:String, defaultValue:String):String
{
var parameters:Object = LoaderInfo(stage.loaderInfo).parameters;