Skip to content

Instantly share code, notes, and snippets.

View andreasjansson's full-sized avatar

Andreas Jansson andreasjansson

View GitHub Profile
@andreasjansson
andreasjansson / cog-dev.md
Created January 25, 2023 09:49
Develop inside Cog container

Develop inside Cog container

Start a shell inside the container:

cog run bash

This will mount your working directory into /src inside the container.

When the shell has started, install ipython:

@@ -38,6 +38,8 @@ const (
RowType
BarGaugeType
HeatmapType
+ TimeseriesType
+ StateTimelineType
)
const MixedSource = "-- Mixed --"
@@ -59,6 +61,8 @@ type (
from scipy.signal import convolve2d
import sys
import multiprocessing
import numpy as np
shapes = [
np.array([
[1, 0, 0, 1],
[1, 0, 0, 1],
[1, 1, 1, 1],
;; spotify-play-track
;; osx only 🙈
(defun osascript (script)
(shell-command-to-string (concat "osascript -e " (shell-quote-argument script))))
(defun spotify-uri-bounds-of-thing-at-point ()
(save-excursion
(skip-chars-backward "a-zA-Z0-9:")
(cons (point) (progn (skip-chars-forward "a-zA-Z0-9:") (point)))))
@andreasjansson
andreasjansson / gist:a675ef49e6999f951c67
Last active February 14, 2016 19:35
4PL curve fitting with gnuplot
$ gnuplot -e 'set term dumb size 100, 30; set fit quiet; set xr [1000:20000]; f(x) = (a - d) / (1 + ((x / c) ** b)) + d; fit f(x) "acc.txt" u 1:2 via a, b, c, d; p "acc.txt" u 1:2 w l notit, f(x) w l notit'
80 ++---+--------+---------+---------+--------+---------+--------+---------+--------+--------++
| + + + + + + + + + +
79 ++ #################
| * *******############## |
| * *****************#** |
78 ++ * ** ************ *** * * ++
@andreasjansson
andreasjansson / billboard.json
Created October 17, 2015 23:23
Billboard Top 100, crawled from http://www.umdmusic.com/
This file has been truncated, but you can view the full file.
[{"date": "2015-09-26 00:00:00", "name": "BILLBOARD SINGLES", "songs": [{"position": 1, "artist": "THE WEEKND", "title": "Can't Feel My Face"}, {"position": 2, "artist": "THE WEEKND", "title": "The Hills"}, {"position": 3, "artist": "JUSTIN BIEBER", "title": "What Do You Mean?"}, {"position": 4, "artist": "SILENTO", "title": "Watch Me"}, {"position": 5, "artist": "OMI", "title": "Cheerleader"}, {"position": 6, "artist": "MAJOR LAZER x DJ SNAKE featuring M0", "title": "Lean On"}, {"position": 7, "artist": "SELENA GOMEZ featuring A$AP ROCKY", "title": "Good For You"}, {"position": 8, "artist": "FETTY WAP featuring REMY BOYZ", "title": "679"}, {"position": 9, "artist": "R. CITY featuring ADAM LEVINE", "title": "Locked Away"}, {"position": 10, "artist": "ED SHEERAN", "title": "Photograph"}, {"position": 11, "artist": "DEMI LOVATO", "title": "Cool For The Summer"}, {"position": 12, "artist": "TAYLOR SWIFT", "title": "Wildest Dreams"}, {"position": 13, "artist": "SKRILLEX & DIPLO featuring JUSTIN BIEBER", "title":
@andreasjansson
andreasjansson / youtube.txt
Last active October 18, 2015 00:37
YouTube play counts for most jammed tracks on ThisIsMyJam.com (crawled 2015-09-29)
grimesoblivion 18441827
altjbreezeblocks 70737601
lorderoyals 513468680
thelumineershohey 134697041
chvrchesthemotherweshare 11418762
gotyesomebodythatiusedtoknow 685106679
arcticmonkeysdoiwannaknow 217387511
ofmonstersandmenlittletalks 158730595
alabamashakesholdon 14149362
djangodjangodefault 3871704
@andreasjansson
andreasjansson / logreg.el
Last active August 29, 2015 14:16
regularized logistic regression in emacs lisp
;; -*- lexical-binding: t -*-
(eval-when-compile
(require 'cl))
(defun rnd (from to)
(let ((r (/ (random 10000) 10000.0)))
(+ (* r (- to from)) from)))
(defun init-weights (n-inputs n-outputs)
function conky_format(format, number)
return string.format(format, conky_parse(number))
end
function conky_average(...)
local sum = 0
local count = 0
for _, v in ipairs({...}) do
sum = sum + conky_parse(v)
(require 'cl)
(defun new-shell ()
"Create new shells with consecutive names *shell-1*, *shell-2*, etc.
Remove any stale shells (shells without a live process)"
(interactive)
(let* ((regex "^\\*shell-\\([0-9]+\\)\\*$")
(shell-buffers (loop for buffer in (buffer-list)
if (string-match regex (buffer-name buffer))
collect buffer))