Skip to content

Instantly share code, notes, and snippets.

class Thing
constructor: (obj)->
# do stuff with obj
obj # I want this returned
new_thing = new Thing(x: 1)
console.log(new_thing.x) # I want 1 but I get undefined

Keybase proof

I hereby claim:

  • I am jwoertink on github.
  • I am jeremywoertink (https://keybase.io/jeremywoertink) on keybase.
  • I have a public key whose fingerprint is AF5E 8AEF 4CB8 6611 3037 C44C 8336 1F37 B055 1836

To claim this, I am signing this object:

@jwoertink
jwoertink / xmpp.js
Created September 26, 2014 23:33
An example of using XMPP to do messaging
var Client = require('node-xmpp-client'),
ltx = require('node-xmpp-core').ltx;
var client = new Client({jid: '[email protected]', password: 'password'});
client.on('online', function(data) {
console.log('Connected as ' + data.jid.user + '@' + data.jid.domain + '/' + data.jid.resource)
var presence = new ltx.Element('presence', { type: 'available' }).c('show').t('chat');
client.send(presence);
});
require 'spec_helper'
describe HomeController do
describe '#show' do
it 'renders the taco view when params[:page] is set to taco' do
get(:show, :page => 'pricing')
response.should render_template('home/pricing')
end
end
@jwoertink
jwoertink / directive.coffee
Last active August 29, 2015 14:07
A small timer directive for AngularJS
# assumes there's already a window.timer = {}
app.directive 'callTimer', ->
opts =
restrict: 'E'
controller: ($scope, $rootScope)->
$scope.minutes = (window.timer?.state.minutes || 0)
$scope.seconds = (window.timer?.state.seconds || 0)
$scope.$on 'start-timer', -> $scope.startTimer()
# find dependencies
asterisk/contrib/scripts/install_prereq
# dialplan examples
exten => some_ext,priority,application
same => n(label),application
same => n,Goto(label) ;comments
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<a href="#" onclick="process.mainModule.exports.printer()">Click to print</a>
</body>
</html>
module TimeZone
DAYLIGHT = [
{name: 'Dateline Daylight Time', offset: -12, alt: 'International Date Line West'},
{name: 'UTC-11', offset: -11, alt: 'International Date Line West'},
{name: 'Hawaiian Daylight Time', offset: -10, alt: 'Hawaii'},
{name: 'Alaskan Daylight Time', offset: -9, alt: 'Alaska'},
{name: 'Pacific Daylight Time', offset: -8, alt: 'Pacific Time (US & Canada)'},
{name: 'US Mountain Daylight Time', offset: -7, alt: 'Mountain Time (US & Canada)'},
{name: 'Mountain Daylight Time', offset: -7, alt: 'Mountain Time (US & Canada)'},
{name: 'Central America Daylight Time', offset: -6, alt: 'Central Time (US & Canada)'},
require "kemal"
require "pg"
DB = PG.connect(ENV["DATABASE_URL"])
get "/" do |env|
env.response.content_type = "application/json"
result = DB.exec("SELECT id, username FROM members LIMIT 1000")
result.to_hash.to_json
end
require "kemal"
class AuthorizationHandler < HTTP::Handler
ACCEPT = "application/vnd.api.v1+json"
def call(env)
if env.request.headers["Accept"] != ACCEPT
env.response.status_code = 401
end
call_next(env)
end