Skip to content

Instantly share code, notes, and snippets.

@Happy-Ferret
Happy-Ferret / git2go-checkout-branch.go
Created September 7, 2016 10:14 — forked from danielfbm/git2go-checkout-branch.go
How to do a git checkout branch using git2go
package main
import (
"errors"
"log"
"github.com/libgit2/git2go"
)
func checkoutBranch(repo *git.Repository, branchName string) error {
checkoutOpts := &git.CheckoutOpts{
@Happy-Ferret
Happy-Ferret / purescript-vs-elm.md
Created September 20, 2016 12:06
Elm vs PureScript -- I've typed this or something similar enough times to just stick it in a Gist : ]

I'm convinced one of them (or something similar) will be the future, but it's too soon to say for sure. The Elm community is growing crazy fast and it's really focused on being beginner-friendly and having a good dev experience (see this recent talk from Elm's creator: https://www.youtube.com/watch?v=oYk8CKH7OhE). This focus has kept the language simple and lots of work has been done on making the compiler errors helpful and instructive. Elm also limits communication with JS to an interface called 'ports', basically just message passing that both sides must parse and act on. Elm also has focused pretty exclusively on coding client-side UIs (i.e. the Angular or Ember or (most similarly) React+Redux space)

PureScript is a similar idea (a statically typed functional language compiling to JS), but with a different background and different short-term goals. PureScript modules compile to CommonJS modules. PureScript functions compile to JS functions. The FFI (talking to JS code) is more like TypeScript or F

@Happy-Ferret
Happy-Ferret / CommonJS.md
Created October 19, 2016 07:37 — forked from Yoric/CommonJS.md
Migrating from JSM to CommonJS

Even if we move to RequireJS modules, we still need to keep a version of Cu.import to avoid breaking Thunderbird and add-ons. Maintaining this version of Cu.import should also help with migrating some corner case modules, tests, etc.

The following steps are designed so that we can land them one at a time:

Progressively move from EXPORTED_SYMBOLS to exports

  1. Ensure our .jsm don't define a global exports or this.exports. I believe that the easiest way to do this is to patch mozJSComponentLoader to detect such globals and MOZ_ASSERT(false). Rewrite code that violates this invariant.
  2. Patch up mozJSComponentLoader to inject a global exports in loaded files.
  3. Patch up mozJSComponentLoader to use exports instead of EXPORTED_SYMBOLS if available.
@Happy-Ferret
Happy-Ferret / snake.go
Created November 14, 2016 23:49 — forked from elwinar/snake.go
ToSnake function for golang, convention-compliant
package main
import (
"unicode"
)
// ToSnake convert the given string to snake case following the Golang format:
// acronyms are converted to lower-case and preceded by an underscore.
func ToSnake(in string) string {
runes := []rune(in)
@Happy-Ferret
Happy-Ferret / my_thoughts_on_msgpack.md
Created November 23, 2016 13:52 — forked from frsyuki/my_thoughts_on_msgpack.md
My thoughts on MessagePack

My thoughts on MessagePack

Hi. My name is Sadayuki "Sada" Furuhashi. I am the author of the MessagePack serialization format as well as its implementation in C/C++/Ruby.

Recently, MessagePack made it to the front page of Hacker News with this blog entry by Olaf, the creator of the Facebook game ZeroPilot. In the comment thread, there were several criticisms for the blog post as well as MessagePack itself, and I thought this was a good opportunity for me to address the questions and share my thoughts.

My high-level response to the comments

To the best of my understanding, roughly speaking, the criticisms fell into the following two categories.

@Happy-Ferret
Happy-Ferret / how_i_write_tests_for_node_and_the_browser.markdown
Created November 28, 2016 06:57
how I write tests for node and the browser

In node I use simple test libraries like tap or tape that let you run the test files directly. For code that needs to run in both the browser and node I use tape because tap doesn't run in the browser very well and the APIs are mostly interchangeable.

The simplest kind of test I might write in test/ looks like:

var test = require('tape');
var someModule = require('../');

test('fibwibblers and xyrscawlers', function (t) {
 t.plan(2);
@Happy-Ferret
Happy-Ferret / tabbycatswag.json
Created December 31, 2016 11:40 — forked from oldwestaction/tabbycatswag.json
hack for the tabby cat chrome extension to unlock all the accessories
{"collected":["glasses-1","glasses-2","glasses-3","glasses-4","hat-1","hat-2","hat-3","hat-4","hat-5","hat-6","hat-7","hat-8","toy-1","toy-2","toy-3","toy-4","toy-5","toy-6","toy-7","toy-8"],"active":{"hat":"hat-8","toy":"toy-3","glasses":"glasses-3"},"unseen":[],"shuffle":false}
@Happy-Ferret
Happy-Ferret / Program.cs
Created January 1, 2017 14:36 — forked from kevinswiber/Program.cs
Passing messages between Node.js and C#.
using System;
using System.Text;
namespace NodeIPC
{
class Program
{
static void Main(string[] args)
{
var input = Console.OpenStandardInput();
@Happy-Ferret
Happy-Ferret / kernel_sgd.py
Created January 9, 2017 06:34 — forked from mblondel/kernel_sgd.py
Kernel SGD
# Mathieu Blondel, May 2012
# License: BSD 3 clause
import numpy as np
def euclidean_distances(X, Y=None, Y_norm_squared=None, squared=False):
XX = np.sum(X * X, axis=1)[:, np.newaxis]
YY = np.sum(Y ** 2, axis=1)[np.newaxis, :]
distances = np.dot(X, Y.T)
distances *= -2