Skip to content

Instantly share code, notes, and snippets.

View atroche's full-sized avatar

Alistair Roche atroche

View GitHub Profile
import csv
from PIL import Image
rows = csv.reader(open("scores_for_bloom.csv", "r"))
rows = sorted(rows, key=lambda x:x[2], reverse=True)[1:]
for index, row in enumerate(rows):
image = Image.open(open(row[-1], "rb"))
image.save("datasets/videos/faces/sorted/bloom/%s.jpg" % index)
# see https://imgur.com/a/GS9n20F
import os
import pickle
import numpy as np
import scipy.spatial.distance
from PIL import Image
eu = scipy.spatial.distance.euclidean
ze = np.load("facenet/src/zuck_embeddings.npy")
@atroche
atroche / calculate_embeddings.py
Created May 7, 2018 04:05
Using FaceNet to sort Zuck faces by weirdness
import time
import os
import numpy as np
import scipy.misc
import tensorflow as tf
import facenet
image_size = (160, 160)
@atroche
atroche / reagent_strict_mode.cljs
Created April 28, 2018 06:47
An example of enabling React's new "Strict Mode" in reagent
;; use [reagent "0.8.0"]
(let [unsafe-component (r/create-class
{:reagent-render (fn [& args]
(js/console.log "this should be printed twice, because strict mode 'double invokes' render methods in dev mode, to bring side effectful code to the fore")
[:div
"rendering this should produce a warning in the console about lifecycle methods in "
[:a {:href "https://reactjs.org/docs/strict-mode.html"}
"strict mode"]])
:component-will-mount (fn [this]
(ns scratch.core
(:require
[reagent.core :as r]
[taoensso.tufte :as tufte :refer (defnp p profiled profile)]))
(enable-console-print!)
(tufte/add-basic-println-handler! {})
(defonce props (r/atom {:todos 1}))
I walked by the sea, and there came to me,
as a star-beam on the wet sand,
a white shell like a sea-bell;
trembling it lay in my wet hand.
In my fingers shaken I heard waken
(defn fake-poll-fn []
(range 10))
(defn possible-not-claimed?
[work-item]
(pos-int? work-item))
(defn claim-log-process-transact
[work-item]
(require '[think.parallel.core :as par])
(let [new-val (inc counter)]
(alter-var-root #'counter (constantly 100))
(let [vals (binding [counter 50]
(par/queued-pmap 50 (fn [_] counter) (range 200)))]
(alter-var-root #'counter (constantly 400))
(println vals)))
(println counter)
IMG="fsof-lein-test"
REPL_PORT=6666
docker build \
-t $IMG \
-f Dockerfile.dev \
--build-arg USERID=$(id -u) \
--build-arg GROUPID=$(id -u) \
--build-arg USERNAME=$USER \
.
~/t/fsof   circleci $…  circleci build 2267ms  Wed 01 Nov 2017 12:10:39 PM MDT
====>> Spin up Environment
Build-agent version 0.0.4499-d8fe89b (2017-10-31T13:39:51+0000)
Starting container circleci/clojure:lein-2.7.1
using image circleci/clojure@sha256:7f4647ec1f1dc1078fa5904c48d3c37106ba4b266b7f386da38c477a4bae6213
Using build environment variables:
BASH_ENV=/tmp/.bash_env-localbuild-1509559843