Skip to content

Instantly share code, notes, and snippets.

View cmaujean's full-sized avatar

Christopher Maujean cmaujean

  • Mostly here, but sometimes elsewhere
View GitHub Profile
@cmaujean
cmaujean / setup.sh
Created July 1, 2021 19:32 — forked from Sitin/setup.sh
Run x86-64 Docker images on Raspberry Pi 4 (QEMU/QUS)
# Setup QEMU for x86-64 Docker images on Raspberry Pi 4
# Install Python3 and Docker first: https://dev.to/rohansawant/installing-docker-and-docker-compose-on-the-raspberry-pi-in-5-simple-steps-3mgl
# Install QUEMU (https://www.qemu.org/)
sudo apt-get install qemu binfmt-support qemu-user-static
# Use QUS in Docker (https://github.com/dbhi/qus) to configure x86_64 architecture
docker run --rm --privileged aptman/qus -s -- -p x86_64
# Test x86-64 image:
@cmaujean
cmaujean / example_spec.rb
Last active August 29, 2015 13:57
Example Route spec
# spec/routes/example_spec.rb
require 'spec_helper'
describe "routing for tab separation of example slug routed pages" do
it "routes to known tab names" do
expect( :get => "/example/far-out-man/reviews" ).to route_to(
:controller => "directory",
:action =>"show_tab",
:slug => "far-out-man",
:tab => "reviews"
@cmaujean
cmaujean / git_prompt.sh
Created June 10, 2013 19:41
(bash_completion/git and rvm) command prompt integration
# requires the bash_completion packages installed via homebrew
if [ -f /usr/local/etc/bash_completion ]; then
. /usr/local/etc/bash_completion
fi
function __git_dirty {
git diff --quiet HEAD &>/dev/null
[ $? == 1 ] && echo "!"
}
@cmaujean
cmaujean / bundler_tldr.markdown
Created July 20, 2012 00:49
Bundler for the TL;DR impaired

Bundler for the TL;DR impaired

If you'd like a full description, read at the very least the "Understanding Bundler" section of http://gembundler.com

Commands

bundle install - This command is your meat-and-potatoes-everyday command, use

@cmaujean
cmaujean / Rakefile
Created July 14, 2012 01:24 — forked from adzap/Rakefile
# Get your spec rake tasks working in RSpec 2.0
require 'rspec/core/rake_task'
desc 'Default: run specs.'
task :default => :spec
desc "Run specs"
RSpec::Core::RakeTask.new do |t|
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
require 'sinatra'
get '/process' do
erb :process
end
@cmaujean
cmaujean / synopsis.rb
Created October 26, 2011 05:28
Rfile synopsis
require 'rfile'
f = RFile.new('path/to/some/file')
f.line(6) #=> "the 6th line in the file"
f.each do |l|
# ordered iteration of each line in the file (IO intensive)
end
@cmaujean
cmaujean / 01_add_custom_admin_roles.rb
Created October 11, 2011 04:52
Customizing Spree Roles - 0.60-stable - a basic example of adding custom roles to spree
# db/migrate/01_add_custom_admin_roles.rb
class AddCustomAdminRoles < ActiveRecord::Migration
@roles = %w[extra]
def self.up
@roles.each do |r|
Role.create(:name => r)
end
end
@cmaujean
cmaujean / _add_dialog.html.erb
Created September 30, 2011 18:13
Spree Add to Cart AJAX for spree 0.60-stable
<!-- app/views/orders/_add_dialog.html.erb -->
<div id="add_to_cart_dialog">
Your item(s) have been added. You now have <%= order.item_count %>
items valued at <%= number_to_currency order.item_total %> in your cart.<br/>
<div id="buttons" style="margin-top: 10px; width: 100%;">
<button id="continue_shopping_button" style="float: left;" type="button">Continue Shopping (10)</button>
<button id="view_cart_button" style="margin-left: 10px; float: left;clear: right;" type="button">Checkout Now</button>
</div>
</div>
@cmaujean
cmaujean / dotimes.js
Created September 27, 2011 09:35
countdown displayed in a button
function dotimes(amount) {
$('button#continue_shopping_button').html("Continue Shopping (" + amount + ")");
if (amount == 0 ) {
$('button#continue_shopping_button').trigger('click');
return;
} else {
amount = amount - 1;
setTimeout("dotimes(" + amount + ")", 1000);
}