Skip to content

Instantly share code, notes, and snippets.

View taybin's full-sized avatar
🤷‍♂️
¯\_(ツ)_/¯

Taybin Rutkin taybin

🤷‍♂️
¯\_(ツ)_/¯
View GitHub Profile
@taybin
taybin / dynamic_stopwords.sql
Created July 1, 2017 03:21
Technique for looking up stopwards from a table, instead of a static file in postgres
CREATE TABLE IF NOT EXISTS stopwords (
word VARCHAR(20) NOT NULL;
);
CREATE OR REPLACE FUNCTION remove_stopwords(string TEXT, OUT tsv TSVECTOR) AS
$$
BEGIN
SELECT string_agg(words.*, ' ')::tsvector FROM
-- split tsvector into row for each word
regexp_split_to_table(
var https = require('https');
var util = require('util');
exports.handler = function(event, context) {
console.log(JSON.stringify(event, null, 2));
console.log('From SNS:', event.Records[0].Sns.Message);
var postData = {
"channel": "#aws-sns",
"username": "AWS SNS via Lamda :: DevQa Cloud",
@taybin
taybin / nodetest.ex
Last active August 29, 2015 14:07
ecto many to many test
defmodule NodeTest do
use ExUnit.Case
test "can have childen and parents" do
node1 = %Node{name: "parent"} |> Repo.insert
node2 = %Node{name: "child2"} |> Repo.insert
%NodeToNode{parent_id: node1.id, child_id: node.id} |> Repo.insert
assert Node.get_children(node1) == [node2]
assert Node.get_parents(node2) == [node1]
end
@taybin
taybin / gist:16a30c08b73ae76a72be
Created October 3, 2014 13:59
ecto get parents/children
defmodule Node do
import Ecto.Query, only: [from: 2]
def get_children(node) do
from(n in Node,
join: n2n in NodeToNode, on: n.id == n2n.parent_id,
inner_join: n1 in Node, on: n1.id == n2n.child_id,
select: n1,
where: n.id == ^node.id)
|> Repo.all
defmodule Node do
use Ecto.Model
schema "nodes" do
has_many :children, NodeToNode, foreign_key: :parent_id
has_many :parents, NodeToNode, foreign_key: :child_id
end
end
defmodule NodeToNode do
@taybin
taybin / gist:ffc8c18f9c8459f5f47a
Last active August 29, 2015 14:07
ecto node migration
defmodule Repo.Migrations.CreateNodes do
use Ecto.Migration
def up do
[
"CREATE TABLE IF NOT EXISTS nodes(id SERIAL PRIMARY KEY, name TEXT NOT NULL, script TEXT)",
"CREATE TABLE IF NOT EXISTS node_to_node(parent_id INTEGER NOT NULL REFERENCES nodes(id) ON DELETE CASCADE, child_id INTEGER NOT NULL REFERENCES nodes(id) ON DELETE CASCADE)"
]
end
@taybin
taybin / gist:22f13ad1a5c90db23e6a
Last active October 19, 2015 09:59
ecto many to many association
defmodule Foo.Model.Job do
alias Foo.Model.JobToJob, as: JobToJob
use Ecto.Model
schema "jobs" do
field :name, :string
has_many :children, JobToJob, foreign_key: :parent_id
has_many :parents, JobToJob, foreign_key: :child_id
end
end
@taybin
taybin / git-ffwd-update
Created May 4, 2012 02:37
update multiple branches at once
#!/bin/bash
# from http://stackoverflow.com/questions/620650/can-i-easily-update-all-local-git-branches-from-remote-branches-simultaneously
main() {
REMOTES="$@";
if [ -z "$REMOTES" ]; then
REMOTES=$(git remote);
fi
REMOTES=$(echo "$REMOTES" | xargs -n1 echo)
@taybin
taybin / Makefile
Created September 21, 2011 04:33 — forked from abackstrom/Makefile
CSS and JavaScript Minification/Compression Makefile
#
# css/js minification/compression makefile
#
#
# JS_TARGETS -- js files to minify/gzip
# CSS_TARGETS -- css files to minify/gzip
# CLEANUP -- additional files to delete during "make clean"
#
diff --git a/Makefile.in b/Makefile.in
index 7ab25ff..34f5f36 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -16,9 +16,9 @@ DYNAMIC_EXTENSION := .so
DYNAMIC_FULL_VERSION := .2.1.0
DYNAMIC_ABI_VERSION := .2
DYNAMIC_LIBNAME := librubberband$(DYNAMIC_EXTENSION)
-DYNAMIC_LDFLAGS := -shared -Wl,-Bsymbolic -Wl,-soname=$(DYNAMIC_LIBNAME)$(DYNAMIC_ABI_VERSION)
-VAMP_LDFLAGS := -shared -Wl,-Bsymbolic -Wl,--version-script=vamp/vamp-plugin.map