Skip to content

Instantly share code, notes, and snippets.

//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@mrflip
mrflip / gist:766608
Created January 5, 2011 17:15
Elasticsearch shell config
We couldn’t find that file to show.
@rlivsey
rlivsey / id_rsa.pub
Created May 7, 2011 15:52
Public Key
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvkilybbL7t0VRLaTa+Du8Im7bO1ouZDoDnogD36bLScHCKEwH7awpQyqEtSKF+IFLw/rk+TfEEnTZZPX6gmnbuNK5LjGpbiQU5OtJe9l84ZynjmP+slKnbmdcF/1384ltA/q2KlMZy8JMwcvHUc22yK+Ysl3ftM9BDkQY20Qb+zbDjVfjRh5t4mXpCiNXku7ZPrdmkBkiHcTxi1fO2WLpDDXk0FjvFK+YLfKcB0v+BlKB1wakw06fn7B45v2ibIPcpf1gTzIeT0CuAPOYx/O9ZGtwU4PV9tNbMGfq+zm9j9MlE53gbeDlHiPkbwqvSkbqKHsRx1m1JMuPc7X8lNP2w== rlivsey@unbeliever.local
# These are my notes from the PragProg book on CoffeeScript of things that either
# aren't in the main CS language reference or I didn't pick them up there. I wrote
# them down before I forgot, and put it here for others but mainly as a reference for
# myself.
# assign arguments in constructor to properties of the same name:
class Thingie
constructor: (@name, @url) ->
# is the same as:
@nathansmith
nathansmith / file_input_example.css
Created December 9, 2011 14:56
Markup to Hide a File Input
.fake_file_input {
background: url(../images/fake_file_input.png) no-repeat;
cursor: pointer;
width: 150px;
height: 30px;
overflow: hidden;
position: relative;
display: inline-block;
*display: inline;
*zoom: 1;
def output name=((default=true); "caius")
puts "name: #{name.inspect}"
puts "default: #{default.inspect}"
end
output
# >> name: "caius"
# >> default: true
output "avdi"
@jamesarosen
jamesarosen / ember-views-and-states.md
Created January 11, 2012 00:21
On Ember Views & States

I have a state machine for the major sections of the page:

App.States = Ember.StateManger.create({
  foo: Ember.State.create({})
});

I have a view that needs to reset itself whenever the user enters the foo state:

Viz.WidgetsController = Ember.ArrayController.extend
init: ->
@refresh()
setInterval (=> @refresh), 5000
refresh: ->
$.ajax
url: @get('src'),
type: "GET",
context: this,
@justindossey
justindossey / gist:2063267
Created March 17, 2012 17:38
MongoMapper-- check that replicas are within a minute of primary
def all_replicas_in_sync?(verbose=false)
in_sync = true
# connect to the primary
mongo = Mongo::Connection.new(*MongoMapper.connection.primary)
db = mongo.db('local')
last_op=db.collection('oplog.rs').find.sort([['$natural',-1]]).limit(1).to_a[0]
db.collection('slaves').find().to_a.each do |slave|
opdiff = last_op['ts'].increment - slave['syncedTo'].increment
diff = (last_op['ts'].seconds - slave['syncedTo'].seconds)/1000.0
in_sync = false if diff > 60
@charlesjolley
charlesjolley / dev_view.coffee
Created August 21, 2012 03:57
Adding event locks to Ember
# example view implements a simple dragging for mouse events.
Wall.DevView = Ember.View.extend
mouseDown: (ev) ->
ev.dispatcher.lock @, 'mouseMove', 'mouseUp'
@_mouseDown = @$().offset()
@_mouseDown.pageX = ev.pageX
@_mouseDown.pageY = ev.pageY
@_mouseDown.dispatcher = ev.dispatcher
console.log 'mouseDown'