Skip to content

Instantly share code, notes, and snippets.

View os6sense's full-sized avatar

Adrian Lee os6sense

  • MyMedsAndMe
  • London, UK
View GitHub Profile
@os6sense
os6sense / gist:8934371
Last active August 29, 2015 13:56
Controller, params and scopes
class ProjectsController < ApplicationController
7
8 def index
9 @projects = nil
10
11 if params[:studio_id] && !params[:studio_id].empty?
12 @projects = Project.studio(params[:studio_id])
13 end
14
15 # past, present, future
require 'benchmark'
Benchmark.bm(20) do |x|
x.report ('<<') do
10_000_000.times do
one = 'one'
two = 'two'
three = 'three'
y = one << two << three
end
require 'benchmark'
Benchmark.bm(20) do |x|
x.report ('<<') do
out = ""
100_000.times do
one = 'one'
two = 'two'
three = 'three'
out << "#{one}" << "#{two}" << "#{three}"
@os6sense
os6sense / gist:8157eaa820a3abb211dc
Last active August 29, 2015 14:00
Black Magic DSK direct link
SDK
http://software.blackmagicdesign.com/SDK/Blackmagic_DeckLink_SDK_10.1.zip
Drivers
http://software.blackmagicdesign.com/DesktopVideo/Blackmagic_Desktop_Video_Linux_10.1.tar.gz
@os6sense
os6sense / gist:c275bc89a6fd969835e2
Created May 12, 2014 19:07
bmdcapture and ffmpeg muxing audio from seperate source to ffserver
sudo bmdcapture -m 2 -A 0 -C 0 -V 1 -F nut -f pipe:1 | sudo ffmpeg -f alsa -i plughw:UA25 -i - -f ffm http://localhost:8090/feed1.ffm
Order of everything is VITAL otherwise the muxed audio ends up being ignored. 3 hours time wasted messing with map :/
@os6sense
os6sense / gist:4d71a2e887e81050cc91
Last active August 29, 2015 14:14
(sort of dynamic) alias as a macro in Elixir
# dynamic_alias.ex
defmodule DynamicAlias do
@doc
"""
The following macro will introduce an alias into the calling module replacing
the last part of the module name with the contents of List.replace_at/3.
This is useful if you want to automatically references a different module
without knowing the fully qualified module name, but I'm new to Elixir and
there may be a better way to do this.
@os6sense
os6sense / gist:db80d6970db6091f9089
Created February 13, 2015 13:46
__using__ using use
# used from within a test (e.g. use UseDI.A) the following is output:
# __using__ UseDI. caller : Elixir.UseDependencyInjectionTest
# __using__ UseDI.A. caller : Elixir.UseDependencyInjectionTest
import IO, only: [puts: 1]
defmodule UseDI do
defmacro __using__(_) do
quote do
@os6sense
os6sense / gist:7362770
Last active December 27, 2015 17:29
vagrant + rubber + ubuntu 13.10 + rvm
Trying to use vagrant + rubber + ubuntu 13.10 (box, probably other versions).
Most of the docs cover basic setup but I ran into a couple of problems not covered anywhere (does no-one use this combo before deploying to AWS?)
~ vagrant up
# OR
~ vagrant provision
-> [BUG] Segmentation fault ruby 1.9.3p194 (blah blah)
It seems its necessary to use rvm to switch to 1.9.3 p194 on the host
@os6sense
os6sense / deploy.sh
Last active December 29, 2015 06:19
Bootstrap chef onto a new system. Based on Jo Liss's bootstrap http://www.opinionatedprogrammer.com/2011/06/chef-solo-tutorial-managing-a-single-server-with-chef/. Run sh depoly.sh user@ipaddress_or_host to deploy
#!/bin/bash
# Usage: ./deploy.sh [host]
# e.g. sh deploy user@123.212.11.14
host="$1"
# The host key might change when we instantiate a new VM, so
# we remove (-R) the old host key from known_hosts
ssh-keygen -R "${host#*@}" 2> /dev/null
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});