Skip to content

Instantly share code, notes, and snippets.

View cblunt's full-sized avatar
👨‍💻
Coding

Chris Blunt cblunt

👨‍💻
Coding
View GitHub Profile
@alexbrinkman
alexbrinkman / Capybara Cheat Sheet.md
Last active May 2, 2024 05:44
A List of Methods for Capybara

Navigating

visit "/projects"
visit post_comments_path(post)

Clicking links and buttons

click_link "id-of-link"
click_link "Link Text"
@ungoldman
ungoldman / config.rb
Last active December 25, 2015 05:29
middleman instance variables that are collections of pages
# ...
def get_pages
# get an array of pages whose source filename contains .html
@pages = sitemap.resources.find_all { |page| page.source_file.match(/\.html/) }
# sort them by an arbitrary YAML frontmatter property called 'order'
@pages.sort! { |a,b| a.data['order'].to_i <=> b.data['order'].to_i }
end
@gabrielemariotti
gabrielemariotti / build.gradle
Last active January 12, 2024 17:41
Use signing.properties file which controls which keystore to use to sign the APK with gradle.
android {
signingConfigs {
release
}
buildTypes {
release {
signingConfig signingConfigs.release
}
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 2, 2024 05:55
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@cdarne
cdarne / apache_setup.sh
Created May 24, 2012 11:17
Upstart/init.d config example for rails/passenger
sudo a2enmod proxy_http
sudo service apache2 restart
# DEPRECATED: use https://gist.github.com/cblunt/1042832
# rails new my-app -m [raw url to this file]
gem 'json'
# Slim template
gem 'slim-rails'
gem 'simple_form'
@kirs
kirs / avatar_uploader.rb
Created September 24, 2011 07:33
Validation of image dimensions with CarrierWave
# encoding: utf-8
class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# Override the directory where uploaded files will be stored.
@casidiablo
casidiablo / SimpleCursorLoader.java
Created September 14, 2011 20:03
Used to write apps that run on platforms prior to Android 3.0. When running on Android 3.0 or above, this implementation is still used; it does not try to switch to the framework's implementation. See the framework SDK documentation for a class overview
/*
* Copyright 2012 CodeSlap - Cristian Castiblanco
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@grantr
grantr / gist:1105416
Created July 25, 2011 22:31
Chef mysql master/slave recipes
## mysql::master
ruby_block "store_mysql_master_status" do
block do
node.set[:mysql][:master] = true
m = Mysql.new("localhost", "root", node[:mysql][:server_root_password])
m.query("show master status") do |row|
row.each_hash do |h|
node.set[:mysql][:master_file] = h['File']
node.set[:mysql][:master_position] = h['Position']
end
@mttkay
mttkay / gist:1042424
Created June 23, 2011 12:05
Android photo uploader
@Override
protected void onHandleIntent(Intent intent) {
this.nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
int jobId = intent.getIntExtra(JOB_ID_EXTRA, -1);
QypeModel model = intent.getParcelableExtra(MODEL_EXTRA);
if (model instanceof Place) {
this.uploadStrategy = new PlacePhotoUploadStrategy((Place) model);
} else if (model instanceof User) {
this.uploadStrategy = new UserPhotoUploadStrategy((User) model);
} else {