Skip to content

Instantly share code, notes, and snippets.

@shad
shad / parse_date.rb
Created May 20, 2009 11:02
Ruby helper for parsing dates of an unknown format.
# ParseDate
#
# A helper for parsing dates of an unknown format.
#
# Takes a randomly formatted date and makes a best guess at the date, or throws and exception if
# there's no best guess. Will take international dates into account if you pass in a 'short form' date
# to help suggest a starting point for the search.
# Will also try Chronic parsing to get relative dates (yesterday, tomorrow, in 3 days, etc.)
#
# Examples:
@grosser
grosser / resque_web.rb
Created September 13, 2011 15:08 — forked from skippy/resque_web.rb
Mountable resque-web for rails 3+ apps
# https://gist.github.com/1214052
require 'sinatra/base'
class ResqueWeb < Sinatra::Base
require 'resque/server'
use Rack::ShowExceptions
if CFG[:user].present? and CFG[:password].present?
Resque::Server.use Rack::Auth::Basic do |user, password|
user == CFG[:user] && password == CFG[:password]
@gre
gre / easing.js
Last active April 30, 2024 04:58
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
@argon
argon / gl-resque.service
Created July 3, 2012 10:15
GitLab systemd files
[Unit]
Description=Gitlab Resque
[Service]
Type=forking
SyslogIdentifier=gl-resque
User=gitlab
PIDFile=/home/gitlab/gitlab/tmp/pids/resque_worker.pid
WorkingDirectory=/home/gitlab/gitlab
@mikhailov
mikhailov / 0. nginx_setup.sh
Last active December 26, 2022 19:30
Nginx + secure pseudo-streaming
# Nginx can serve FLV/MP4 files by pseudo-streaming way without any specific media-server software.
# To do the custom build we use 2 modules: --with-http_secure_link_module --with-http_flv_module
# This module "secure-link" helps you to protect links from stealing away.
#
# NOTE: see more details at coderwall: http://coderwall.com/p/3hksyg
cd /usr/src
wget http://nginx.org/download/nginx-1.5.13.tar.gz
tar xzvf ./nginx-1.5.13.tar.gz && rm -f ./nginx-1.5.13.tar.gz
@troy
troy / oneline_detailed_logging.rb
Created August 10, 2012 02:13
One-line detailed logging for Rails 3 (ActiveSupport::Notifications) and later
# Outputs this at warn log level:
# 1.2.3.4 GET /path 200 OK BlahController#action HTML 938.2 (DB 11.8, View 719.7) {params} {optional params from flash[:log]}
#
# Save as config/initializers/oneline_detailed_logging.rb. Consider
# decreasing the log level from "info" to "warn" (in production.rb) so
# the one-line log message replaces the standard request logs.
# override process_action to add 2 things to the payload:
# - remote IP
@nhance
nhance / method_logger.rb
Created September 6, 2012 12:58
Rails compatible method logging. Use this to log all calls to instance methods of a class to the log.
Model.new.foo
@ruckus
ruckus / AppController.php
Created October 25, 2012 04:51
CakePHP Request logging ala Rails
class AppController extends Controller {
function beforeFilter() {
$this->capture_request_head_for_log();
}
/*
Log some basic basic details of the HTTP Request:
Started GET "/users/lost" for 127.0.0.1 at 2012-10-24 19:18:25 -0700
@adelevie
adelevie / custom_cell.rb
Created November 17, 2012 18:26
Programmatically customize UITableViewCells in RubyMotion
# code inspired from http://jainmarket.blogspot.com/2009/05/creating-custom-table-view-cell.html
class CustomCell < UITableViewCell
attr_accessor :primaryLabel
attr_accessor :secondaryLabel
def createLabels
@primaryLabel = UILabel.alloc.init
@leucos
leucos / README.md
Last active December 11, 2015 10:28
Ruby playbook example

Deploying Ruby with Ansible

Define these variables somewhere and let it go :

  • ruby_current: the ruby version you want to deploy (e.g. "1.9.3-p374")
  • ruby_user: Under which account we want ruby to be installed (e.g. "myappuser"; "ruby" in this playbook)

Note : this playbook only works with '-i' in the sudo line since it requires the target user environment to be fully loaded