Skip to content

Instantly share code, notes, and snippets.

View chrismo's full-sized avatar

chrismo chrismo

View GitHub Profile
@chrismo
chrismo / [outputs]
Created October 15, 2012 21:15
Dump date/time formats with examples of a locale in Rails
$ bin/rake i18n:show_sample_dates_and_times['en-MY']
time:
date : %m/%d/%Y : 2012-10-15
date_day : %d : 15
date_hour : %l:%M %p : 4:13 pm
date_month : %B : October
date_month_name : %B %e, %Y : 15 October 2012
date_month_year : %B %Y : October 2012
date_short_month_year : %e %b %Y : 15 Oct 2012
date_short_year : %m/%d/%y : 15-10-12
@chrismo
chrismo / bundle editor.sh
Last active December 12, 2022 02:13
Sequel Pro Format Sql Bundle
ruby formatsql.rb "$(cat)"
@chrismo
chrismo / install_imagick_amzn2.sh
Last active October 12, 2021 14:52 — forked from sshymko/install_pecl_imagick_amzn2.sh
Install latest ImageMagick 7.x and imagick PHP extension from PECL on Amazon Linux 2
#!/bin/sh
# Uninstall ImageMagic library and imagick PHP extension using it (installed previously)
yum remove -y php-pecl-imagick ImageMagick
# Install libraries for JPG, PNG, GIF, WebP, and TIFF image formats
yum install -y libpng-devel libjpeg-devel openjpeg2-devel libtiff-devel libwebp-devel giflib-devel
# Install latest ImageMagick library compiled from downloaded sources
yum install -y tar gzip gcc make
@chrismo
chrismo / copr.md
Last active April 9, 2021 18:15
Git: Checkout PR

Greg Vaughn posted this cool alias the other day:

copr = "!f() { git fetch -fu origin refs/pull/$1/head:pr-$1; git checkout pr-$1; } ; f"

Preferring to be a stock-tools person, I wanted to deconstruct this to see how I'd use it off-the-shelf without the alias.

git fetch     -- I'm already familiar with this command
-fu           -- these two flags I'm not sure are necessary, esp. -u since the help says, 
 "unless you are implementing your own Porcelain you are not supposed to use 
@chrismo
chrismo / README.md
Last active October 19, 2016 20:32
Bundler 1.3 --binstubs vs. Rails 4

On a clean Rails 4 install with Bundler 1.3.0, using --binstubs causes competition between Rails and Bundler for the contents of bin/rails (and bin/rake).

Just running bundle will rewrite the Rails version of bin/rails to a version that doesn't work.

The fix is to use the new bundle binstubs <gemname> command.

(see rails/rails#8974)

Fetching gem metadata from https://rubygems.org/........
Fetching version metadata from https://rubygems.org/.
Starting resolution (2016-10-06 10:14:12 -0500)
Resolving dependencies...Creating possibility state for fog (= 1.38.0) (1 remaining)
Attempting to activate fog (1.38.0)
Activated fog at fog (1.38.0)
Requiring nested dependencies (fog-core (~> 1.32), fog-json, fog-xml (~> 0.1.1), ipaddress (~> 0.5), fog-aliyun (>= 0.1.0), fog-atmos, fog-aws (>= 0.6.0), fog-brightbox (~> 0.4), fog-cloudatcost (~> 0.1.0), fog-dynect (~> 0.0.2), fog-ecloud (~> 0.1), fog-google (<= 0.1.0), fog-local, fog-openstack, fog-powerdns (>= 0.1.1), fog-profitbricks, fog-rackspace, fog-radosgw (>= 0.0.2), fog-riakcs, fog-sakuracloud (>= 0.0.4), fog-serverlove, fog-softlayer, fog-storm_on_demand, fog-terremark, fog-vmfusion, fog-voxel, fog-vsphere (>= 0.4.0), fog-xenserver)
Creating possibility state for fog-core (~> 1.32) (14 remaining)
Attempting to activate fog-core (1.43.0)
Activated fog-core at fog-core (1.43.0)
=> bundle outdated
Fetching source index from file:/Users/chrismo/dev/bundler-cases/out/repo/
Resolving dependencies...
Outdated gems included in the bundle:
* bar (newest 1.1.0, installed 1.0.0) in group "default"
* foo (newest 2.0.0, installed 1.0.0) in group "default"
* qux (newest 1.0.1, installed 1.0.0) in group "default"
=> bundle outdated --major
@chrismo
chrismo / .gitignore
Last active January 25, 2016 15:53
Answer to creating multiple has_many records
.bundle
@chrismo
chrismo / test.rb
Created April 22, 2013 22:47
elsif
irb(main):001:0> a = 2
=> 2
irb(main):002:0> if a == 0
irb(main):003:1> puts 'zero'
irb(main):004:1> elsif a < 2
irb(main):005:1> puts 'less than 2'
irb(main):006:1> else
irb(main):007:1* puts 'greater than or equal to 2'
irb(main):008:1> end
greater than or equal to 2