Skip to content

Instantly share code, notes, and snippets.

View shadoath's full-sized avatar
📚
Learning

Skylar Bolton shadoath

📚
Learning
View GitHub Profile
@ruzrobert
ruzrobert / Vibration.cs
Last active April 2, 2024 08:16
Android Vibration for Unity 3D. Supports all API: 1 - 29 (auto detect), Amplitudes, Predefined Effects, both Legacy and >=26 APIs.
using System.Diagnostics.CodeAnalysis;
using UnityEngine;
// Dont forget to add "using RDG;" to the top of your script!
namespace RDG
{
/// <summary>
/// Class for controlling Vibration. Automatically initializes before scene is loaded.
/// </summary>
public static class Vibration
@roalcantara
roalcantara / elasticsearch.rb
Created March 24, 2017 14:58
Rails > Disabling elasticsearch requests durying rspec tests
# spec/support/elasticsearch.rb
RSpec.configure do |config|
config.before :each do
stub_request(:any, /localhost:9200/).to_return(body: "<html>a webpage!</html>", status: 200)
end
end
@bhoggard
bhoggard / Gemfile
Created July 26, 2016 16:28
Default Rails 5 Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
@kraftbj
kraftbj / functions.php
Created July 23, 2014 17:43
Jetpack Related Posts, filter by date
function jetpackme_related_posts_past_halfyear_only( $date_range ) {
$date_range = array(
'from' => strtotime( '-6 months' ),
'to' => time(),
);
return $date_range;
}
add_filter( 'jetpack_relatedposts_filter_date_range', 'jetpackme_related_posts_past_halfyear_only' );
@lfender6445
lfender6445 / gist:9919357
Last active March 28, 2024 08:38
Pry Cheat Sheet

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@octocat
octocat / .gitignore
Created February 27, 2014 19:38
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@madhums
madhums / serializeHash.js
Created October 4, 2012 23:51
jquery form serialize hash
var serializeHash = function () {
var attrs = {};
$.each($(this).serializeArray(), function(i, field) {
attrs[field.name] = field.value;
});
return attrs;
};
@alexbevi
alexbevi / pre-commit.sh
Created August 23, 2012 12:05
Git pre-commit hook that checks ruby source files for Pry breakpoints
# Git pre-commit hook to check all staged Ruby (*.rb/haml/coffee) files
# for Pry binding references
#
# Installation
#
# ln -s /path/to/pre-commit.sh /path/to/project/.git/hooks/pre-commit
#
# Based on
#
# http://codeinthehole.com/writing/tips-for-using-a-git-pre-commit-hook/
@tjh
tjh / character_set_and_collation.rb
Created January 31, 2012 16:07
Convert all Rails table column collation and character set
#!/usr/bin/env ruby
# Put this file in the root of your Rails project,
# then run it to output the SQL needed to change all
# your tables and columns to the same character set
# and collation.
#
# > ruby character_set_and_collation.rb
DATABASE = ''
class Message < ActiveRecord::Base
validate :image_size_validation, :if => Proc.new { |m| m.image.present? }
mount_uploader :image, MessageImageUploader
private
def image_size_validation
errors[:image] << "should be less than 2MB" if image.size > 2.megabytes
end