Skip to content

Instantly share code, notes, and snippets.

View jkosoy's full-sized avatar

Jamie Kosoy jkosoy

View GitHub Profile
@jkosoy
jkosoy / runner.js
Created April 16, 2024 20:25
Record a video using playwright and FFMPEG
/*
* usage
* node runner.js | ffmpeg -y -c:v png -f image2pipe -r 30 -i - -c:v libx264 -pix_fmt yuv420p -movflags +faststart output.mp4
*
*/
const { chromium } = require('playwright');
const WIDTH = 1920;
const HEIGHT = 1080;
const URL = 'URL_GOES_HERE';
@jkosoy
jkosoy / TheBigShow.json
Created April 15, 2016 00:27
Melody Jams JSON example
{
"code": 200,
"data": {
"jam": {
"status": "ready",
"jam_id": "TheBigShow",
"created": "2016-03-16T00:00:00-07:00",
"last_updated": "2016-03-16T00:00:00-07:00",
"name": "The Big Show",
"ios": {
@jkosoy
jkosoy / CoreGraphics+AspectRatio.swift
Created April 14, 2016 23:54
Calculating for different device Aspect Ratios, used in Melody Jams
//
// CoreGraphics+AspectRatio.swift
// EmptySpriteKitGame
//
// Created by Jamie Kosoy on 11/6/15.
// Copyright © 2015 Arbitrary. All rights reserved.
//
import UIKit
import Foundation
@jkosoy
jkosoy / pseudo.js
Created March 9, 2016 20:12
Promises Explained
animateFareTextIn(function() {
animateWeatherTextIn(function() {
animateDividerIn(function() {
animateLoadingSentence1In(function() {
animateLoadingSenetence2In(function() {
// all done!
})
}
}
})
@jkosoy
jkosoy / IntroView.swift
Created March 8, 2016 23:34
Fare Weather
//
// IntroView.swift
// Fare Weather
//
// Created by Jamie Kosoy on 3/8/16.
// Copyright © 2016 Arbitrary. All rights reserved.
//
import UIKit
import CFAAction
@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
@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 / CGSize+AspectFunctions.swift
Last active June 3, 2023 18:11
Aspect Fill and Aspect Fit calculations in Swift
// port of http://stackoverflow.com/a/17948778/3071224
import UIKit
import Foundation
extension CGSize {
static func aspectFit(aspectRatio : CGSize, var boundingSize: CGSize) -> CGSize {
let mW = boundingSize.width / aspectRatio.width;
let mH = boundingSize.height / aspectRatio.height;
@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 / Git Flow.md
Last active February 23, 2024 22:48
Git Flow

Git Flow

I keep meeting people who struggle to wrap their heads around the proper way to use Git + Github. This snippet is designed to explain Vincent Driessen's git branching model, at least as well as I understand it. Speacial thanks to Stephen Koch for being the true master here.

This tutorial is for Linux or OSX. Feel free to use Cygwin or write a fork for windows.

A way to think about Git and Github.