Skip to content

Instantly share code, notes, and snippets.

#####
# Found on http://www.documentsnap.com/abbyy-finereader-and-snow-leopard-file-not-created-with-scansnap/
# and modified to work from command line and behave slightly differently. Creating an Automator script
# to trigger should be trivial, though. you'd want to add a "cd /path/to/incoming_scans" at the top.
#
# Works with ScanSnap on Snow Leopard with the latest Abby Fine Reader and ScanSnap drivers. Doesn't
# do the meta data munging though that should be trivial to add back in.
#
# Do you scanning all at once, then kick this script off when you leave your computer - this results in a
# great speed up in workflow
#!/usr/bin/ruby
if `networksetup -getairportpower AirPort` =~ /On/
exec "networksetup -setairportpower AirPort off"
else
exec "networksetup -setairportpower AirPort on"
end
raise "Code here isn't very usefull"
require 'spec_helper'
class ::ParentDoc
include MongoMapper::Document
many :embedded_docs
many :child_docs
key :name, String
end
class ::EmbeddedDoc
@mkocher
mkocher / $PATH
Created March 22, 2011 18:56
Our rvm_install_on_use_flag seems to be producing broken rubies - we couldn't decide what it would make sense to trace - the install itself?
user@server:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/company/com/bin/java6_32/bin:/company/com/bin/ant/bin:/company/com/bin/RDSCli/bin:/company/com/bin/CloudWatch/bin:/company/com/bin/ec2-api-tools/bin:/home/user/.rvm/bin
@mkocher
mkocher / gist:969445
Created May 12, 2011 21:05
Requring psych before yaml, ruby-1.9.2-p180 on centos
ruby-1.9.2-p180 :006 > exit
[clients-user@ip-10-83-118-38 workspace]$ cd ..
[clients-user@ip-10-83-118-38 workspace]$ vi config
config/ config.ru
[clients-user@ip-10-83-118-38 workspace]$ vi config/
application.rb cucumber.yml database.yml.example environments/ locales/
boot.rb database.yml environment.rb initializers/ routes.rb
[clients-user@ip-10-83-118-38 workspace]$ vi config/database.yml.example
[clients-user@ip-10-83-118-38 workspace]$ irb
ruby-1.9.2-p180 :001 > require 'pp'
execute "check file cache path" do
command "ls #{Chef::Config[:file_cache_path]}"
end
Species = DS.Model.extend({
name: DS.attr('string')
});
Person = DS.Model.extend({
name: DS.attr('string'),
species: DS.belongsTo(Species, { embedded: true })
tags: DS.hasMany(Tag, { embedded: true })
});
module JasmineFixtures
# Saves the markup to a fixture file using the given name
def save_fixture(markup, name)
fixture_path = File.join(Rails.root, '/tmp/js_dom_fixtures')
Dir.mkdir(fixture_path) unless File.exists?(fixture_path)
fixture_file = File.join(fixture_path, "#{name}.fixture.html.erb")
File.open(fixture_file, 'w') do |file|
file.puts(markup)
end
@mkocher
mkocher / fake.rb
Created September 5, 2012 04:30
Fakes in Ruby
class FileTransferJob
def initialize(ftp_service = FtpService.new)
@ftp_service = ftp_service
end
def do_the_needful
@ftp_service.put("/tmp/the_file_to_send", "/tmp/the_destination")
end
end
@mkocher
mkocher / gist:3651970
Created September 6, 2012 06:12
Using a gem for shared project code
Sharing common code using a gem is a great idea, but it's painful to rapidly iterate in both codebases.
What we settled on something like:
if ENV['LOCAL_GEMS']
gem 'shared_stuff', :path => '~/workspace/shared_stuff'
else
gem 'shared_stuff, :github => 'mkocher/shared_stuff'
end