Skip to content

Instantly share code, notes, and snippets.

@ahoy-jon
ahoy-jon / small-Y.clj
Last active April 22, 2017 05:37
Small and pluggable Y combinator in clojure.
;; ; made this macro scraching my head between the simplicity of Haskell for fix
;; ; and the absence of curryfication in Clojure.
;; (P expr-fn) ; makes expr-fn lazy
;; (P P expr-fn) ; curry one time expr-fn
;; (P P P expr-fn) ; curry two time expr-fn
;; (= ((((P P P str) "a") "b") "c") "abc") ;=> true
(defmacro P [& f]
(let [x (gensym 'x)] ;; cannot be replaced by x# due to nested macro expansion.
@StephenWakely
StephenWakely / selecttags.cljs
Created October 9, 2014 22:22
Select Tags Om component
(ns acme.selecttags
(:require-macros [cljs.core.async.macros :refer [go alt!]])
(:require [cljs.core.async :refer [put! <! >! chan timeout]]
[om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[acme.shared-controls :as shared]
[cljs-http.client :as http]
[acme.server :as server]
[clojure.string :as str]))
'''
Copyright (c) <2012> Tarek Galal <tare2.galal@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:
@MichaelDrogalis
MichaelDrogalis / gist:bc620a7617396704125b
Last active May 22, 2018 14:26
The Anatomy of an Onyx Program

The Anatomy of an Onyx Program

In this tutorial, we'll take an in-depth view of what's happening when you execute a simple Onyx program. All of the code can be found in the Onyx Starter repository if you'd like to follow along. The code uses the development environment with HornetQ and ZooKeeper running in memory, so you don't need additional dependencies to run the example for yourself on your machine.

The Workflow

At the core of the program is the workflow - the flow of data that we ingest, apply transformations to, and send to an output for storage. In this program, we're going to ingest some sentences from an input source, split the sentence into individual words, play with capitalization, and add a suffix. Finally, we'll send the transformed data to an output source.

Let's examine the workflow pictorially:

'''
Copyright (c) <2012> Tarek Galal <tare2.galal@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:
@sebmarkbage
sebmarkbage / transferring-props.md
Last active August 2, 2022 10:44
Deprecating transferPropsTo

Deprecating transferPropsTo

It's a common pattern in React to wrap a component in an abstraction. The outer component exposes a simple property to do something that might have more complex implementation details.

We used to have a helper function called transferPropsTo. We no longer support this method. Instead you're expected to use a generic object helper to merge props.

render() {
 return Component(Object.assign({}, this.props, { more: 'values' }));
@aminamid
aminamid / README.md
Created April 17, 2014 03:28
Chatserver by angularJS + geventwebsocket + flask

Location

./test.py ./static/index.html ./static/client.js

Usage

python ./test.py

@jlecour
jlecour / post_to_slack.rb
Last active May 22, 2022 17:43
How to post alerts from Monit to Slack
# encoding: UTF-8
require 'optparse'
require 'net/http'
require 'json'
def parse_options(argv)
opts = {}
@parser = OptionParser.new do |o|
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@pauloalem
pauloalem / blocking_tornado.py
Last active March 28, 2016 23:34
Example of how to offload a blocking task to a threadpool to avoid locking tornado using tornado.gen and multiprocessing
# -*- coding: utf-8
from time import sleep, time
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.web import Application, asynchronous, RequestHandler
from multiprocessing.pool import ThreadPool
from tornado import gen
pool = ThreadPool(10)