Skip to content

Instantly share code, notes, and snippets.

View TheKidCoder's full-sized avatar
💚
Come Join Us @ Dutchie!

Chris Ostrowski TheKidCoder

💚
Come Join Us @ Dutchie!
View GitHub Profile
@TheKidCoder
TheKidCoder / example_controller.rb
Last active October 29, 2020 18:40
Rails - Sanitize Ordering Params
class ExampleController
include OrderingHelpers
def index
@clients = Clients.order(sanitized_ordering).where(user_id: current_user.id)
end
end
gem 'thin'
gem 'sevenhelpers', git: 'https://github.com/sevenview/sevenhelpers.git'
#gem_group :assets do
# gem 'zurb-foundation', '~>4.0.0'
#end
gem_group :test, :development, :staging do
gem 'factory_girl_rails', '~> 4.2'
gem 'ffaker'

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.

TL;DR Demo

# Ensure system is in ship-shape.

aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev

@TheKidCoder
TheKidCoder / gist:6784600
Created October 1, 2013 20:29
Argument Polymorphism in Java.
class DemoOverload{
public int add(int x, int y){ //method 1
return x+y;
}
public int add(int x, int y, int z){ //method 2
@TheKidCoder
TheKidCoder / ModalSetup.coffee
Created July 15, 2013 00:05
A simple modal.
class Readit.ModalRegionStruct extends Backbone.Marionette.Region
el: '#modal-container .modal'
open: (view) ->
@$el.parents('#modal-container').css
'width' : $(window).width()
'height' : $(window).height()
@$el.siblings('.modal-background').css
'width' : $(document).width()
@TheKidCoder
TheKidCoder / gist:4990752
Created February 19, 2013 22:26
Simple JS bookmarklet to get the center coordinates from maps.google.com
javascript:void(prompt('',gApplication.getMap().getCenter()));
@TheKidCoder
TheKidCoder / PNGtoBase64
Created April 24, 2012 22:53
Simple Thor task to convert PNGs to Base64 strings. Also compresses them using pngcrush.
#!/usr/bin/env ruby
require 'thor'
require 'base64'
require 'clipboard'
module PNGUtils
def PNGUtils.crush(file_path)
crushed = "#{file_path}.crushed"
# `pngcrush -rem alla -reduce -brute "#{file_path}" "#{crushed}"`
output = IO.popen("pngcrush -rem alla -reduce -brute \"#{file_path}\" \"#{crushed}\"")