Skip to content

Instantly share code, notes, and snippets.

View cdesch's full-sized avatar
🏠
Working from home

cdesch cdesch

🏠
Working from home
View GitHub Profile
@rstacruz
rstacruz / index.md
Last active November 3, 2023 09:56
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@steveclarke
steveclarke / capybara.md
Created April 10, 2012 17:32
RSpec Matchers

Capybara

save_and_open_page

Matchers

have_button(locator)
@Andrew8xx8
Andrew8xx8 / Gemfile
Created June 14, 2013 10:32
Example of API with ransack search and kaminari paginate.
gem 'kaminari'
gem 'ransack'
@gonecoding
gonecoding / Readme.markdown
Created February 22, 2011 12:42
Adding methods to NSData and NSString using categories to provide AES256 encryption on iOS

Important notice

I took down this Gist due to concerns about the security of the encryption/decryption part of this code (see comments below).

Rob Napier (@rnapier) has created a publicly available class that provides similar AES encryption/decryption functionality at https://github.com/rnapier/RNCryptor.

@thebigreason
thebigreason / social-sharing-alignment.html
Created October 18, 2011 17:48
Align Facebook Like, Twitter Tweet and Google +1 buttons
<div class="social">
<span class="twitter">
<a href="http://twitter.com/share" class="twitter-share-button" data-url="[your-url-here]">Tweet</a>
</span>
<span class="google">
<g:plusone size="medium" href="[your-url-here]"></g:plusone>
</span>
<span class="Facebook">
<iframe src="https://www.facebook.com/plugins/like.php?href=[your-url-here]&amp;show_faces=false&amp;layout=button_count" scrolling="no" frameborder="0" style="height: 21px; width: 100px" allowTransparency="true"></iframe>
</span>
@sydneyitguy
sydneyitguy / eth.rb
Created January 8, 2020 16:42
Ethereum address validation and normalization in Ruby
# Extracted from https://github.com/se3000/ruby-eth
#
# Dependencies:
# - gem 'digest-sha3'
# - gem 'rlp'
#
# Usage:
# - Eth::Utils.valid_address?('0x4Db7569F90bd836294B11c8b08B853d2de499Ced')
# => true
# - Eth::Utils.format_address('0x4db7569f90bd836294b11c8b08b853d2de499ced')
@chip
chip / find-unused.sh
Created December 23, 2013 19:13
This helps me find unused images in a Rails project. The echo statement never executes, so there's a glitch, but the output was helpful nonetheless. I'll try to improve later.
#!/bin/sh
PROJECT="" # Fill this in
IMAGES="$PROJECT/app/assets/images"
VIEWS="$PROJECT/app/views"
CSS="$PROJECT/app/assets/stylesheets"
for image in `find $IMAGES -type f`
do
name=`basename $image`
@wboykinm
wboykinm / cr-leaflet.js
Last active May 2, 2018 19:22
Census reporter GeoJSON tiles
CensusReporter = {
GeoIDLayer: L.GeoJSON.extend({
addGeoID: function(geoid) {
var request = new XMLHttpRequest();
var url = this.options.api_url + "/1.0/geo/show/tiger2013?geo_ids=" + geoid;
request.open('GET', url, true);
var self = this;
request.onreadystatechange = function() {
if (this.readyState === 4) {
if (this.status >= 200 && this.status < 400) {
@developer88
developer88 / active_admin.rb
Last active March 19, 2016 20:18
This is my gist that show how we can use CanCan with ActiveAdmin and store permissions in database.
# config/initializers/active_admin.rb
ActiveAdmin.setup do |config|
config.current_user_method = :current_user
config.authentication_method = :authenticate_user!
config.before_filter :admin_role_filter
end
# Adding all recource names to Permissions table after ActiveAdmin is loaded
@oliverbarreto
oliverbarreto / ObjectiveC Singleton
Last active December 27, 2015 09:39
Singleton Code for ObjectiveC iOS7
SingletonClass.h:
@interface SingletonClass : NSObject
@property (nonatomic, retain) NSString *myProperty;
+ (SingletonClass *)sharedInstance;
@end
SingletonClass.m:
@implentation
+ (SingletonClass *)sharedInstance