Skip to content

Instantly share code, notes, and snippets.

View enragedginger's full-sized avatar

Stephen Hopper enragedginger

View GitHub Profile
@marchelbling
marchelbling / 100-local-citus.sql
Last active July 5, 2023 15:47
Local Citus cluster setup — bis
-- user:
CREATE ROLE citus WITH NOSUPERUSER LOGIN IN ROLE pg_monitor;
-- database:
ALTER DATABASE citus SET citus.shard_replication_factor = 1;
ALTER DATABASE citus OWNER TO citus;
-- extensions:
CREATE EXTENSION IF NOT EXISTS "hll";
CREATE EXTENSION IF NOT EXISTS "topn";

Building pgModeler in MacOS with Homebrew

The official installation instructions for pgModeler recommends installing Xcode and the Enterprise DB distribution of Postgres to fulfill its build requirements. Luckily, Homebrew's got us covered!

  1. Checkout the source

    git clone https://github.com/pgmodeler/pgmodeler.git
    
(defn topo [graph]
(when-not (empty? graph)
(lazy-seq
(let [n (first (for [[node s] graph
:when (not (seq s))]
node))]
(assert n "if this fails there is a cycle")
(cons n (topo (into {} (for [[node deps] graph
:when (not= n node)]
[node (disj deps n)]))))))))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Uninstall brew package and dependencies

Remove package's dependencies (does not remove package):

brew deps [FORMULA] | xargs brew remove --ignore-dependencies

Remove package:

@stathissideris
stathissideris / channel-as-seq.clj
Last active October 20, 2020 19:14
clojure async channels as lazy (and blocking!) sequences
(defn seq!!
"Returns a (blocking!) lazy sequence read from a channel."
[c]
(lazy-seq
(when-let [v (<!! c)]
(cons v (seq!! c)))))
(comment
(def stream (chan))
(go (dotimes [x 16]
@ramn
ramn / Deserialization.scala
Last active October 18, 2023 17:42
Object serialization example in Scala
import java.io._
@SerialVersionUID(15L)
class Animal(name: String, age: Int) extends Serializable {
override def toString = s"Animal($name, $age)"
}
case class Person(name: String)
// or fork := true in sbt
@werkshy
werkshy / start-mysql-in-mem
Created March 29, 2013 14:37
Script to start a second mysql server using ramdisk/tmpfs for unit tests.
#!/bin/bash
DATADIR=/dev/shm/mysql
TMPDIR=/dev/shm/mysql_tmp
MYSQL_SOCKET=/dev/shm/mysql.sock
pkill -9 -f mysql.*datadir.*$DATADIR
mkdir -p $DATADIR
@jspaper
jspaper / YahooToken.rb
Created May 25, 2012 14:18
yahoo api with oauth-plugin
class YahooToken < ConsumerToken
YAHOO_SETTINGS={
:site => "https://api.login.yahoo.com",
:request_token_path => "/oauth/v2/get_request_token",
:access_token_path => "/oauth/v2/get_token",
:authorize_path=> "/oauth/v2/request_auth"
}
def self.consumer