Skip to content

Instantly share code, notes, and snippets.

View Oshuma's full-sized avatar

Dale Campbell Oshuma

View GitHub Profile
@Oshuma
Oshuma / fetch_and_build.sh
Created February 8, 2014 23:48
Shell script to pull and compile latest OpenXcom code.
#!/bin/sh
echo "\n== Stashing changes..."
git stash &&
echo "\n== Pulling latest code..."
git pull &&
echo "\n== Removing old build/ dir..."
rm -rf ./build/ &&
[user]
name = YOUR NAME
email = YOUR EMAIL
[github]
user = GITHUB USERNAME
token = GITHUB TOKEN
[core]
pager = less -FMRX
for f in (ls *.flac); ffmpeg -i "$f" -acodec libmp3lame -ab 320k (echo mp3/(basename $f .flac).mp3); end
# example of using rush to access files on multiple servers (as one collection)
nginx_confs = %w(www1 www2 www3).map { |n| Rush::Box.new(n)['/etc/nginx/nginx.conf'] }
nginx_confs.search(/access_log/)
@Oshuma
Oshuma / wma_to_mp3.rb
Created August 17, 2014 05:27
Convert .wma to .mp3
#!/usr/bin/env ruby
class WmaToMp3
TEMP_WAV = 'audiodump.wav'
def self.convert!(path)
wma_files = Dir.glob(File.join(path, "**/*.wma"), File::FNM_CASEFOLD)
if wma_files.empty?
STDOUT.puts "No .wma files found at: #{path}"
@Oshuma
Oshuma / sweetAlert-rails.js
Created October 21, 2014 16:04
Use sweetAlert with Rails UJS.
$.rails.allowAction = function(link) {
if ( ! link.attr('data-confirm') ) return true;
$.rails.showConfirmDialog(link);
return false;
};
$.rails.confirmed = function(link) {
link.removeAttr('data-confirm');
link.trigger('click.rails');
};
@Oshuma
Oshuma / gist:14219
Created October 1, 2008 23:04
EndNote Export
%0 Journal Article
%T Spectacular Giant Magnetoresistance Effects in the Polycrystalline Perovskite Pr0. 7Sr0. 05Ca0. 25MnO3-d
%A Raveau, B
%A Maignan, A
%A Caignaert, V
%J Journal of Solid State Chemistry
%V 117
%N 2
%P 424-426
%D 1995
# app/helpers/application_helper.rb
# Sets the page title and outputs a container if passed in.
# ex. <%= title('Some Page', :h2) %> will return the following:
# <h2>Some Page</h2> as well as setting the page title.
def title(name, container = nil)
@page_title = name
content_tag(container, name) if container
end
h1. Things I Always Do
* Initialize git repository
* Move config/database.yml to config/database.yml.example
* rm -f log/*.log
* <code>find . \( -type d -empty \) -and \( -not -regex ./\.git.* \) -exec touch {}/.gitignore \;</code>
* git add . && git commit -m 'Initial commit.'
* Add top-level .gitignore
* Write AppConfig
* Install restful_authentication.
<% form_tag session_path, :class => 'some_class' do %>
<%= text_field_tag :openid_url, params[:openid_url] || params['openid.identity'], :class => 'another_class' %>
<%= submit_tag 'Use OpenID', :class => 'button grey' %>
<% end %>