Skip to content

Instantly share code, notes, and snippets.

@gdotdesign
gdotdesign / dabblet.css
Created February 17, 2012 09:39
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
.wrapper {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
@gdotdesign
gdotdesign / ClientMiddleware.rb
Created February 27, 2012 16:14
Faye Client Middleware for rack
module Faye
class ClientMiddleware
def initialize(app)
@app = app
end
def get_client
@fc ||= Faye::Client.new('http://localhost:3000/faye')
end
def call(env)
env['faye.client'] = get_client
@gdotdesign
gdotdesign / config.ru
Created March 25, 2012 19:50
INK API Implementation
require "net/http"
require 'cgi'
class Hash
# Create a Query String from a Hash
def to_query
def to_query
map { |k,v|
::CGI.escape(k.to_s)+"="+::CGI.escape(v)
}.join("&")
Mediator = {
events: {}
listeners: {}
fireEvent: (type,event)->
if @listeners[type]
@listeners[type].apply @, event
addListener: (type,callback) ->
@listeners[type] = callback
removeListener: (type) ->
delete @listeners[type]
@gdotdesign
gdotdesign / gist:3487990
Created August 27, 2012 12:24
ConvertCurrency
convertCurrency = (input) ->
value = $(input).val().replace /[^\d\.]/g, ''
float = parseFloat(value)
float = 0 if isNaN(float)
precision = parseInt(input.attr('data-precision'))
if precision is 0
val = float.toString().replace /\.\d*/, ''
else
val = float.toString().replace new RegExp("(\\.\\d{#{precision}})\\d*"), '$1'
val = parseFloat val
@gdotdesign
gdotdesign / api.cr
Created December 18, 2015 13:29
Jarvis
require "kemal"
require "process"
require "redis"
require "secure_random"
class Action
def run
end
end
@gdotdesign
gdotdesign / Ext.Date.Elm
Last active December 22, 2015 15:11
Date Stuff
module Ext.Date where
{-| Utility functions for dates.
# Create
@docs now, createDate
# Querying
@docs month, daysInMonth, datesInMonth
sendAsEffect : Signal.Address a -> a -> (() -> b) -> Effects.Effects b
sendAsEffect address value action =
Signal.send address value
|> Effects.task
|> Effects.map action
type Action
= Tasks ()
| RunTask
update : Action -> Model -> (Model, Effects.Effects Action)
update action model =
case action of
RunTask ->
(model, sendAsEffect address value Tasks)
type alias Model tag id err =
{ create : String -> List tag -> Task err tag
, failAddress : Maybe (Signal.Address err)
, remove : tag -> Task err tag
, input : Ui.Input.Model
, label : tag -> String
, tags : List tag
, removeable : Bool
, id : tag -> id
, disabled : Bool