Skip to content

Instantly share code, notes, and snippets.

View wearethefoos's full-sized avatar

Wouter de Vos wearethefoos

View GitHub Profile
ssl_certificate Definition
define :ssl_certificate, action: :create do
cert_dir = File.expand_path("../../files/default", __FILE__)
# Find the host certificate
host_cert = File.join( cert_dir, "*.#{params[:name]}.crt" )
Chef::Logger.error("Could not locate host certificate for #{params[:name]}!")
# Find the intermediate certificate
class Profiler
def self.profile(&block)
result = RubyProf.profile do
block.call
end
printer = RubyProf::GraphPrinter.new(result)
printer.print(STDOUT, {})
end
end
#!/usr/bin/env bash
#
# Rails console script that can be run on AWS Elastic Beanstalk.
#
# Run this script from the app dir (/var/app/current) as root (sudo script/aws-console)
#
set -xe
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
@wearethefoos
wearethefoos / Setup.md
Created May 7, 2015 15:21
Configurable Bootstrap Setup With Rails And Bower For Sass & JS Dependencies

First add the bower-rails and the compass-rails gems to your project's Gemfile:

# Gemfile
gem 'compass-rails'
gem 'bower-rails'

Run bundle install and then the generator that comes with bower-rails to set everything up:

def show_menu
puts "
Catalogue
-------------
1) Cat
2) Goldfish
3) Dog
4) Horse
Pick a product (1 - 4):"

Carrierwave Example Uploader

Steps

  • Add gem 'carrierwave' to Gemfile
  • Run bundle install to install the new gem
  • Stop spring: spring stop
  • Run rails generate uploader Image
  • Mount the newly generated ImageUploader on your Model. I mounted it on the string type column image by adding this in my model's class:
class Beer
# We ONLY want to be able to read @amount, not
# change it without calling "sip!"
attr_reader :amount
def initialize
@amount = 250
end
def sip!

Git Assignment

  • Make teams of 2 to 3 ppl
  • One creates a Repository and adds the rest of the team as collaborators (see repo "Settings")
  • All of you clone the repository on your local machine (make sure you are not cloning inside another git repo!)
  • Recreate the Beer project together, but spread the work in different files, e.g.:
import SocketClient from 'socket.io-client';
import Feathers from 'feathers-client';
import Utils from '../lib/Utils';
const API_HOST = "http://localhost:3030";
class BaseModel {
defaults() { return {}; }
constructor(resource_name, host = API_HOST) {
class Utils {
uuid() {
var i, random;
var uuid = '';
for (i = 0; i < 32; i++) {
random = Math.random() * 16 | 0;
if (i === 8 || i === 12 || i === 16 || i === 20) {
uuid += '-';
}