Skip to content

Instantly share code, notes, and snippets.

@xionon
xionon / copy_image_files.rb
Last active August 24, 2020 13:54
Simple program to watch a floppy drive (A:) for new disks, and copy the images or files from them
require 'fileutils'
require 'win32-sound'
FILE_UTILS_NOOP = false
IMAGE_TYPES_REGEX = /.(jpg|gif|jpeg|png|mpg)$/i
DOC_TYPES_REGEX = /(?<!mavica).(doc|txt|docx|xls|xlsx|html|htm|zip)$/i
IMAGES_DIRECTORY = "C:/Users/Alec/Documents/floppys/images"
OTHER_DIRECTORY = "C:/Users/Alec/Documents/floppys/docs"
ALWAYS_IGNORE_REGEX = /(System Volume Information|.411|MAVICA.htm)$/i
FAILURE_WAV = "C:/Windows/Media/Windows Hardware Fail.wav"
@xionon
xionon / Gemfile
Last active January 4, 2016 16:39
Use rake and knife-solo to cook or bootstrap multiple EC2 instances. Automatically load EC2 IP addresses via the SDK
source 'https://rubygems.org'
gem 'rake'
gem 'aws-sdk'
gem 'dotenv'
gem 'chef'
gem 'librarian-chef'
gem 'knife-solo'
gem 'knife-solo_data_bag'
@xionon
xionon / hashtest.rb
Created January 20, 2014 15:50
Show off default hash values
puts "hash_without_default = Hash.new"
hash_without_default = Hash.new
print "hash_without_default[:key] # => "
puts hash_without_default[:key].inspect
print "hash_without_default[:key][:value] # => "
begin
puts hash_without_default[:key][:value].inspect
rescue => e
@xionon
xionon / Vagrantfile
Created January 17, 2014 16:00
Using this Vagrantfile, "vagrant up" fails running chef-solo with the error: FATAL: Chef::Exceptions::PrivateKeyMissing: I cannot read /etc/chef/client.pem, which you told me to use to sign requests!
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.provision :chef_solo do |chef|
chef.environment = "development"
chef.environments_path = "environments"
end
@xionon
xionon / .env
Created December 3, 2013 17:40
Simple rake task to upload a cookbooks archive to S3, for use with OpsWorks
S3_ACCESS_KEY_ID='SOME_SECRET_ID'
S3_SECRET_ACCESS_KEY='SOME_SECRET_KEY'
S3_BUCKET_NAME='SOME_BUCKET_NAME'
class PostsController < ApplicationController
def show
@post = Post.find(params[:id])
respond_to do |format|
format.html # GET /posts/1
format.json { render :json => @post } # GET /posts/1.json
end
end
web: bundle exec puma -C config/puma.rb
#! /usr/bin/env sh
# Generate a new, simple sinatra app
# Usage: sinatra-new name_of_app
set -e
dir=$1
mkdir -p $dir/{views,public}
cd $dir
@xionon
xionon / rails_form.js.jsx
Created February 20, 2015 17:01
rails jsx helper
var RailsForm = React.createClass({
propTypes: {
csrf: React.PropTypes.shape({
param: React.PropTypes.string,
token: React.PropTypes.string
}).isRequired
},
getDefaultProps: function() {
return {
@xionon
xionon / gist:f946b27f27c1fbb6eaba
Created June 28, 2014 14:29
Difference between an app generated with active record and an app without active record
diff -r app-with-ar/Gemfile app-without-ar/Gemfile
6,7d5
< # Use sqlite3 as the database for Active Record
< gem 'sqlite3'
diff -r app-with-ar/Gemfile.lock app-without-ar/Gemfile.lock
97d96
< sqlite3 (1.3.9)
123d121
< sqlite3
diff -r app-with-ar/config/application.rb app-without-ar/config/application.rb