Skip to content

Instantly share code, notes, and snippets.

@micahwalter
micahwalter / base58.sql
Created October 7, 2014 22:47
base58.sql
DELIMITER $$
CREATE FUNCTION base58_encode (num bigint(64)) RETURNS varchar(255)
DETERMINISTIC
BEGIN
DECLARE alphabet varchar(255);
DECLARE base_count int DEFAULT 0;
DECLARE encoded varchar(255);
DECLARE divisor DECIMAL(10,4);
"use strict";
var Promise = require("bluebird");
var debug = require("debug")("app:utils/GridSQL");
var through2 = require("through2");
/**
* MongoDB's GridFS inspired data storage for Knex. The given file is saved to
* multiple binary columns in order to enable proper file streaming.
*
* GridSQL works like a key value store. All files must be written with an
anonymous
anonymous / gulp.js
Created September 11, 2014 15:33
'use strict';
var env = require('../env'),
gulp = require('gulp'),
streamify = require('gulp-streamify'),
imagemin = require('gulp-imagemin'),
browserify = require('browserify'),
watchify = require('watchify'),
reactify = require('reactify'),
envify = require('envify'),
'use strict';
var subclass = require('../util/subclass'),
Policy = require('./policy'),
Client = require('../models/client'),
Stylist = require('../models/stylist'),
AppointmentPolicy = subclass(Policy);
AppointmentPolicy.can('request', function (user, model) {
return user instanceof Client;
@ericeslinger
ericeslinger / document.coffee
Last active May 13, 2016 21:09
Add side-loads to BookshelfJS
Knex = require 'knex'
Promise = require 'bluebird'
FlormModel = require './flormModel'
Document = FlormModel.extend
tableName: 'documents'
# here's an example sideload construct. I want to know document editor ids, which are stored in the
# edges join table - that table stores parent_id and child_id polymorphically (with parent_type and child_type)
# also polymorphically with join type- 'grant: edit' denotes editorship.
@jordaaash
jordaaash / count.js
Last active June 19, 2021 13:03
Bookshelf.js/Knex.js innerJoin withRelated
var Promise = require('bluebird'),
User = require('./user'),
knex, query;
knex = User.prototype._builder(User.prototype.tableName);
query = function (q) {
q.distinct()
.innerJoin('orders', function () {
this.on('users.id', '=', 'orders.user_id')
@rtt
rtt / tinder-api-documentation.md
Last active October 6, 2025 20:20
Tinder API Documentation

Tinder API documentation

Note: this was written in April/May 2014 and the API may has definitely changed since. I have nothing to do with Tinder, nor its API, and I do not offer any support for anything you may build on top of this. Proceed with caution

http://rsty.org/

I've sniffed most of the Tinder API to see how it works. You can use this to create bots (etc) very trivially. Some example python bot code is here -> https://gist.github.com/rtt/5a2e0cfa638c938cca59 (horribly quick and dirty, you've been warned!)

@joyrexus
joyrexus / README.md
Last active February 12, 2024 19:59
The Stable Marriage Problem

My implementation of the Gale/Shapley algorithm in Python. This algorithm is designed to address the Stable Marriage Problem.

Compare this recursive variant with the implementations on Rosetta Code.

Problem description

Given an equal number of men and women to be paired for marriage, each man ranks all the women in order of his preference and each women ranks all the men in order of her preference.

A stable set of engagements for marriage is one where no man prefers a women over the one he is engaged to, where that other woman also prefers that man over the one she is engaged to. I.e. with consulting marriages, there would be no reason for the engagements between the people to change.

@thomasfr
thomasfr / Git push deployment in 7 easy steps.md
Last active October 5, 2025 07:57
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
create = {
handler: function(request, reply) {
return new Address().save({
name: request.payload.name,
address_line1: request.payload.address_line1
}).then(function(model) {
return new Address({
'id': model.id
}).fetch().then(function(model) {
return reply(model);