Skip to content

Instantly share code, notes, and snippets.

@webcss
webcss / mithril-touch.js
Last active May 26, 2020 15:34
mithril-touch, consume touch and mouse events evenly with mithril
/*****************************************
/* DOM touch support module
/*****************************************/
if (!window.CustomEvent) {
window.CustomEvent = function (event, params) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
};
(function (exports) {
/**
* Dependencies
* - jsbn.js
* - jsbn2.js
* - prng4.js
* - ec.js
* - sec.js
* - rng.js
#!/usr/bin/env ruby -w
# brew-services(1) - Easily start and stop formulas via launchctl
# ===============================================================
#
# ## SYNOPSIS
#
# [<sudo>] `brew services` `list`<br>
# [<sudo>] `brew services` `restart` <formula><br>
# [<sudo>] `brew services` `start` <formula> [<plist>]<br>
@Amanieu
Amanieu / chase_lev.cpp
Last active January 20, 2023 11:57
Chase-Lev deque implementation
// Copyright (c) 2013 Amanieu d'Antras
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
anonymous
anonymous / gist:5408941
Created April 18, 2013 00:37
// Make sure the socket is coming from our app by matching the session id
socketServer.set('authorization', function (data, accept) {
cookieParser(data, {}, function(err) {
if (err) {
accept(err, false);
} else {
config.sessionStore.load(data.signedCookies[config.sessionKey], function(err, session) {
if (err || !session) {
accept('Session error', false);
} else {
@rkh
rkh / response_size.rb
Created August 10, 2011 10:12 — forked from jergason/app.rb
Checking size of each request
require 'rack'
##
# Tries to calculate size of the complete response.
# This middleware should be chained in front of everything else.
# Middleware taking care of compression, etag handling etc could
# produce wrong results.
#
# Leaves streaming intact and does work file bodies from sockets
# and files.
require "rubygems"
require "datamapper"
DataMapper.setup(:default, "sqlite::memory:")
DataMapper::Logger.new(STDOUT, :debug)
class Recipe
include DataMapper::Resource
property :id, Serial
@durango
durango / items.php
Created June 29, 2011 01:12
Just showing someone the basics of closures...
<?php
class item {
public $player_id, $ids, $sql, $vars = array();
private $functions = array();
function __construct($sql=null) {
$this->sql = $sql;
$this->sql->query('SHOW FIELDS FROM items');
for($x=0;$x<$this->sql->rows;$x++) {
$this->sql->fetch($x);
@britishtea
britishtea / trades.rb
Created June 27, 2011 22:01
Bitcoin trade data
# I turned the script into a Ruby gem. To install it, first install Rubygems if you haven't already. Instructions are here: https://rubygems.org/pages/download. Next type: sudo gem install trades
#
# To run the script type:
# trades
#
# Or if you only want to see trades from specific exchanges:
# trades mtgoxUSD thUSD britcoinGBP
#
# You can specify as many exchanges as you want. Just make sure you use the same name Bitcoincharts uses.
#
@dkubb
dkubb / ev.rb
Created March 16, 2011 22:13
Poor-man's Embedded Value
class User
include DataMapper::Resource
property :id, Serial
property :username, String, :required => true, :unique => true
property :address_street_address, String
property :address_location, String
property :address_subdivision, String
property :address_country, String