Skip to content

Instantly share code, notes, and snippets.

View jkosoy's full-sized avatar

Jamie Kosoy jkosoy

View GitHub Profile
@jkosoy
jkosoy / gist:4657510
Created January 28, 2013 17:43
SCSS Responsive Mixin
// breakpoints
$break-small: 400px;
$break-large: 1024px;
@mixin respond-to($media) {
@if $media == handhelds {
@media only screen and (max-width: $break-small) { @content; }
}
@else if $media == medium-screens {
@media only screen and (min-width: $break-small + 1) and (max-width: $break-large - 1) { @content; }
@jkosoy
jkosoy / gist:4708253
Created February 4, 2013 17:44
openFrameworks MD5 Encryption
// .h
#include "Poco/MD5Engine.h"
#include "Poco/DigestStream.h"
#include "Poco/StreamCopier.h"
using Poco::DigestEngine;
using Poco::MD5Engine;
using Poco::DigestOutputStream;
using Poco::StreamCopier;
@jkosoy
jkosoy / ExampleDispatcher.pde
Last active December 14, 2015 00:39
Processing example of event dispatching.
class ExampleDispatcher {
private Object _listener;
public void setListener(Object obj) {
_listener = obj;
}
public void dispatchBasic() {
try {
Method callback = _listener.getClass().getMethod("handleBasicEvent");
@jkosoy
jkosoy / testApp.cpp
Last active December 14, 2015 07:09
ofImage to ofBuffer not working... why?
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
ofImage foo;
foo.loadImage("walrus.jpg");
ofPixels px;
px.setFromPixels(foo.getPixels(), foo.width, foo.height, foo.getPixelsRef().getImageType());
@jkosoy
jkosoy / index.html
Created March 22, 2013 18:56
A CodePen by Adam. Tear-able Cloth - Javascript cloth simulation.
<canvas id = "c" > </canvas>
<p>
Tear the cloth with your mouse.<br><br>
Right click and drag to cut the cloth.<br><br>
Reduce physics_accuracy if it's laggy, increase it for a better effect.
</p>
@jkosoy
jkosoy / index.html
Created March 22, 2013 18:56
A CodePen by Adam. Tear-able Cloth - Javascript cloth simulation.
<canvas id = "c" > </canvas>
<p>
Tear the cloth with your mouse.<br><br>
Right click and drag to cut the cloth.<br><br>
Reduce physics_accuracy if it's laggy, increase it for a better effect.
</p>
@jkosoy
jkosoy / ready.js
Created July 5, 2013 17:36
Standalone minified ready() function. Based on http://stackoverflow.com/questions/1206937/javascript-domready
var ready=function(){function i(){if(r.isReady){return}try{document.documentElement.doScroll("left")}catch(e){setTimeout(i,1);return}r.ready()}function s(t){r.bindReady();var n=r.type(t);e.done(t)}var e,t,n={};n["[object Boolean]"]="boolean";n["[object Number]"]="number";n["[object String]"]="string";n["[object Function]"]="function";n["[object Array]"]="array";n["[object Date]"]="date";n["[object RegExp]"]="regexp";n["[object Object]"]="object";var r={isReady:false,readyWait:1,holdReady:function(e){if(e){r.readyWait++}else{r.ready(true)}},ready:function(t){if(t===true&&!--r.readyWait||t!==true&&!r.isReady){if(!document.body){return setTimeout(r.ready,1)}r.isReady=true;if(t!==true&&--r.readyWait>0){return}e.resolveWith(document,[r])}},bindReady:function(){if(e){return}e=r._Deferred();if(document.readyState==="complete"){return setTimeout(r.ready,1)}if(document.addEventListener){document.addEventListener("DOMContentLoaded",t,false);window.addEventListener("load",r.ready,false)}else if(document.attachEvent){doc
@jkosoy
jkosoy / example.swift
Last active February 29, 2016 01:45
CFAAction+AHEasing example
let foo = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
foo.center = view.center
foo.layer.backgroundColor = UIColor.blueColor().CGColor
foo.layer.anchorPoint = CGPoint(x: 0.5, y: 0.5)
view.addSubview(foo)
foo.layer.opacity = 1.0
let fade = CFAAction.fade(fromValue: 0, toValue: 1, time: 2.5, curveType: CurveType.CurveTypeQuintic, easeType: EaseType.EaseTypeOut)
let scale = CFAAction.scale(fromValue: 1.0, toValue: 2.5, time: 1, curveType: CurveType.CurveTypeBounce, easeType: EaseType.EaseTypeOut)
let rotate = CFAAction.rotate(fromValue: 0.0, toValue: CGFloat( M_PI ), time: 1, curveType: CurveType.CurveTypeBounce, easeType: EaseType.EaseTypeOut)
@jkosoy
jkosoy / testApp.cpp
Created February 17, 2013 16:44
Example code to reproduce the error in ofxFastFboReader (https://github.com/satoruhiga/ofxFastFboReader) I discovered. Create an app, resize the window and press "s" to save a different file in your data directory. Sometimes this will work and other times it won't.
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
ofSetVerticalSync(true);
ofEnableAlphaBlending();
ofSetFrameRate(30);
counter = 0;
fboReader.setAsync(false);
@jkosoy
jkosoy / MainViewController.swift
Last active March 8, 2016 23:31
Fare Weather Prototype 010
//
// ViewController.swift
// Fare Weather
//
// Created by Jamie Kosoy on 2/23/16.
// Copyright © 2016 Arbitrary. All rights reserved.
//
import UIKit
import PromiseKit