Skip to content

Instantly share code, notes, and snippets.

@cbosco
cbosco / install-ffmpeg-centos.sh
Last active May 13, 2022 14:34
Compile ffmpeg with libfdk_aac in a Lambda-like environment (Amazon Linux, CentOS)
# Copied from https://trac.ffmpeg.org/wiki/CompilationGuide/Centos
yum install -y autoconf automake bzip2 cmake freetype-devel gcc gcc-c++ git libtool make mercurial pkgconfig zlib-devel
mkdir ~/ffmpeg_sources
# NASM
cd ~/ffmpeg_sources
curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.13.02/nasm-2.13.02.tar.bz2
tar xjvf nasm-2.13.02.tar.bz2
@cbosco
cbosco / TruncateWithEllipsis.js
Last active May 23, 2017 00:51
React component for truncation with ellipsis.js (supporting HTML entities)
/**
* This component can truncate text AND HTML markup with ellipsis.
* Inspired by this github issue: https://github.com/One-com/react-truncate/issues/8#issuecomment-262639343
* This component is not managed by react VDOM and mutates its own DOM
*/
const Ellipsis = require('imports?self=>{}!ellipsis.js'); // shim `self`
import React, { Component } from 'react';
class TruncateWithEllipsis extends Component {
configure() {
@cbosco
cbosco / open_tmux.sh
Created June 25, 2015 19:49
Terry Li's open_tmux.sh
#!/bin/bash
set -e
CURRENT_SESSION=${PWD##*/}
# Do we have rakefile in the directory?
if [ ! -f Rakefile ]
then
echo 'Rakefile not found in current directory'
@cbosco
cbosco / tmux.conf
Created June 25, 2015 19:47
Terry Li's tmux config
unbind C-b
set -g prefix C-a
bind C-a send-prefix
bind-key C-a last-window
set -g default-terminal "screen-256color"
set-option -g default-command "reattach-to-user-namespace -l zsh"
set -g status on
set -g history-limit 1000000
AUTOMATION_SOURCE_DIR=./
AUTOMATION_TEST_SOURCE_DIR=${AUTOMATION_SOURCE_DIR}
NODE_MODULES_DIR=node_modules/
BUILD_DIR=./build/
.PHONY: all test \
copy_vendor_libs \
build prep \
clean
@cbosco
cbosco / all_my_facebook_photos.html
Last active November 9, 2023 23:34
Simple "get all of my facebook photos" facebook JS SDK + Graph API example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Photos with Friends!</title>
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script>
/**
* This is the getPhoto library
*/
@cbosco
cbosco / getTemporaryFilePathFromURL.coffee
Created September 29, 2012 21:11
Copies a binary remote file (like a jpeg image) to a temporary local file for use with node-canvas, etc
fs = require 'fs'
http = require 'http'
temp = require 'temp' # npm install
getTemporaryFilePathFromURL = ( url, callback ) ->
temp.open 'temp-image', (err, info) ->
stream = fs.createWriteStream info.path
http.get url, ( res ) ->
res.on 'data', (chunk) ->
console.log 'got chunk of size ' + chunk.length
@cbosco
cbosco / shadowtransform.js
Created August 31, 2011 14:18
HTML Canvas: Tests if .shadowOffsetX or .shadowOffsetY context properties are inverted (Android bug)
/**
* Usually shadowOffsetX and shadowOffsetY work as expected, but Android
* browser has a known issue where it inverts shadowOffsetY.
* (See http://code.google.com/p/android/issues/detail?id=16025)
* So, we test for it, creating an offset object for x and y
*/
var shadowTransform = (function() {
// create a 3x3 canvas and put a 1px square in the middle
var canvas = document.createElement('canvas');
canvas.height = canvas.width = 3;
@cbosco
cbosco / filtercanvas.js
Created August 22, 2011 17:21
Filter pattern
var filter = function(dest, src, w, h, filterSpecific) {
// HIPSTERHASHIT!
};
var canvas = document.getElementById('canvas');
var width = canvas.width;
var height = canvas.height;
var cc = canvas.getContext('2d');