Skip to content

Instantly share code, notes, and snippets.

@speier
speier / prompt.js
Created November 24, 2023 23:41 — forked from zckly/prompt.js
gpt-4-v skateboarding coach prompt
// model: gpt-4-vision-preview
const input = 'can you help me land this skateboarding trick?'
const frames = [
// Frames should be a list of image URLs or bytes
]
const messages = [
...messages,
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/

Backend Architectures

ARCHITECTURES

ror, scala, jetty, erlang, thrift, mongrel, comet server, my-sql, memchached, varnish, kestrel(mq), starling, gizzard, cassandra, hadoop, vertica, munin, nagios, awstats

@speier
speier / app.js
Created October 2, 2012 11:34 — forked from pixelhandler/app.js
Develop a RESTful API Using Node.js With Express and Mongoose - See: http://pixelhandler.com/blog/2012/02/09/develop-a-restful-api-using-node-js-with-express-and-mongoose/
var application_root = __dirname,
express = require("express"),
path = require("path"),
mongoose = require('mongoose');
var app = express.createServer();
// database
mongoose.connect('mongodb://localhost/ecomm_database');
@speier
speier / api.js
Created September 14, 2012 20:07 — forked from fwielstra/api.js
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
@speier
speier / JS Util solution using underscore.js
Created September 8, 2011 21:14 — forked from HenrikJoreteg/JS Util solution using underscore.js
Rather than creating some other util global, just extend underscore.js with any additional methods you want.
// If you don't use underscore.js, use it (http://documentcloud.github.com/underscore/)
// Then, use underscore's mixin method to extend it with all your other utility methods
// like so:
_.mixin({
escapeHtml: function () {
return this.replace(/&/g,'&')
.replace(/>/g,'>')
.replace(/</g,'&lt;')
.replace(/"/g,'&quot;')
.replace(/'/g,'&#39;');
@speier
speier / rubicon.coffee
Created September 8, 2011 08:18
Simple HTTP proxy for our node.js development environment
#!/usr/bin/env ./node_modules/coffee-script/bin/coffee
sys = require 'sys'
express = require 'express'
assets = require 'connect-assets'
proxy = require 'http-proxy'
server = proxy.createServer (req, res, proxy) ->
if req.url.match /^\/?api/
backend =
@speier
speier / paginated_collection.js
Created September 8, 2011 08:17 — forked from io41/paginated_collection.js
Pagination with Backbone.js
// includes bindings for fetching/fetched
var PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage');
typeof(options) != 'undefined' || (options = {});
this.page = 1;
typeof(this.perPage) != 'undefined' || (this.perPage = 10);
},
fetch: function(options) {
@speier
speier / README.md
Created September 1, 2011 18:53 — forked from chrisjacob/README.md
QUICK setup Github Pages + Cloud9 IDE for HTML/CSS/JavaScript hacking

QUICK setup Github Pages + Cloud9 IDE for HTML/CSS/JavaScript hacking

GitHub + GitHub Pages

  1. Get a GitHub account: https://github.com/
  2. Github > Dashboard > New Repository ... https://github.com/repositories/new
  3. Enter a Project Name and Description; click "Create Repository"
  4. On the project page ignore the suggested setup instructions... instead click on the "Admin" button
  5. Check the "GitHub Pages" checkbox... You'll get a popup.
  6. Click the "Automatic GitHub page Generator" button.
  7. Choose a funky colour... or go safe with just white... then click "Create Page" button
@speier
speier / redis-counters.coffee
Created August 15, 2011 08:46 — forked from mythz/redis-counters.coffee
Create and increment multiple counters with express, coffeescript and redis
#1. install node, npm and coffeescript
#2. >npm install express
#3. >npm install node_redis
#4. >npm install -d
redis = require('redis').createClient()
redis.on 'error', (err) -> console.log "Redis connection error to #{redis.host} : #{redis.port} - #{err}"
app = require('express').createServer()
#create and increment multiple counters in redis, via: http://localhost:3000/counters/my-counter