Skip to content

Instantly share code, notes, and snippets.

View ixaxaar's full-sized avatar
🏔️

ixaxaar ixaxaar

🏔️
View GitHub Profile
@djspiewak
djspiewak / streams-tutorial.md
Created March 22, 2015 19:55
Introduction to scalaz-stream

Introduction to scalaz-stream

Every application ever written can be viewed as some sort of transformation on data. Data can come from different sources, such as a network or a file or user input or the Large Hadron Collider. It can come from many sources all at once to be merged and aggregated in interesting ways, and it can be produced into many different output sinks, such as a network or files or graphical user interfaces. You might produce your output all at once, as a big data dump at the end of the world (right before your program shuts down), or you might produce it more incrementally. Every application fits into this model.

The scalaz-stream project is an attempt to make it easy to construct, test and scale programs that fit within this model (which is to say, everything). It does this by providing an abstraction around a "stream" of data, which is really just this notion of some number of data being sequentially pulled out of some unspecified data source. On top of this abstraction, sca

"UserData": {
"Fn::Base64": { "Fn::Join":["", [
"#!/bin/bash -ex\n",
"apt-get update\n",
"apt-get -y install python-setuptools\n",
"mkdir aws-cfn-bootstrap-latest\n",
"curl https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz | tar xz -C aws-cfn-bootstrap-latest --strip-components 1\n",
"easy_install aws-cfn-bootstrap-latest\n",
"/usr/local/bin/cfn-init --stack ", { "Ref":"AWS::StackName" }, " --resource WebServer", " --region ", { "Ref": "AWS::Region" }, "\n",
"\n",
@tixxit
tixxit / EditDistance.scala
Created September 28, 2011 03:10
Short Levenshtein distance implementation in Scala
package net.tixxit.levenshtein
import scala.math.min
object EditDistance {
def editDist[A](a: Iterable[A], b: Iterable[A]) =
((0 to b.size).toList /: a)((prev, x) =>
(prev zip prev.tail zip b).scanLeft(prev.head + 1) {
case (h, ((d, v), y)) => min(min(h + 1, v + 1), d + (if (x == y) 0 else 1))
}) last
@yahyaKacem
yahyaKacem / string_converter.py
Created December 29, 2013 13:51
Convert camel-case to snake-case in python. e.g.: CamelCase -> snake_case e.g.: snake_case -> CamelCase e.g.: CamelCase -> dash-case e.g.: dash-case -> CamelCase By: Jay Taylor [@jtaylor] Me<modifier>: Yahya Kacem <fuj.tyoli@gmail.com> Original gist: https://gist.github.com/jaytaylor/3660565
#!/usr/bin/env python
"""
Convert camel-case to snake-case in python.
e.g.: CamelCase -> snake_case
e.g.: snake_case -> CamelCase
e.g.: CamelCase -> dash-case
e.g.: dash-case -> CamelCase
By: Jay Taylor [@jtaylor]
Me<modifier>: Yahya Kacem <fuj.tyoli@gmail.com>
Original gist: https://gist.github.com/jaytaylor/3660565
@hyqneuron
hyqneuron / pytorch_visualize.py
Created June 7, 2017 07:06
PyTorch graph visualization
import torch
import torch.nn as nn
from torch.nn import Parameter
from torch.autograd import Variable, Function
from collections import defaultdict
import graphviz
"""
This is a rather distorted implementation of graph visualization in PyTorch.
@ijy
ijy / cartesian-product.js
Last active April 23, 2022 15:54
Underscore.js implementation of Cartesian Product (without any mutable variable). @see: http://stackoverflow.com/questions/12303989/cartesian-product-of-multiple-arrays-in-javascript
function cartesianProductOf() {
return _.reduce(arguments, function(a, b) {
return _.flatten(_.map(a, function(x) {
return _.map(b, function(y) {
return x.concat([y]);
});
}), true);
}, [ [] ]);
};
@louispan
louispan / minimal_ghc_ghcjs_nix.sh
Last active June 20, 2022 05:00
Install Cabal, GHC, or GHCJS with one Nix command
# install nix (5.5 mins)
curl https://nixos.org/nix/install | sh
# open a new shell to source nix
bash
# query available haskell compilers
nix-env -qaP -A nixpkgs.haskell.compiler [QUERY]
# install ghc (2.5 mins, cached binary)
@takeshy
takeshy / firehose-cloudwatch-logs-processor-elasticsearch_by_cloudwatch_subscription.js
Created February 23, 2020 03:49
kinesys firehose by cloudwatch subscription to elasticsearch
/*
For processing data sent to Firehose by Cloudwatch Logs subscription filters.
Cloudwatch Logs sends to Firehose records that look like this:
{
"messageType": "DATA_MESSAGE",
"owner": "123456789012",
"logGroup": "log_group_name",
"logStream": "log_stream_name",
@drmarshall
drmarshall / event_export.py
Created June 8, 2015 17:04
Example Mixpanel raw event export script
#! /usr/bin/env python
#
# Mixpanel, Inc. -- http://mixpanel.com/
#
# Python API client library to consume mixpanel.com analytics data.
import hashlib
import urllib
import time
try:
@iMilnb
iMilnb / boto3_hands_on.md
Last active October 19, 2022 09:15
Programmatically manipulate AWS resources with boto3 - a quick hands on

boto3 quick hands-on

This documentation aims at being a quick-straight-to-the-point-hands-on AWS resources manipulation with [boto3][0].

First of all, you'll need to install [boto3][0]. Installing it along with [awscli][1] is probably a good idea as

  • [awscli][1] is boto-based
  • [awscli][1] usage is really close to boto's