Skip to content

Instantly share code, notes, and snippets.

View siman's full-sized avatar
🏠
Working from home

Alex Siman siman

🏠
Working from home
View GitHub Profile
@retronym
retronym / type-bounds.scala
Created December 16, 2009 11:17
Tour of Scala Type Bounds
class A
class A2 extends A
class B
trait M[X]
//
// Upper Type Bound
//
def upperTypeBound[AA <: A](x: AA): A = x
@softprops
softprops / key_opts.md
Created June 24, 2011 06:11
sbt function operator cheatsheet

key independent functions

:=   binds single value
+=   appends single value
++=  appends seq of values

key dependent functions

<<=  binds single value

<+= appends single value

@m242
m242 / gist:1205631
Created September 9, 2011 06:43
Scala Option in JavaScript
var MyOption, Option;
Array.prototype.filter = function(f) {
var x, _i, _len, _results;
_results = [];
for (_i = 0, _len = this.length; _i < _len; _i++) {
x = this[_i];
if (f(x)) {
_results.push(x);
}
@geetchandratre
geetchandratre / play_scala_jade
Created June 4, 2013 12:24
Play 2.x + SBT + Scala + Jade
All you need to do is,
In your SBT Dependencies add,
"de.neuland" % "jade4j" % "0.3.11" from "https://raw.github.com/neuland/jade4j/master/releases/de/neuland/jade4j/0.3.11/jade4j-0.3.11.jar",
"com.googlecode.concurrentlinkedhashmap" % "concurrentlinkedhashmap-lru" % "1.3.1",
"org.apache.commons" % "commons-jexl" % "2.1.1"
You need apache libs as Jade4J uses them internally,
@guersam
guersam / AutoProductFormat.scala
Last active March 8, 2017 19:26
Macro-based json format generator for spray-json (https://github.com/spray/spray-json)
package spray.json
import scala.language.experimental.macros
trait AutoProductFormat extends DefaultJsonProtocol {
implicit def jsonFormat[T <: Product]: RootJsonFormat[T] = macro AutoProductFormatMacro.autoProductFormatMacro[T]
}
object AutoProductFormat extends AutoProductFormat
@ricardo-rossi
ricardo-rossi / ElasticSearch.sh
Last active December 1, 2023 04:55
Installing ElasticSearch on Ubuntu 14.04
#!/bin/bash
### USAGE
###
### ./ElasticSearch.sh 1.7 will install Elasticsearch 1.7
### ./ElasticSearch.sh will fail because no version was specified (exit code 1)
###
### CLI options Contributed by @janpieper
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch
@bithavoc
bithavoc / postgres-notify-trigger.sql
Last active February 2, 2019 09:31
I used this trigger to notify table changes via NOTIFY (migrating off RethinkDB)
CREATE OR REPLACE FUNCTION notify_trigger() RETURNS trigger AS $$
DECLARE
channel_name varchar DEFAULT (TG_TABLE_NAME || '_changes');
BEGIN
IF TG_OP = 'INSERT' THEN
PERFORM pg_notify(channel_name, '{"id": "' || NEW.id || '"}');
RETURN NEW;
END IF;
IF TG_OP = 'DELETE' THEN
PERFORM pg_notify(channel_name, '{"id": "' || OLD.id || '"}');
@siman
siman / jquery-in-browser-console.js
Created April 20, 2017 23:59
Inject jQuery into browser console
var script = document.createElement("script");
script.setAttribute("src", "//code.jquery.com/jquery-latest.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
@abrkn
abrkn / index.js
Created October 13, 2017 20:53
kraken-minimal-trader
#!/usr/bin/env node
const assert = require('assert');
const { delay } = require('bluebird');
const BigNumber = require('bignumber.js');
const kraken = require('./kraken');
const {
fetchMyOpenOrders,
fetchOrderBook,
placeOrder,
@siman
siman / image-proxy.conf
Created September 24, 2018 21:08 — forked from tmaiaroto/image-proxy.conf
Nginx Image Filter Resize Proxy Service
# Feel free to change this path of course (and keys_zone value as well, but also change the usage of it below).
proxy_cache_path /var/www/cache/resized levels=1:2 keys_zone=resizedimages:10m max_size=1G;
# Gzip was on in another conf file of mine...You may need to uncomment the next line.
#gzip on;
gzip_disable msie6;
gzip_static on;
gzip_comp_level 4;
gzip_proxied any;
# Again, be careful that you aren't overwriting some other setting from another config's http {} section.