Skip to content

Instantly share code, notes, and snippets.

@naps62
naps62 / bitly.rb
Last active December 16, 2015 18:00
Ruby script to quickly shorten a url using the bit.ly API. The only requirements are the bitly and clipboard gems, and BITLY_USERNAME and BITLY_API_KEY environment variables
#!/usr/bin/env ruby
require 'bitly'
require 'clipboard'
require 'uri'
username = ENV['BITLY_USERNAME']
api_key = ENV['BITLY_API_KEY']
url = ARGV.shift
@naps62
naps62 / 01_goal.rb
Last active December 27, 2015 13:29
possible approach to presenter pattern (not tested)
# We want to have something this:
# app/models/user.rb
class User < ActiveRecord::Base
include Presenter::Mixin
end
# or for more customization
class User < ActiveRecord::Base
presented
@naps62
naps62 / Gruntfile.coffee
Last active January 23, 2017 05:47
quick Grunt.js setup with Sass + Coffee + Slim
module.exports = (grunt) ->
# configuration
grunt.initConfig
# grunt sass
sass:
compile:
options:
style: 'expanded'
@naps62
naps62 / Rakefile
Created May 30, 2014 13:01
Retrying failing cucumber steps automatically until everything is green
require 'cucumber/rake/task'
NUM_RETRIES = ENV['NUM_RETRIES'] || 2
task :default => "cucumber:run"
namespace :cucumber do
directory "tmp"
@rerun_file = 'tmp/rerun.txt'
@naps62
naps62 / foobar.conf
Last active August 29, 2015 14:07
Examples for Provision talk @ Code Week
upstream foobar {
server unix:///var/www/foobar/shared/sockets/puma.sock;
}
server {
server_name www.foobar.com;
return 301 $scheme://foobar.com$request_uri;
}
server {
@naps62
naps62 / .rubocop.yml
Created March 22, 2015 22:36
[ESS @ UM] Rubocop setup
AllCops:
Include:
- '**/Rakefile'
- '**/config.ru'
Exclude:
- 'db/**/*'
- 'config/**/*'
- 'script/**/*'
- 'bin/**/*'
- 'vendor/**/*'
language: ruby
rvm:
- 2.0.0
@naps62
naps62 / components.js
Created April 9, 2015 00:08
A JS component pattern implementation
var GameObject = function(name) {
this.name = name || "gameObject";
this.components = [];
}
GameObject.prototype.update = function() {
this.components.map(function(component) {
if (!!component.update) {
component.update();
}
@naps62
naps62 / cs2015-rails-presentation.md
Last active August 29, 2015 14:26
cs2015-rails-presentation

Topics

  • MVC
  • Routes
  • Convention over Configuration
  • How to create a Rails project
  • Directory Structure
  • Route helpers
  • (*) sprockets (manifest files, minification, etc, Scss)
  • (*) views (view helpers
@naps62
naps62 / test.rb
Last active February 26, 2016 10:23
egonSchiele/contracts.ruby - issue #229
require "contracts"
C = Contracts
module ModuleWithContracts
def self.included(base)
base.extend ClassMethods
end
module ClassMethods