Skip to content

Instantly share code, notes, and snippets.

@laran
laran / gist:810520
Created February 4, 2011 00:33
502 when installing homebrew
foo $ ruby -e "$(curl -fsSL https://gist.github.com/raw/323731/install_homebrew.rb)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/Formula/...
/usr/local/Library/Homebrew/...
Press enter to continue
==> Downloading and Installing Homebrew...
curl: (22) The requested URL returned error: 504
Failed during: /bin/bash -o pipefail -c '/usr/bin/curl -sSfL https://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1'
@laran
laran / application.js
Created September 11, 2015 06:11 — forked from Genkilabs/application.js
Bootstrap 3 modals in Rails 4 confirms using bootstrap3-dialog JS plugin
//= require jquery
//= require jquery_ujs
//= require_tree .
// ^ I am assuming that bootstrap3-dialog is in the tree
//GLOBAL JQuery Functionality
$(function(){
/*** CONFIRM MODAL OVERRIDE ***/
//override the use of js alert on confirms
@laran
laran / examples.md
Last active March 5, 2016 10:01 — forked from ErisDS/examples.md
Ghost Filter Query examples

Filter Queries - Example Use Cases

Here are a few example use cases, these use cases combine filter with other parameters to make useful API queries. The syntax for any of this may change between now, implementation, and release - they're meant as illustrative examples :)

Fetch 3 posts with tags which match 'photo' or 'video' and aren't the post with id 5.

api.posts.browse({filter: "tags:[photo, video] + id:-5", limit="3"});

GET /api/posts?filter=tags%3A%5Bphoto%2Cvideo%5D%2Bid%3A-5&limit=3

@laran
laran / binary-tree-insert.js
Last active September 28, 2018 16:04
Add a value to a Binary Tree.
import Node from 'binary-tree-node';
class BinaryTree {
constructor() {
this.root = new Node();
}
// ... other methods
add(value) {
@laran
laran / .babelrc
Last active September 29, 2018 18:33
All permutations of an array
{
"presets": [
"env"
],
"env": {
"test": {
"presets": [
"env"
]
}
@laran
laran / edge-list.js
Last active September 29, 2018 22:52
An Edge List representation of a Graph
// Each element in the Array represents an Edge between the two Nodes with the IDs in that element.
// Every element in the array will have exactly two values.
// The indices of the elements in either the inner our outer Arrays have no meaning.
let graph = [[1, 2], [0, 3], [1, 3], [2, 0]];
@laran
laran / adjacency-list.js
Last active October 1, 2018 03:36
A Adjacency List representation of a Graph
// The index of the element in the outer Array is the 'id' of the Node in the Graph.
// Each element in the outer Array contains the Set of IDs to which that Node is connected.
//
// e.g. Node 0 has Edges to Nodes 1 and 2
// Node 1 has no Edges
// Node 2 has Edges to Nodes 0, 1 and 3
// Node 3 only has an Edge to Node 2
let graphAsList = [
[1, 2],
@laran
laran / adjacency-matrix.js
Last active September 30, 2018 00:10
An Adjacency Matrix representation of a Graph
// - An Adjacency Matrix stores the Set of all possible Edges.
// - Each row represents a Node, storing the complete Set of possible Edges for that Node.
// - The index of the element in the outer Array indicates the ID of the Node.
// - A value of 1 indicates an Edge. A 0 indicates no Edge.
//
// In this example:
// - Node 0 has an Edge to Node 3
// - Node 1 has Edges to Nodes 0 and 3
// - Node 2 has Edges to Nodes 0, 1 and 3
// - Node 3 has an Edge to Node 1
@laran
laran / Hanoi-output.txt
Created October 6, 2018 08:05
Output of Hanoi with 5 discs
Move #0: Initial state
1
2
3
4
5
- - -
Move #1: Move value=1 from Tower=0 to Tower=2
2
exports.handler = async function(event, context) {
// Your code goes here ...
let success = function() {
// Do stuff ...
};
// Exit the handler by invoking the callback.
// The first argument is an error object (null indicates success).