This is a generic guidline that applies mostly to Ruby on Rails and Postgres, but can be usefull for running any database migrations in CI.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# -------------------------------------------------------------------------------------------- | |
# Installs Ruby using rbenv/ruby-build on the Raspberry Pi (Raspbian) | |
# | |
# Run from the web: | |
# bash <(curl -s https://gist.githubusercontent.com/blacktm/8302741/raw/install_ruby_rpi.sh) | |
# -------------------------------------------------------------------------------------------- | |
# Set the Ruby version you want to install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SubdomainValidator < ActiveModel::EachValidator | |
# http://matthewhutchinson.net/2010/10/27/rails-3-subdomain-validation-activemodeleachvalidator | |
def validate_each(object, attribute, value) | |
return unless value.present? | |
reserved_names = %w(www ftp mail pop smtp admin ssl sftp) | |
reserved_names = options[:reserved] if options[:reserved] | |
if reserved_names.include?(value) | |
object.errors[attribute] << 'cannot be a reserved name' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Future versions of Hyper may add additional config options, | |
// which will not automatically be merged into this file. | |
// See https://hyper.is#cfg for all currently supported options. | |
module.exports = { | |
config: { | |
// default font size in pixels for all tabs | |
fontSize: 14, | |
// font family with optional fallbacks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'net/http' | |
require 'uri' | |
require 'nokogiri' | |
require 'mail' | |
url = ###/tracktest.php | |
refnum = # my application reference number. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Stupid simple css cache bust for Jekyll using site generation timestamp year/month/day/hour/minute/seconds | |
Output example: v=20130403134355 | |
--> | |
<link rel="stylesheet" href="/css/styles.css?v={{ site.time | date: '%Y%m%d%H%M%S' }}"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'dbm' | |
require 'github_api' | |
class Cache | |
attr_accessor :db | |
def initialize | |
@db = DBM.open('starred', 666, DBM::WRCREAT) | |
end | |
def load(key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Speed things up by not loading Rails env | |
config.assets.initialize_on_precompile = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_facebook_friends(access_token) | |
@graph = Koala::Facebook::API.new(access_token) | |
friends = @graph.get_connections("me", "friends?fields=id,name,picture.type(large)") | |
return friends | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UrlValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
record.errors[attribute] << (options[:message] || "must be a valid URL") unless url_valid?(value) | |
end | |
# a URL may be technically well-formed but may not actually be | |
# valid, so this checks for both. | |
def url_valid?(url) | |
url = URI.parse(url) rescue false | |
url.kind_of?(URI::HTTP) || url.kind_of?(URI::HTTPS) |
NewerOlder