This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## Script for searching for all references to a particular function in | |
## a clojure project (A crude implementation of "Find usage" | |
## functionality commonly found in IDEs such as Intellij) False | |
## positives are possible. | |
## | |
## Usage: | |
## | |
## $ clj-fn-usages NAMESPACE_QUALIFIED_FN [ paths ... ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns inclojure-mocks) | |
;; IN/Clojure 2018 lightning talk :: 13/01/2018 | |
;; | |
;; Topic: Mocking code (mainly for writing tests) | |
;; | |
;; Will be covered: | |
;; | |
;; 1. Mocking code using circleci/bond library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
usage() | |
{ | |
cat << EOF | |
usage: $(basename $0) [ -c COMMIT -v VAULT_PASSWORD_FILE ] -f FILE | |
To view the actual changes in ansible vault/secret files for a git commit. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import izip_longest | |
def fnone(f, *xs): | |
"""Takes a function f, and returns a function that calls f, replacing | |
a None first argument to f with the supplied value x. Higher arity | |
versions can replace arguments in the second and third | |
positions (y, z). Note that the function f can take any number of | |
arguments, not just the one(s) being None-patched. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from functools import wraps | |
def throttle_greedy(wait): | |
def decorator(fn): | |
state = {'last_call_at': None} | |
@wraps(fn) | |
def wrapper(*args, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn consume-until-timeout | |
[ms ch f init & args] | |
(let [tmt (timeout ms)] | |
(go (loop [ret init] | |
(if-let [v (first (alts! [ch tmt]))] | |
(recur (apply f ret [v])) | |
ret))))) | |
(comment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import d | |
x = 10 | |
def f(n): | |
return x + n | |
print 'f(2) called directly in module a [a.x = 10]' | |
print f(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Hands on R session by Harshad Saykhedkar from today's Machine | |
### learning workshop (Fifth elephant Mumbai run-up event) | |
--- | |
R version 3.1.0 (2014-04-10) -- "Spring Dance" | |
Copyright (C) 2014 The R Foundation for Statistical Computing | |
Platform: i686-pc-linux-gnu (32-bit) | |
R is free software and comes with ABSOLUTELY NO WARRANTY. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(message_ring). | |
-compile(export_all). | |
-export([]). | |
%% Problem Statement: Write a ring benchmark. Create N processes in a | |
%% ring. Send a message round the ring M times so that a total of N * | |
%% M messages get sent. Time how long this takes for different values | |
%% of N and M. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from operator import itemgetter | |
from threading import Thread | |
try: | |
from Queue import Queue | |
except ImportError: | |
from queue import Queue | |
def concurrently(fns): |
NewerOlder