Skip to content

Instantly share code, notes, and snippets.

View galdolber's full-sized avatar

Gal Dolber galdolber

View GitHub Profile
@maxweber
maxweber / query_check.clj
Created May 13, 2016 16:41
Checks if a Datomic datalog query contains only allowed symbols / functions.
(require '[datomic.api :as d]
'[clojure.string :as str])
(defn normalize-query
"Turns a vector formatted Datomic datalog query into a map formatted
one."
[query]
(let [pairs (partition-by keyword? query)]
(assert (even? (count pairs)))
(into
@brianreavis
brianreavis / libvips.sh
Created August 21, 2015 19:46
Install an exact version of libvips (an adaptation of Lovell Fuller's script)
#!/bin/sh
# Ensures libvips is installed and attempts to install it if not
# Currently supports:
# * Debian Linux
# * Debian 7, 8
# * Ubuntu 12.04, 14.04, 14.10, 15.04
# * Mint 13, 17
# * Red Hat Linux
# * RHEL/Centos/Scientific 6, 7
# * Fedora 21, 22
(ns datascript-to-datomic-util
(:require [datascript :as d]))
;;;; a utility to help with a datomic-datascript roundtrip process involving:
;;; 1. export some data from a datomic database and transact into a datascript instance.
;;; 2. perform one or more transactions against datascript.
;;; 3. transact the sum of all changes made against datascript back into datomic in a single tx
;;; this namespace contains two public functions:
;;; listen-for-changes: listen to datascript transactions and build up a record of changes
@favila
favila / datomic-mysql-bootstrap.sql
Created January 22, 2015 17:49
Better MySQL bootstrap setup for datomic's datomic_kvs table
-- Optimized MYSQL schema for datomic
-- Unfortunately the bin/sql/mysql-*.sql bootstrapping files for datomic are not
-- very good, and can actually cause failures if not adjusted.
-- One symptom of this is the following error:
-- SQL Error (1071): Specified key was too long; max key length is 767 bytes.
-- Reported here: https://support.cognitect.com/entries/28462168-MySQL-Caveats
-- This is caused by the default collation for the `id` column possibly being
@aphyr
aphyr / gist:f72e72992dade4578232
Last active December 17, 2016 08:00
Clojure Keyword.intern
commit 8e51c34ca4d97e48750850d5ba09956f89783b4e
Author: Kyle Kingsbury <aphyr@aphyr.com>
Date: Wed May 7 19:06:15 2014 -0700
Improve Keyword.intern performance
Keyword interning is an expensive factor in many Clojure
serialization/deserialization paths, especially where the same set of
keywords are created and freed repeatedly; e.g. iterating over records
with similar structure. There are two principle costs to keyword
@yangshun
yangshun / youtube-vimeo-url-parser.js
Last active June 14, 2023 22:27
YouTube Vimeo URL Parser
function parseVideo (url) {
// - Supported YouTube URL formats:
// - http://www.youtube.com/watch?v=My2FRPA3Gf8
// - http://youtu.be/My2FRPA3Gf8
// - https://youtube.googleapis.com/v/My2FRPA3Gf8
// - Supported Vimeo URL formats:
// - http://vimeo.com/25451551
// - http://player.vimeo.com/video/25451551
// - Also supports relative URLs:
// - //player.vimeo.com/video/25451551
@azakordonets
azakordonets / simpleHttpServer.py
Created September 1, 2013 13:22
Python simple HTTP Server that get's two variables for launch - port and time delay( time after which server will return response) . If we do not specify this two values, then server starts on 8000 port with delay = 0
#!/usr/bin/env python
import SimpleHTTPServer, BaseHTTPServer, SocketServer, socket, time, sys
class ThreadedHTTPServer(SocketServer.ThreadingMixIn,
BaseHTTPServer.HTTPServer) :
"""
New features w/r to BaseHTTPServer.HTTPServer:
- serves multiple requests simultaneously
- catches socket.timeout and socket.error exceptions (raised from
@Chouser
Chouser / externs_for_cljs.clj
Created June 17, 2013 13:44
Generate an externs.js file for arbitrary JS libraries for use in advanced Google Closure compilation, based on the ClojureScript code that uses the libraries.
(ns n01se.externs-for-cljs
(:require [clojure.java.io :as io]
[cljs.compiler :as comp]
[cljs.analyzer :as ana]))
(defn read-file [file]
(let [eof (Object.)]
(with-open [stream (clojure.lang.LineNumberingPushbackReader. (io/reader file))]
(vec (take-while #(not= % eof)
(repeatedly #(read stream false eof)))))))
@larsmans
larsmans / kmeans.py
Created February 14, 2013 13:38
k-means clustering in pure Python
#!/usr/bin/python
#
# K-means clustering using Lloyd's algorithm in pure Python.
# Written by Lars Buitinck. This code is in the public domain.
#
# The main program runs the clustering algorithm on a bunch of text documents
# specified as command-line arguments. These documents are first converted to
# sparse vectors, represented as lists of (index, value) pairs.
from collections import defaultdict
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active April 19, 2024 11:00
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: