Skip to content

Instantly share code, notes, and snippets.

@dfreerksen
dfreerksen / .editorconfig
Last active Aug 16, 2018
.editorconfig for Ruby projects
View .editorconfig
# EditorConfig is awesome: http://EditorConfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
View .rubocop.yml
AllCops:
Include:
- Rakefile
- config.ru
Exclude:
- "bin/**/*"
- "db/schema.rb"
- "db/migrate/**/*"
- "spec/dummy/**/*"
- "vendor/**/*"
@dfreerksen
dfreerksen / .template.rb
Last active Apr 15, 2016
Rails application template
View .template.rb
# coding: utf-8
# Rails init template
#
# Usage
#
# $ rails new app_name -m https://gist.githubusercontent.com/dfreerksen/0270bbb7cf153497d5dce6b691c747e2/raw/.template.rb
# Gemfile
run "rm Gemfile"
get "https://gist.githubusercontent.com/dfreerksen/0270bbb7cf153497d5dce6b691c747e2/raw/Gemfile", "Gemfile"
View checkout_controller_decorator.rb
# app/controllers/spree/checkout_controller_decorator.rb
Spree::CheckoutController.class_eval do
after_action :after_order_processing
def after_order_processing
# This doesn't seem to be called either. Also I would have to check the
# current state each time this ran for the 'complete' state
binding.pry
end
end
View Date.php
<?php
/**
* Date class
*/
class Date {
/**
* Fuzzy date strings
*
* @var array
@dfreerksen
dfreerksen / Crypt.php
Created Aug 27, 2012
PHP Crypt class
View Crypt.php
<?php
class Crypt {
/**
* The encryption cipher
*
* @var string
*/
static public $cipher = MCRYPT_RIJNDAEL_256;
@dfreerksen
dfreerksen / Curl.php
Created Aug 17, 2012
PHP Curl helper class (PHP 5.2+)
View Curl.php
<?php
class Curl {
/**
* cURL request method
*
* @var string
*/
protected $_method = 'GET';
@dfreerksen
dfreerksen / Input.php
Created Aug 17, 2012
PHP Input class
View Input.php
<?php
class Input {
/**
* Protocol (http or https)
*
* @return string
*/
static public function protocol() {
@dfreerksen
dfreerksen / Autoload.php
Created Aug 17, 2012
PHP Autoload class (for PHP < 5.3)
View Autoload.php
<?php
/**
* TODO: Add support for namespaces... If we ever move to PHP 5.3+
*/
class Autoload {
/**
* Class directories
*