Skip to content

Instantly share code, notes, and snippets.

View knoopx's full-sized avatar

Víctor Martínez knoopx

View GitHub Profile
~$ ARCHFLAGS='-arch i386 -arch x86_64'
~$ rvm install 1.8.7 --debug --reconfigure -C --enable-shared=yes
~$ wget http://sourceforge.net/projects/rubycocoa/files/RubyCocoa/1.0.0/RubyCocoa-1.0.0.tar.gz/download
~$ tar xzf RubyCocoa-1.0.0.tar.gz && rm RubyCocoa-1.0.0.tar.gz && cd RubyCocoa-1.0.0
~/RubyCocoa-1.0.0$ ruby install.rb config --build-universal=yes
~/RubyCocoa-1.0.0$ ruby install.rb setup
~/RubyCocoa-1.0.0$ sudo ruby install.rb install
# Ruby 1.9 required
require 'socket'
port = ARGV.shift || 10075
server = TCPServer.new("0.0.0.0", port)
puts "Server running on #{server.addr.last}:#{server.addr[1]}"
# Serve the requests
begin
while sock = server.accept_nonblock
@danivovich
danivovich / factory_girl_step_helpers.rb
Created March 22, 2012 01:39
Factory Girl steps for Turnip
module FactoryGirlStepHelpers
def convert_human_hash_to_attribute_hash(human_hash, associations = [])
HumanHashToAttributeHash.new(human_hash, associations).attributes
end
class HumanHashToAttributeHash
attr_reader :associations
def initialize(human_hash, associations)
@human_hash = human_hash

Stuff I learned about Puppet

Chef vs Puppet

  • My blink is that in 2012 Puppet is safer and more productive.
  • Puppet is declarative, Chef procedural.
  • Puppet brings system into compliance (state), Chef "does" things (recipes).
  • Puppet has strong security practices; Chef has a toleration for loose security in Chef itself.
  • Puppet makes it very hard to get "outside the lines" or violate its strong opinions; in Chef this is routine.
@knoopx
knoopx / boostrap.markdown
Created June 21, 2012 12:07
Setting Up A New Server

Setting up a Rails application on a new server

This guide assumes the following points:

  • You are using a debian-based operating system
  • You would like to deploy your application using RVM, Capistrano and Bundler
  • Your application source code is hosted on a remote GIT repository

Update the operating system

@natritmeyer
natritmeyer / Usage.txt
Last active January 16, 2017 01:56
JUnit formatter for RSpec
NOTE: I've created a gem based on this: https://github.com/natritmeyer/yarjuf
---------
rspec my_spec.rb -r ./junit.rb -f JUnit -o results.xml
@brantfaircloth
brantfaircloth / gist:1282390
Created October 12, 2011 20:12
Enable Lion TRIM support on 3rd part SSDs
cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage ~/Desktop/IOAHCIBlockStorage.original
sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00).{9}(\x00\x51)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
sudo kextcache -system-prelinked-kernel
sudo kextcache -system-caches
@xaiki
xaiki / README.md
Last active May 8, 2018 14:54 — forked from scttnlsn/README.md

Pub/sub with MongoDB and Node.js

Setup:

$ mongo
> use pubsub
> db.createCollection('messages', { capped: true, size: 100000 })
> db.messages.insert({})
@pachacamac
pachacamac / google_speech_recognition.rb
Created December 11, 2011 10:52
google speech recognition with ruby
require 'rest_client'
require 'json'
a = `sox -d --norm -t .flac - silence -l 1 0 1% 1 6.0 1% rate 16k`
#a = `arecord -q -d 3 -c 1 -f S16_LE -r 22050 -t wav | flac - -f --totally-silent -o-`
r = RestClient.post 'https://www.google.com/speech-api/v1/recognize?lang=en-US', a,
:content_type => 'audio/x-flac; rate=16000'
if j = JSON.parse(r)
(p j; `espeak 'you said: #{j['hypotheses'].first['utterance']}'`)
end
@txus
txus / delegate_matcher.rb
Created February 2, 2011 09:19
RSpec matcher for delegations
# RSpec matcher to spec delegations.
#
# Usage:
#
# describe Post do
# it { should delegate(:name).to(:author).with_prefix } # post.author_name
# it { should delegate(:month).to(:created_at) }
# it { should delegate(:year).to(:created_at) }
# end