Skip to content

Instantly share code, notes, and snippets.

View dwayne's full-sized avatar

Dwayne Crooks dwayne

View GitHub Profile
require 'active_support/core_ext/time'
class BusinessHoursFeature
# This feature is only available between the hours of 10am and 4pm
def enabled?
Time.use_zone('Pacific Time (US & Canada)') do
now = Time.zone.now
am, pm = Time.zone.parse('10:00'), Time.zone.parse('16:00')
weekday = !(now.saturday? || now.sunday?)
@denzildoyle
denzildoyle / Vertical Center.css
Created June 6, 2014 01:30
Vertical align anything with out the need to define its height. With only 5 lines of code.
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
@mgold
mgold / proposal.elm
Last active February 12, 2016 01:34
Elm mailbox revamp
-- a distilation of https://github.com/elm-lang/elm-plans/issues/7
{- Mailbox is renamed Dispatcher, although this name is the part I'm least certain about.
The address field is replaced with a dispatch field.
It's minor, but I've found it helpful to put dispatch second, since the signal is easier to explain.
-}
type alias Dispatcher a =
{ signal : Signal a
, dispatch : a -> Message -- the big change
}
@tomdale
tomdale / gist:2494968
Created April 26, 2012 01:10
Ember.js View Context Change

View Context Changes

The rules for how Ember.js evaluates Handlebars templates have recently changed, and you may need to update your application's templates to ensure they continue working..

Template Contexts

Remember that a template is always evaluated against a context object. When you render a template, values are looked up from that object. For example:

Hello, {{firstName}} {{lastName}}!
AppState (Main.elm delegates to one of these)
LoggedIn
Context.elm
Init.elm
Model.elm
Msg.elm
Subscriptions.elm
Update.elm
UrlUpdate.elm
View.elm
@aseemk
aseemk / coffeescript-updates.md
Last active December 2, 2017 20:22
CoffeeScript upcoming changes.

CoffeeScript 1.7 is shaping up to be a pretty kick-ass release with significant improvements. Here are the ones I'm most excited about, in order of my own excitement.

Parentheses-free chaining

jashkenas/coffeescript#3263

Years of being wished for, finally granted!

@TheSeamau5
TheSeamau5 / HackerNewsExample.elm
Last active September 23, 2018 00:24
Hacker news requests example
--------------------------
-- CORE LIBRARY IMPORTS --
--------------------------
import Task exposing (Task, ThreadID, andThen, sequence, succeed, spawn)
import Json.Decode exposing (Decoder, list, int, string, (:=), map, object2)
import Signal exposing (Signal, Mailbox, mailbox, send)
import List
---------------------------------
-- THIRD PARTY LIBRARY IMPORTS --
@netzpirat
netzpirat / 0_README.md
Created November 12, 2010 10:42
Continuous CoffeeScript testing with Guard and Jasmine

Continuous CoffeeScript testing with Guard and Jasmine

This Gist shows how to set up a Rails project to practice BDD with CoffeeScript, Guard and Jasmine. You can see this setup in action on Vimeo

  • Install Gems with Bundler with bundle install
  • Define your guards with mate Guardfile
  • Initialize Jasmine with bundle exec jasmine init
  • Configure Jasmine with mate spec/support/yasmine.ym
  • Start Guard with bundle exec guard
@eriklott
eriklott / Client.elm
Last active February 19, 2019 10:12
Elm Backend Client
module YourAPIClient exposing (Config, otherFunctions)
import Http
import Json.Decode as Decode
import Json.Encode as Encode
-- Config