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
# To and from hash and params (Rails 4) | |
str = 'nonce=2147483647&version=2.0&client_id=8iR5q' | |
h = Rack::Utils.parse_query str | |
params = ActiveSupport::HashWithIndifferentAccess.new(h) | |
# back to string: | |
query_str = params.to_query | |
Rack::Utils.parse_query(query_str) == Rack::Utils.parse_query(str) | |
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
module Moddy | |
def show_me | |
puts "Yop" | |
end | |
end | |
Class.new.extend(Moddy).show_me | |
Yop | |
# this may come in handy also: |
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
// TODO: Save this snippet for converting collections: | |
XXX.to[({type l[_] = collection.immutable.HashMap[UserInformationKind, String]})#l] |
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 | |
# Pingdom_http_custom_check | |
# DFF - 2011 | |
# put this in {Apache Files}/cgi-bin/ | |
# make sure to chmod +x the file | |
# Your ruby interpreter might not be where mine is. Check the above. | |
# | |
require 'cgi' | |
too_old=360 |
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 -ex | |
# | |
# Description: Graph how old the last sync was between primary and secondary mongo instances. | |
# | |
# Base code and idea thanks to: Edward M. Goldberg | |
# | |
# any mistakes courtesy of: Dennis Faust | |
# | |
if [ $RS_DISTRO = ubuntu ]; then | |
plugin_dir="/etc/collectd/conf" |
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
# Apache Basic Authentication for A Rewrite Condition not a Directory | |
# | |
# NOTE: Locations work off of URLs not directories | |
# | |
# Put this in your virtualhost block | |
# | |
<Location /YOUR_URL_PATH/> | |
AuthType Basic | |
AuthName "Authorization Required." | |
AuthUserFile /etc/httpd/conf/htpasswd |
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
# god upstart service | |
description "God process monitoring" | |
# When to start and stop the service | |
start on runlevel [2345] | |
stop on runlevel [016] | |
# Automatically restart process if crashed | |
kill timeout 20 | |
respawn |
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
# | |
# Check: http://redis-rb.keyvalue.org/v2.2.0/ | |
# | |
if Redis_connect | |
case Rails.env | |
when "production" | |
opts = {:host => "YOUR HOST NAME OR IP", :port => "6379", :thread_safe => true } | |
when "staging" | |
opts = {:host => "YOUR HOST NAME OR IP", :port => "6379", :thread_safe => true } | |
else |
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
// NewNotBlankValidator - given field must be declared as a null.* type. This checks to make sure the | |
// field value is its zero or null, or filled in but NOT set to empty String | |
// e.g. {value="", err=false} is not valid. | |
func NewNotBlankValidator(db *gorm.DB) validator.Func { | |
return func(v *validator.Validate, topStruct reflect.Value, currentStruct reflect.Value, field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string) bool { | |
switch fieldKind { | |
case reflect.String: | |
if field.String() == "" && field.IsValid() { | |
return 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
describe "StaticPages", type: :feature do | |
header_links = [ | |
{ name: 'Sign Up', link: '/signup', text: 'Contacts associated with purchases' }, | |
{ name: 'Log In', link: '/login', text: 'Forgot your user name or password?' } | |
] | |
footer_links = [ | |
{ name: 'Home', link: '/', text: 'Easily and efficiently track'}, | |
{ name: 'Plans & Pricing', link: '/plan', text: 'Standard Features'}, |
OlderNewer