Skip to content

Instantly share code, notes, and snippets.

View andresilva's full-sized avatar
🌴
Off

André Silva andresilva

🌴
Off
  • Porto, Portugal
View GitHub Profile
@andresilva
andresilva / ycombinator.scala
Last active August 29, 2015 14:14
Scala Y Combinator
def Y[A, B](f: (A => B) => (A => B)): (A => B) = f(Y(f))(_)
val fac = Y[Int, Int](f => i => if (i <= 0) 1 else f(i - 1) * i)
fac(6)
@andresilva
andresilva / gist:ff5f16d34a2a60a147fc
Created February 5, 2015 20:27
rust missing libregex
λ racer → λ git master* → bin/racer [20:26:54]
dyld: Library not loaded: x86_64-apple-darwin/stage2/lib/rustlib/x86_64-apple-darwin/lib/libregex-4e7c5e5c.dylib
Referenced from: /Users/beat/Workbench/racer/bin/racer
Reason: image not found
[1] 7112 trace trap bin/racer
λ racer → λ git master* → rustc --version [20:27:12]
rustc 1.0.0-nightly (3b2ed1490 2015-02-03 14:56:32 +0000)
@andresilva
andresilva / helm-fuzzy.el
Created February 2, 2015 12:30
Helm fuzzy matching
(setq helm-buffers-fuzzy-matching t
helm-recentf-fuzzy-match t
helm-locate-fuzzy-match t
helm-M-x-fuzzy-match t
helm-semantic-fuzzy-match t
helm-imenu-fuzzy-match t
helm-apropos-fuzzy-match t)
@andresilva
andresilva / bst.rs
Last active August 29, 2015 14:13
rust bst
use std::rc::Rc;
use std::fmt::String as StringFmt;
use Tree::{Node, Tip};
#[derive(Show)]
enum Tree<T> {
Tip,
Node(Rc<Tree<T>>, T, Rc<Tree<T>>),
}
def time = mapRequestContext { ctx =>
val timerCtx = globalTimer.timerContext()
ctx.withHttpResponseMapped { response =>
timerCtx.stop()
response
}
}
-- Logs begin at Tue 2014-09-30 17:40:22 UTC, end at Tue 2014-09-30 17:44:46 UTC. --
Sep 30 17:40:39 ip-10-231-46-239.ec2.internal systemd[1]: Starting etcd...
Sep 30 17:40:39 ip-10-231-46-239.ec2.internal systemd[1]: Started etcd.
Sep 30 17:40:41 ip-10-231-46-239.ec2.internal etcd[565]: [etcd] Sep 30 17:40:41.301 INFO | The path /var/lib/etcd/log is in btrfs
Sep 30 17:40:41 ip-10-231-46-239.ec2.internal etcd[565]: [etcd] Sep 30 17:40:41.301 INFO | Set NOCOW to path /var/lib/etcd/log succeeded
Sep 30 17:40:41 ip-10-231-46-239.ec2.internal etcd[565]: [etcd] Sep 30 17:40:41.301 INFO | Discovery via https://discovery.etcd.io using prefix /faeededd4ecc5c2e8746bd8455053e98.
Sep 30 17:40:42 ip-10-231-46-239.ec2.internal etcd[565]: [etcd] Sep 30 17:40:42.348 INFO | Discovery found peers [http://10.184.159.239:7001]
Sep 30 17:40:42 ip-10-231-46-239.ec2.internal etcd[565]: [etcd] Sep 30 17:40:42.348 INFO | Discovery fetched back peer list: [10.184.159.239:7001]
Sep 30 17:40:44 ip-10-231-46-239
[Unit]
Description=RabbitMQ Disc Cluster Node
After=docker.service
Requires=docker.service
[Service]
TimeoutStopSec=2m
EnvironmentFile=/etc/environment
ExecStart=/bin/bash -c '\
docker run -p 22 -p 15672:15672 -p 4369:4369 -p 5672:5672 -p 35197:35197 -p 35198:35198 -e HOST_IP=$COREOS_PRIVATE_IPV4 --name rabbitmq rabbitmq:latest'
(let
(nth [li n]
(tif (= n 0)
(car li)
(recur (cdr li) (- n 1))))
(nth [0 1 2 3 4 5] 4))
directory: ~/music
plugins: mpdupdate scrub info inline convert
convert:
format: aac
opts: '-c:a libfdk_aac -vbr 4 -cutoff 18000'
dest: ~/transcode
paths:
default: $albumartist - $album/$track $title
(defun erc-notify-on-private-msg-darwin (proc parsed)
(let ((nick (car (erc-parse-user (erc-response.sender parsed))))
(target (car (erc-response.command-args parsed)))
(msg (erc-response.contents parsed)))
(when (and (erc-current-nick-p target)
(not (erc-is-message-ctcp-and-not-action-p msg))
(erc-notify-allowed-p nick))
(shell-command-to-string
(format "terminal-notifier -sender org.gnu.Emacs -message '%s says: %s'" nick msg))
nil)))