Skip to content

Instantly share code, notes, and snippets.

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

Taybin Rutkin taybin

🤷‍♂️
¯\_(ツ)_/¯
View GitHub Profile
@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
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 / 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(