Skip to content

Instantly share code, notes, and snippets.

View 0_curly_braces_vs_do_end.rb
# > Note 1: Yes, the parenthesis `( )`` for the prepend call are required when
# > using this inline style. If you do not use the parenthesis it will fail
# > silently and the patch will not be applied.
# -- https://solidfoundationwebdev.com/blog/posts/writing-clean-monkey-patches-fixing-kaminari-1-0-0-argumenterror-comparison-of-fixnum-with-string-failed
#
# The code below will show what's happening in this line of code from the blog:
#
# prepend(KaminariFix = Module.new do
# ...
# end)
@pixeltrix
pixeltrix / time_vs_datatime.md
Last active November 21, 2022 12:33
When should you use DateTime and when should you use Time?
View time_vs_datatime.md

When should you use DateTime and when should you use Time?

It's a common misconception that [William Shakespeare][1] and [Miguel de Cervantes][2] died on the same day in history - so much so that UNESCO named April 23 as [World Book Day because of this fact][3]. However because England hadn't yet adopted [Gregorian Calendar Reform][4] (and wouldn't until [1752][5]) their deaths are actually 10 days apart. Since Ruby's Time class implements a [proleptic Gregorian calendar][6] and has no concept of calendar reform then there's no way to express this. This is where DateTime steps in:

>> shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
=> Tue, 23 Apr 1616 00:00:00 +0000
>> cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
=> Sat, 23 Apr 1616 00:00:00 +0000
@rstormsf
rstormsf / bedrock-ansible-setup.sh
Last active January 29, 2018 10:23
Bedrock ansible setup
View bedrock-ansible-setup.sh
#!/bin/bash
#Script to install Bedrock Wordpress stack on OSX
brew doctor
brew tap caskroom/cask
brew update && brew upgrade brew-cask && brew cleanup && brew cask cleanup
brew cask install virtualbox vagrant
brew install rbenv ruby-build
#use bashrc if you are not on zsh
cat >> ~/.zshrc << EOF
# ###
@rochacon
rochacon / cmd-to-websocket.go
Created December 8, 2014 20:17
Stream a command stderr and stdout throught websockets
View cmd-to-websocket.go
package main
import (
"bufio"
"fmt"
"github.com/gorilla/websocket"
"io"
"log"
"net/http"
"os/exec"
@markjaquith
markjaquith / nginx.conf
Last active December 25, 2022 15:55
My WordPress Nginx setup
View nginx.conf
upstream phpfpm {
server unix:/var/run/php5-fpm.sock;
}
upstream hhvm {
server unix:/var/run/hhvm/hhvm.sock;
}
# SSL
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
@bennylope
bennylope / ansible.yml
Created April 30, 2014 00:35
Deployment w/ Capistrano style deployments with Ansible & Capistrano
View ansible.yml
---
- name: Deploy new site release
user: deployer
hosts: all
tasks:
- name: Fetch repo updates
git: >
repo=git@github.com:my/repo.git
@magnetikonline
magnetikonline / README.md
Last active January 13, 2023 16:33
Setting Nginx FastCGI response buffer sizes.
View README.md
@nicolai86
nicolai86 / ansible-rails example
Created February 12, 2014 06:11
a current usage example for nicolai86.rails-deployment as of v0.6.0
View ansible-rails example
---
- hosts: server
user: app_user
gather_facts: False
vars:
user: app_user
home_directory: "/home/{{ user }}"
deploy_to: "{{ home_directory }}/app"
roles:
@ftrain
ftrain / rhymes.clj
Last active January 4, 2021 08:38
Annotated rhyming dictionary
View rhymes.clj
;; This is at: https://gist.github.com/8655399
;; So we want a rhyming dictionary in Clojure. Jack Rusher put up
;; this code here:
;;
;; https://gist.github.com/jackrusher/8640437
;;
;; I'm going to study this code and learn as I go.
;;
;; First I put it in a namespace.
@joelhooks
joelhooks / gear.md
Last active June 14, 2021 08:45
Podcasting Gear List
View gear.md