This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from random import random | |
n = 1 | |
w = 0. | |
while True: | |
s = random()*60. | |
w += 60.-s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# crude template for generating pinterest DMCA takedown request emails. | |
# send to: [email protected] | |
#example csv file: | |
#new,2018/01/25,https://no.pinterest.com/pin/489696159457745571/,url,http://url.com | |
#new,2018/01/25,https://no.pinterest.com/pin/34832597103507119/,desc,old | |
from jinja2 import Environment, DictLoader |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# -*- coding: utf-8 -*- | |
import sys | |
from json import loads | |
from json import dumps | |
try: | |
from pygments import highlight, lexers, formatters | |
def show(d): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
here=`pwd` | |
fld="$here/data" | |
mkdir -p "$fld" | |
docker run -p 9200:9200 \ | |
-p 9300:9300 \ | |
-e "discovery.type=single-node" \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defstruct vec2 | |
(x nil :type double-float :read-only t) | |
(y nil :type double-float :read-only t)) | |
(defstruct (vec3 (:include vec2)) | |
(z nil :type double-float :read-only t)) | |
(declaim (inline make-vec2)) | |
(declaim (inline make-vec3)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/sbcl --script | |
(declaim (inline rnd)) | |
(defun rnd (a) | |
(declare (double-float a)) | |
(the double-float (random (the double-float a)))) | |
(declaim (inline sb-kernel::%random-fixnum)) | |
(sb-ext:unlock-package 'sb-kernel) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
here=`pwd` | |
dir=$1 | |
if [ -z "$dir" ] | |
then | |
dir="." | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; for every line produced as in run-buffer in | |
; https://bitbucket.org/vityok/cl-faster-input/src/default/src/benchmark-read-line.lisp | |
; do this: | |
(defun proc-line (l) | |
(with-input-from-string (in l) | |
(let ((vals (loop for x = (read in nil nil) while x | |
collect (coerce x 'double-float)))) | |
(values (vec:3vec* (subseq vals 0 3)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun do-lines-as-floats (fn n fx &key (buffer-width 80)) | |
(declare (optimize (safety #.*sft*) (speed #.*spd*) (debug #.*dbg*)) | |
(function fx) (fixnum n buffer-width)) | |
(let ((buffer (make-array buffer-width :element-type 'character | |
:initial-element #\space))) | |
(with-open-file (is fn :direction :input) | |
(loop with res-values of-type (simple-array double-float) = | |
(make-array n :adjustable nil :initial-element 0d0 | |
:element-type 'double-float) | |
for (val pos newl) = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; fastest solution. based on https://bitbucket.org/vityok/cl-faster-input/src/default/ | |
(defun do-lines-as-buffer (fn fx &key (buffer-width 80)) | |
(declare #.*opt-settings* (function fx) (fixnum buffer-width)) | |
" | |
fx will receive a stream (named in). use it like this: | |
(loop for x = (read in nil nil) | |
while x | |
do something) | |
" | |
(let ((*read-default-float-format* 'double-float) |
OlderNewer