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 Feb 25, 2021
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 Jan 29, 2018
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
# ###
@markjaquith
markjaquith / nginx.conf
Last active Sep 22, 2020
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 Apr 30, 2014
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 Apr 1, 2021
Setting Nginx FastCGI response buffer sizes.
View README.md
@nicolai86
nicolai86 / ansible-rails example
Created Feb 12, 2014
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 Jan 4, 2021
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 Dec 20, 2020
Podcasting Gear List
View gear.md
@sjl
sjl / zl.vim
Created Jan 17, 2014
Zip Right Vim mapping
View zl.vim
" Zip Right
"
" Moves the character under the cursor to the end of the line. Handy when you
" have something like:
"
" foo
"
" And you want to wrap it in a method call, so you type:
"
" println()foo