Skip to content

Instantly share code, notes, and snippets.

View alejandrodumas's full-sized avatar
💻

Ezequiel Erbaro alejandrodumas

💻
  • Buenos Aires, Argentina
View GitHub Profile
@desandro
desandro / require-js-discussion.md
Created January 31, 2013 20:26
Can you help me understand the benefit of require.js?

I'm having trouble understanding the benefit of require.js. Can you help me out? I imagine other developers have a similar interest.

From Require.js - Why AMD:

The AMD format comes from wanting a module format that was better than today's "write a bunch of script tags with implicit dependencies that you have to manually order"

I don't quite understand why this methodology is so bad. The difficult part is that you have to manually order dependencies. But the benefit is that you don't have an additional layer of abstraction.


@stucchio
stucchio / bayes_bandit_empirical_gain_from_incorporating_priors.py
Created April 28, 2013 22:17
Empirical gain from incorporating priors into the Bayesian Bandit
from numpy import *
from scipy.stats import beta
import random
class BetaBandit(object):
def __init__(self, num_options=2, prior=None):
self.trials = zeros(shape=(num_options,), dtype=int)
self.successes = zeros(shape=(num_options,), dtype=int)
self.num_options = num_options
@hadley
hadley / r-is-like.md
Last active December 13, 2021 22:41
A lighthearted and overly flattering comparison of R to other programming languages: what other comparisons have I missed?

R is like:

  • Clojure, because most objects are immutable
  • Scala, because it combined functional and OO techniques
  • Node.js, because the interpreter is single threaded
  • PHP, because it favours pragmatism over purity
  • Lisp, because it's homoiconic
  • Perl, because OO is (mostly) implemented using the language itself
@erogol
erogol / WTA_kernel_binary
Created August 30, 2013 16:06
Google's Winner Takes All hashing implemmentation
function[binary_codes,G_vecs] = WTA_kernel_binary(X,G_vecs,G, K)
% G is number of permutation vectors
% K is the insterest span
if size(G_vecs,1) == 0
G_vec = zeros(G,size(X,2));
for i = 1:G
G_vecs(i,:) = randperm(size(X,2),size(X,2));
end
end
@tinabeans
tinabeans / template.html
Last active February 13, 2024 09:18
A super-barebones single-column responsive email template, assuming a max-width of 540px. Read about it on the Fog Creek blog.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Single-Column Responsive Email Template</title>
<style>
@media only screen and (min-device-width: 541px) {
.content {
@eanakashima
eanakashima / errors.js.coffee
Created December 10, 2013 19:32
client-side error beacon code in coffeescript
class YourNamespace.Errors
window.onerror = (e) => @report(e)
@report: (e) ->
img = new Image(1,1)
img.src = '//' + your_config.errors_host + '/images/error_pixel.gif'
img.style.display='none'
document.getElementsByTagName('body')[0].appendChild(img);
@subfuzion
subfuzion / redis-autostart-osx.md
Last active April 26, 2024 21:40
redis auto start OS X

Install with Homebrew

brew install redis

Set up launchctl to auto start redis

$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents

/usr/local/opt/redis/ is a symlink to /usr/local/Cellar/redis/x.y.z (e.g., 2.8.7)

@redox
redox / base.html.haml
Last active May 16, 2020 13:13
Algolia extends HipChat to customer support
#chat-box.ubuntu.hidden-xs
.closed
.pull-right
= link_to_function content_tag(:i, nil, class: 'glyphicon glyphicon-chevron-up').html_safe, 'chat.show()'
.m-l-small
= link_to_function 'Chat with us', 'chat.show()'
.opened{style: 'display: none'}
.header
.pull-right
= link_to_function content_tag(:i, nil, class: 'glyphicon glyphicon-plus-sign').html_safe, 'chat.maximize()', class: 'maximize', style: 'display: none'
import numpy as np
class Data_generator(object):
def __init__(self,K,d,reward_type='binary'):
self.d = d # dimension of the feature vector
self.K = K # number of bandits
self.reward_type = reward_type