Skip to content

Instantly share code, notes, and snippets.

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

Andy Cohen OutlawAndy

🏠
Working from home
View GitHub Profile

Ruby: The future of frozen string literals

What is a literal?

In programming languages, literals are textual representations of values in the source code. This is a syntactical concept.

Some examples:

7 # integer literal
@annikoff
annikoff / custom_generators.md
Last active September 15, 2025 05:31
Custom generators

The main generator

# lib/generators/rails/policy/policy_generator.rb

module Rails
  module Generators
    class PolicyGenerator < NamedBase
      source_root File.expand_path('templates', __dir__)

      def copy_policy_file
@n1chre
n1chre / emoji.txt
Created October 14, 2017 11:25
Unicode emojis
ʘ‿ʘ
Innocent face
ಠ_ಠ
Reddit disapproval face
(╯°□°)╯︵ ┻━┻
Table Flip / Flipping Table
┬─┬ ノ( ゜-゜ノ)
@stevepeak
stevepeak / Rakefile
Created February 23, 2016 17:45 — forked from stephanvd/Rakefile
CodeCov setup for parallel_test gem
namespace :codecov do
desc 'Uploads the latest simplecov result set to codecov.io'
task upload: :environment do
require 'simplecov'
require 'codecov'
formatter = SimpleCov::Formatter::Codecov.new
formatter.format(SimpleCov::ResultMerger.merged_result)
end
end
@rstuven
rstuven / decorate.coffee
Last active July 12, 2017 23:15
Decorators in CoffeeScript
###
`decorate` can apply decorators using the API proposed in
https://github.com/wycats/javascript-decorators
which is supported in Babel 5+ and TypeScript 1.5
Usage:
Foo = decorate F("color"), G, class Foo
@mattheworiordan
mattheworiordan / cli.rb
Created January 9, 2015 12:21
Thor with subcommands that work correctly with help
#!/usr/bin/env ruby
require 'thor'
class SubCommandBase < Thor
def self.banner(command, namespace = nil, subcommand = false)
"#{basename} #{subcommand_prefix} #{command.usage}"
end
def self.subcommand_prefix
@jacobo
jacobo / hax_background_jobs_in_thin.ru
Created March 14, 2013 19:01
Example of running background jobs in thin without needing a separate background job processor (or spawning threads)
#Save this file as hax_background_jobs_in_thin.ru
#In one terminal run: thin start --rackup hax_background_jobs_in_thin.ru
#In another run: curl -v localhost:3000
class CleverMailSender
class << self; attr_accessor :emails_to_send; end
self.emails_to_send = []
def initialize(app)
@app = app
end
@ProLoser
ProLoser / alerts.html
Last active October 9, 2019 18:38
AngularJS Bootstrap implemented without any additional code
<h1>Alert</h1>
<p>Bootstrap JS</p>
<div class="alert fade in">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Holy guacamole!</strong> Best check yo self, you're not looking too good.
</div>
<p></p><a ng-click="alert=true">Open Alert (AngularJS)</a></p>
<div class="alert fade" ng-class="{in:alert}">
<button type="button" class="close" ng-click="alert=false">×</button>
@vitch
vitch / config.json
Created December 1, 2012 18:50
Another Inlet
{"description":"Another Inlet","endpoint":"","display":"svg","public":true,"require":[],"tab":"edit","display_percent":0.7,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01}