Skip to content

Instantly share code, notes, and snippets.

@ctford
ctford / boids.cljs
Created March 31, 2015 20:24
Independent boids
(ns universe.core
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]))
(def app-state (atom {:text "Hello Boids"
:birds (map vector
(repeatedly 20 #(rand-int 1000))
(repeatedly 20 #(rand-int 1000)))}))
(defn make-bird [[x y]]
@threedaymonk
threedaymonk / mandel.clj
Created September 11, 2012 20:32
UTF-8 Mandelbrot in Clojure
(def screen-width 100)
(def screen-height 30)
(defn scaled-x [x]
(- (* (/ x screen-width) 3.5) 2.5))
(defn scaled-y [y]
(- (* (/ y screen-height) 2) 1))
(defn mandel [x y iteration x0 y0 max-iteration]
@mashdot
mashdot / msmtprc
Created May 6, 2012 14:27
mutt + offlineimap + msmtp +msmtpQ
#Time-stamp: <2012-05-06 Sun 16:07 msmtprc>
# This file must have no more than user read/write permissions.
account work
host mail.work.net
user someone.something@work.net
password password
auto_from off
from someone.something@work.net
maildomain work.net
@Zulko
Zulko / limehouse_nights_moviepy.py
Last active September 14, 2017 20:37
Source for my music video on Gershwin's Limehouse Nights
"""
Code for a music video where sheet music is
scrolled transparently on my hands playing the
piano. See that effect here:
https://www.youtube.com/watch?v=V2XCJNZjm4w
"""
from moviepy.editor import *
@keegoid
keegoid / mutt.conf
Last active October 1, 2017 23:44
A Mutt config file with PGP, Gmail settings and storing aliases and sigs in Dropbox
# A basic .muttrc for use with Gmail and GPG
set imap_user="###@gmail.com"
set imap_pass="###"
set smtp_url="smtp://###@gmail.com@smtp.gmail.com:587/"
set smtp_pass="###"
set from="###@gmail.com"
set realname="###"
set editor="vi"
set folder="imaps://imap.gmail.com:993"
set spoolfile="+INBOX"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# addnote.py by JP Mens (September 2015), inspired by Martin Schmitt
# Usage: addnote subject "body (may be empty") [image ...]
# Adds a Notes.app (OSX and iOS) compatible message to the "Notes"
# IMAP folder. The IMAP store is configured from a file called
# `creds':
#
# [imap]
# hostname =
@simonjbeaumont
simonjbeaumont / tmup
Last active October 13, 2021 11:03
Update bash to latest tmux environment on reattaching.
#!/bin/bash
tmup ()
{
echo -n "Updating to latest tmux environment...";
export IFS=",";
for line in $(tmux showenv -t $(tmux display -p "#S") | tr "\n" ",");
do
if [[ $line == -* ]]; then
unset $(echo $line | cut -c2-);
@yasaichi
yasaichi / x_means.py
Last active August 31, 2022 12:18
Implementation of X-means clustering in Python
"""
以下の論文で提案された改良x-means法の実装
クラスター数を自動決定するk-meansアルゴリズムの拡張について
http://www.rd.dnc.ac.jp/~tunenori/doc/xmeans_euc.pdf
"""
import numpy as np
from scipy import stats
from sklearn.cluster import KMeans
@genegoykhman
genegoykhman / qb2ledger
Created September 22, 2012 04:19
Converts a QuickBooks General Journal CSV export to a ledger_cli compatible transaction file. More details at http://www.timetiger.com/gene/blog/2012/2012-09-23-an-alternative-to-quickbooks.html
#! /usr/bin/env ruby
require 'csv'
require 'Date'
require 'optparse'
SCRIPT_VERSION = [1, 0, 0]
class Transaction
attr_accessor :transaction_id, :type, :date, :num, :rows
def initialize
@pedrovgp
pedrovgp / upsert_df.py
Last active February 11, 2024 20:44
Allow upserting a pandas dataframe to a postgres table (equivalent to df.to_sql(..., if_exists='update')
# Upsert function for pandas to_sql with postgres
# https://stackoverflow.com/questions/1109061/insert-on-duplicate-update-in-postgresql/8702291#8702291
# https://www.postgresql.org/docs/devel/sql-insert.html#SQL-ON-CONFLICT
import pandas as pd
import sqlalchemy
import uuid
import os
def upsert_df(df: pd.DataFrame, table_name: str, engine: sqlalchemy.engine.Engine):