Skip to content

Instantly share code, notes, and snippets.

View jrhorn424's full-sized avatar
🌟
Always be dreaming

Jeffrey Horn jrhorn424

🌟
Always be dreaming
View GitHub Profile
@jrhorn424
jrhorn424 / age.js
Created October 6, 2015 15:02 — forked from gaand/age.js
var age = function age() {
var dob = new Date(this.dob);
var today = new Date();
var thisYear = today.getFullYear();
if (dob.getMonth() > today.getMonth() ||
dob.getMonth() === today.getMonth() &&
dob.getDate() >= today.getDate()) {
thisYear -= 1;
}

vimdiff cheat sheet

##git mergetool

In the middle file (future merged file), you can navigate between conflicts with ]c and [c.

Choose which version you want to keep with :diffget //2 or :diffget //3 (the //2 and //3 are unique identifiers for the target/master copy and the merge/branch copy file names).

:diffupdate (to remove leftover spacing issues)

:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)

#!/usr/bin/env ruby
require 'rubygems'
require 'twitter'
require 'json'
require 'faraday'
# things you must configure
PATH_TO_DROPBOX = "/Users/your_name/Dropbox/backup/tweets/" # you need to create this folder
TWITTER_USER = "your_twitter_username"

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

// Inspired by http://css-tricks.com/vertically-center-multi-lined-text/
@mixin vertical-center-children($height: auto, $children: ':first-child') {
display: table;
height: $height;
#{$children} {
display: table-cell;
vertical-align: middle;
}
}
# Encapsulate the configuration DSL pattern.
#
# Any `X=(value)` setter method on the given +obj+ is translated into `X(value)` method
# in the context of this object.
class ConfigDSL < BasicObject
def initialize(obj, &config)
@self = obj
call(&config)
end
body {
width: 100%;
height: 500px;
margin: 0;
padding: 0;
text-align: center;
}
body:before {
display: inline-block;
content: ' ';

Number to Ordinal

See full kata at codewars

Finish the function numberToOrdinal, which should take a number and return it as a string with the correct ordinal indicator suffix (in English). That is:

  • numberToOrdinal(1) ==> '1st'
  • numberToOrdinal(2) ==> '2nd'
  • numberToOrdinal(3) ==> '3rd'
  • numberToOrdinal(4) ==> '4th'
@jrhorn424
jrhorn424 / 0_reuse_code.js
Created August 15, 2014 21:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jrhorn424
jrhorn424 / fizz.rb
Created August 13, 2014 19:01 — forked from ggilder/fizz.rb
messages = [nil, "Fizz", "Buzz", "FizzBuzz"]
acc = 810092048
(1..100).each do |i|
c = acc & 3
puts messages[c] || i
acc = acc >> 2 | c << 28
end
# Explanation
#