Skip to content

Instantly share code, notes, and snippets.

@davegurnell
davegurnell / PostfixCalcEither.scala
Last active December 1, 2017 12:58
Postfix calculator with ADT-based error handling
package calc
sealed trait Term
case object Add extends Term
case object Sub extends Term
case object Mul extends Term
case object Div extends Term
case class Num(value: Int) extends Term
sealed trait Error
@garyrussell
garyrussell / FileSplitter.java
Last active May 31, 2016 11:28
File Splitter **This example is now obsolete - use the FileSplitter that's now part of the framework**
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@jaf0
jaf0 / qs.js
Created August 1, 2014 15:32 — forked from jonmaim/qs.js
/* Converts an object into a key/value par with an optional prefix. Used for converting objects to a query string */
var qs = function(obj, prefix){
var str = [];
for (var p in obj) {
var k = prefix ? prefix + "[" + p + "]" : p,
v = obj[p];
str.push(angular.isObject(v) ? qs(v, k) : (k) + "=" + encodeURIComponent(v));
}
return str.join("&");
}
@CMCDragonkai
CMCDragonkai / angularjs_directive_attribute_explanation.md
Last active November 29, 2023 15:35
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@yinchuan
yinchuan / download_voa.py
Last active April 14, 2022 07:27
下载VOA慢速英语的脚本,下载内容保存在D:\VOA目录下。
# -*- coding: utf8 -*-
# 下载速度很慢,
import urllib2, urllib
import sys
import os
import socket
import re
import socks
@zhenyi2697
zhenyi2697 / gist:5662278
Last active December 17, 2015 19:39
Git: set up alias
# Alias for local user
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.st status
git config --global alias.unstage 'reset HEAD --'
git config --global alias.last 'log -1 HEAD'
git config --global color.ui true
# Global alias for all users
sudo git config --system alias.co checkout
@iros
iros / API.md
Created August 22, 2012 14:42
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@dwayne
dwayne / installing-pil.md
Created August 14, 2012 21:12
Installing PIL on Ubuntu 12.04 LTS

Steps to install PIL

$ sudo apt-get install python-imaging
$ sudo apt-get install libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev

$ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/
$ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/
$ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/

$ pip install PIL

@zhenyi2697
zhenyi2697 / gist:1973973
Created March 4, 2012 17:21 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt