Skip to content

Instantly share code, notes, and snippets.

View dylanvee's full-sized avatar

Dylan Vassallo dylanvee

View GitHub Profile
@nsfmc
nsfmc / upgrade_datastore.zsh
Created September 26, 2013 21:30
saves my old appengine datastore and replaces it with a new one
function upgrade_datastore () {
local ds_source="${HOME}/Dropbox/Khan Academy All Staff/Other shared items/datastores"
local ds_target="${HOME}/projects/.gae"
local backup_name="current.sqlite $(date "+%Y-%m-%d %H.%M.%S")"
mv "${ds_target}/current.sqlite" "${ds_target}/${backup_name}"
cp "${ds_source}/current.sqlite" "${ds_target}/"
echo "Copied new current.sqlite from dropbox"
echo "Your old current.sqlite has been archived at "
echo " ${fg[yellow]}${ds_target}/${backup_name}"
}
@alanhamlett
alanhamlett / api.py
Last active January 24, 2023 21:03
Serialize SQLAlchemy Model to dictionary (for JSON output) and update Model from dictionary attributes.
import uuid
import wtforms_json
from sqlalchemy import not_
from sqlalchemy.dialects.postgresql import UUID
from wtforms import Form
from wtforms.fields import FormField, FieldList
from wtforms.validators import Length
from flask import current_app as app
from flask import request, json, jsonify, abort
$ = jQuery
$.fn.lineHeight or= ->
if height = @data('lineHeight')
return height
# Create a hidden div with the same font
# properties, then measure its height
$shadow = $('<span />')
$shadow.css({
@veryeli
veryeli / generating script
Last active December 19, 2015 21:49
Covering relationships from topictree
# To run:
# install graphviz commands
# Download topictree from http://www.khanacademy.org/api/v1/topictree
# open ipython or something and run the following script. Save the output
# as, for instance, covers.gv
# run:
# dot covers.gv -T ps > out.ps
# open out.ps
# Make it look better by playing with it and then let me know what you did!
/*
* call-seq:
* Rugged::Repository.new(name, options = {}) -> repository
*
* Open a Git repository with the given +name+ and return a +Repository+ object
* representing it.
*
*/
static VALUE rb_git_repo_new(int argc, VALUE *argv, VALUE klass)
{
# A program that works jobs in newly created UNIX
# process by calling fork. The number of processes
# running at any given time is bounded by our use
# of a sized queue.
require 'thread'
# Run at most 4 UNIX processes for any given time.
@limiter = SizedQueue.new(4)

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@kghost
kghost / go.patch
Last active December 16, 2015 16:59
ws.go
diff -r d5666bad617d src/pkg/net/file.go
--- a/src/pkg/net/file.go Thu Sep 27 15:36:22 2012 -0700
+++ b/src/pkg/net/file.go Wed Apr 24 11:49:35 2013 -0400
@@ -7,10 +7,132 @@
package net
import (
+ "errors"
+ "io"
"os"
/**
* Simple node.js style script loader for modern browsers
**/
function loadScript(src, cb) {
var script = document.createElement('script');
script.async = true;
script.src = src;
script.onerror = function() {
cb(new Error("Failed to load" + src));
@seanh
seanh / README.md
Last active March 27, 2021 17:06
My ZSH prompt in Python

My ZSH prompt in Python, with:

  • A horizontal rule (as wide as the terminal) before each prompt (when scrolling this makes it easier to see where one command's output ends and the next command begins)
  • Nicely truncated current working directory (like fish shell)
  • Active virtualenv
  • Git branch
  • Non-zero exit status
  • user@host only if connected over ssh