Skip to content

Instantly share code, notes, and snippets.

View edwardloveall's full-sized avatar
👈
there he is

Edward Loveall edwardloveall

👈
there he is
View GitHub Profile
@edwardloveall
edwardloveall / gist:1390880
Created November 24, 2011 08:15
Return Current Season According to Equinoxes/Solstices
function getSeason (dateString) { // format "mm/dd/yy"
var d = typeof(dateString) == "undefined" ? new Date() : new Date(dateString), // use today if nothing is passed in
month = d.getMonth()+1,
day = d.getDate(),
seasonCode = month+(day/100); // mm.dd
if (seasonCode < 3.21) { return "Winter"}
else if (seasonCode < 6.21) { return "Spring"}
else if (seasonCode < 9.22) { return "Summer"}
else if (seasonCode < 12.21) { return "Fall"}
@edwardloveall
edwardloveall / gist:1406484
Created November 29, 2011 21:00
Soft Button
button {
-moz-box-shadow: inset 0px 1px 0px 0px #ffffff;
-webkit-box-shadow: inset 0px 1px 0px 0px #ffffff;
box-shadow: inset 0px 1px 0px 0px #ffffff;
background: -webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ededed), color-stop(1, #dfdfdf) );
background: -moz-linear-gradient( center top, #ededed 5%, #dfdfdf 100% );
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#dfdfdf');
background-color: #ededed;
-moz-border-radius: 2em;
@edwardloveall
edwardloveall / gist:1407853
Created November 30, 2011 03:24
Mac Style Button
button {
display: inline-block;
padding: .2em 1.1em;
color: #000 !important;
text-align: center;
background-image: #eeeeee;
background-image: -moz-linear-gradient(top, #eeeeee 50%, #d4d4d4 100%);
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(50%, #eeeeee), color-stop(100%, #d4d4d4));
background-image: -webkit-linear-gradient(top, #eeeeee 50%, #d4d4d4 100%);
background-image: -o-linear-gradient(top, #eeeeee 50%, #d4d4d4 100%);
@edwardloveall
edwardloveall / application_helper.rb
Created March 2, 2012 20:21
Create a unique "string hash" based off of a seed string
def random_str(length, options = {})
srand(options[:seed].int_hash)
(0...length).map{97.+(rand options[:range]).chr}.join
end
# random_str(5, {seed: "edward", range: 5})
# => "adbae"
# random_str(10, {seed: "edward", range: 26})
# => "yhwtfxpjqe"
@edwardloveall
edwardloveall / gist:2372221
Created April 13, 2012 00:23
Markdown helper for Redcarpet ~> 2.1.1
def to_markdown(text)
md_renderer = Redcarpet::Render::HTML.new(:hard_wrap => true)
md_options = [:autolink => true]
markdown = Redcarpet::Markdown.new(md_renderer, *md_options)
markdown.render(text).html_safe
end
@edwardloveall
edwardloveall / hack.sh
Last active October 4, 2015 11:27 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
#!/usr/bin/ruby
require 'time'
def format_time(seconds)
hours = (seconds / 3600).to_i
minutes = ((seconds % 3600) / 60).to_i
seconds = (seconds % 60).to_i
minutes = "0#{minutes}" if minutes < 10
seconds = "0#{seconds}" if seconds < 10
@edwardloveall
edwardloveall / rails_centOS_setup.mdown
Created August 6, 2012 23:40 — forked from bricker/rails_centOS_setup.mdown
Get a Rails app running on vanilla CentOS (5 or 6) via Nginx & Passenger in minutes

Setup RVM/Ruby, Nginx/Passenger, and Rails in minutes on vanilla CentOS (5 or 6)

July 1, 2012

Based on articles at http://articles.slicehost.com/centos

This gist only covers the steps that are necessary to get a Rails app running quickly via RVM, nginx and Passenger. It disregards security in many cases (such as RVM & iptables)! Go through the articles above for more on that.

Please note that I wrote this after I had already got it all working, so I apologize if

From http://ponyho.st/
,_
|\'.
\ \ \ ,_
\|_,|-'`'-')\'.-.
;-' | \ \ `'--._
/ | | | `-.
| \ | /
\_,/\_/`-._/\_.-;'-._
/ __ \/ \/ \_,
@edwardloveall
edwardloveall / location.js
Created November 20, 2012 18:45
Get location in JS
location_callback = function(location) {
console.log(location);
}
navigator.geolocation.getCurrentPosition(location_callback);