Skip to content

Instantly share code, notes, and snippets.

select sort(array_agg(select id from data where ts_rank(name_vector, name) > 0.8) || id) as bucket
from data
group by bucket
/* @TODO this query is slow because OFFSET is slow! */
with data as (
/* your query */
), sample_size as (select generate_series(1, /* sample size */))
select t.*
from (select trunc(random() * (select count(*) from data)) as offset_index from sample_size) sample
left join data t on t.id = (select id from data limit 1 offset sample.offset_index);
@munro
munro / StripBlockComment.hs
Created November 11, 2014 23:05
Strip block comments using Haskell Parsec
-- | commentBlockStart
-- >>> parse stripCommentBlock "fail" "hello world /* fo /*meow face */o */ bar * / * / /* poop /* zz **/*/ end"
-- Right "hello world bar * / * / end"
stripCommentBlock :: GenParser Char st String
stripCommentBlock = do
first <- many (noneOf "/")
rest <- (eof >> return "") <|> (commentBlock >> stripCommentBlock) <|> ((++) <$> string "/" <*> stripCommentBlock)
return (first ++ rest)
-- | commentBlock
-- | Generate list permutations in Haskell
-- >>> permutateList [[1,2], [3,4]]
-- [[1,3],[1,4],[2,3],[2,4]]
permutateList :: [[a]] -> [[a]]
permutateList = foldl (liftA2 (++)) [[]] . map (map (: []))
// Playground - noun: a place where people can play
import UIKit
func $(s1 : String) -> [String] {
return ["selector: " + s1]
}
func css(s1 : String) -> [String] -> [String] {
return { (data: [String]) -> [String] in
func apply<A, B> (data : A, fn : B) -> A {
return fn(data) // '(A) -> $T2' is not identical to 'B'
}
func apply<A, B : A -> A> (data : A, fn : B) -> A { // Expected '>' to complete generic parameter list
return fn(data)
}
`timescale 1ns / 1ps
module BinToDec(
input mclk,
input [7:0] sw,
output reg [3:0] an,
output reg [6:0] seg,
output reg [7:0] Led
);
Running sch2hdl...
Command Line: sch2hdl -batch C:/Users/Ryan/pong/sch2HdlBatchFile
Release 14.7 - sch2hdl P.20131013 (nt64)
Copyright (c) 1995-2013 Xilinx, Inc. All rights reserved.
Started : "Synthesize - XST".
Running xst...
Command Line: xst -intstyle ise -ifn "C:/Users/Ryan/pong/pong_top.xst" -ofn "C:/Users/Ryan/pong/pong_top.syr"
Reading design: pong_top.prj
myFunction :: Record -> Record -> a
foobar = myFunction Record { meow = "face" }
Record { meow = "face" }
-- vs --
myFunction :: (Record, Record) -> a
foobar = myFunction(
var Dockerfile;
if (!req.body.modules.length) {
Dockerfile = multiline.stripIndent(function () { return undefined; /*
FROM haskell-online-ghc
ADD execute.sh .
*/ });
} else {
Dockerfile = multiline.stripIndent(function () { return undefined; /*
FROM haskell-online-ghc