Skip to content

Instantly share code, notes, and snippets.

@potch
potch / mozApp.js
Created May 3, 2012 16:22
simple open web app lib
// manage a webapp.
// place <link rel="app-manifest" href="path-to-manifest.webapp"> in your <head>
// mozApp.install() attempts installation
// mozApp.uninstall() removes
// mozApp.isRunning() indicates whether the app is currently installed and open
var mozApp = (function() {
var manLink = document.querySelector('link[rel="app-manifest"]'),
manifestURL = manLink.href;
var self = false;
@jsocol
jsocol / gist:2696070
Created May 14, 2012 19:43
Bash prompt function
_prompt() {
local _prompt=$1
local _out=$2
local _default=$3
local _val=''
if [ $_default ]; then
_prompt="${_prompt} [${_default}]"
fi
read -p "$_prompt " _val
if [ $_val ]; then
@harthur
harthur / snippet.md
Created June 18, 2012 22:12
console.log() key binding for Sublime Text

Go to Sublime Text 2 > Preferences > Key Bindings - User and add this JSON to the file:

[
    { "keys": ["super+shift+l"],
      "command": "insert_snippet",
      "args": {
        "contents": "console.log(${1:}$SELECTION);${0}"
      }
 }
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@atopal
atopal / gist:3906711
Created October 17, 2012 16:57
a/b testing of new forum excerpts
SELECT table_numerator.ds, table_numerator.numerator AS clicks, table_denominator.denominator AS searches, round((table_numerator.numerator/ table_denominator.denominator), 2) AS CTR
FROM
(
select ds, count(*) AS numerator
FROM research_logs
WHERE
ds > '2012-10-09'
AND `domain`='support.mozilla.com'
AND ip_address != 'NULL' AND http_version = 200 AND request_type = 'GET'
AND parse_url(empty_string_1,'PATH') RLIKE '\\/en-US\/search\$'
@cstipkovic
cstipkovic / formatDate.js
Last active July 31, 2017 03:02
A simple format Date function using Javascript prototype
/*
Based on Rick Strahl code
http://www.west-wind.com/weblog/posts/2008/Mar/18/A-simple-formatDate-function-for-JavaScript
Contributors:
Clauber Stipkovic - @clauberhalic
Mário Rinaldi - @MarioRinaldi
*/
Date.prototype.formatDate = function (format) {
@mythmon
mythmon / workflow.mkd
Last active December 12, 2015 04:49
A sketch for a software development work flow.

Problem statement

Sprints work pretty well, but they can get messy when contributors start being involved, or when bugs overflow the time boundaries of a sprint (ie a bug was started near the end of a sprint, and isn't finished at the end of the sprint). Sometimes sprints can feel like "mini waterfalls". On the other hand, sprints have the advantage of letting PMs easily define what work should be done, and helping this information flow from PMs to developers. They also help timebox projects, so that we can say "this will be done during this two week cycle. This predictability is important. Surprised estimations are teh suck. It isn't fair to ask a developer to make an estimate on something that they haven't worked on before without time to do some research.

Goals:

  • Reduce dependency on a fixed two week cycle.
  • Maintain a level of predictability, within the error margins of estimation.
  • Keep the amount of metawork to a minimum.
  • Reduce the amount of "surprise estimations".
for file in `git diff-tree --no-commit-id --name-only -r HEAD | sort | uniq`
do
if [ ${file: -3} == ".py" ]
then
flake8 --ignore=E121,E123,E124,E125,E126,E127,E128 $file
fi
if [ ${file: -3} == ".js" ]
then
jshint $file
fi
#!/bin/bash
function remote_by_name() {
name=$1
remote_line=$(git remote -v | grep push | grep $name)
if [[ -z $remote_line ]]; then
echo "Error: remote '$name' not found."
exit 1
# coding=UTF-8
from __future__ import division
import re
# This is a naive text summarization algorithm
# Created by Shlomi Babluki
# April, 2013
class SummaryTool(object):