Skip to content

Instantly share code, notes, and snippets.

View adimit's full-sized avatar
🚆
Trains!

Aleksandar Dimitrov adimit

🚆
Trains!
View GitHub Profile
@adimit
adimit / strace-yarn-install.txt
Created August 8, 2018 08:49
Strace Yarn Install
write(11, "[###############################"..., 94[##################################################################################] 1520/1521) = 94
epoll_wait(3, [], 1024, 0) = 0
epoll_wait(3, [], 1024, 203) = 0
openat(AT_FDCWD, "/proc/self/stat", O_RDONLY) = 15
read(15, "19647 (node) R 19645 19645 18426"..., 1023) = 339
close(15) = 0
epoll_wait(3, [], 1024, 1000) = 0
openat(AT_FDCWD, "/proc/self/stat", O_RDONLY) = 15
read(15, "19647 (node) R 19645 19645 18426"..., 1023) = 339
close(15) = 0
@adimit
adimit / test.js
Created December 1, 2017 21:32
Testing with marbles and promises
import { describe, it } from 'mocha';
import { TestScheduler } from 'rxjs/testing/TestScheduler';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/concatMap';
import 'rxjs/add/operator/concatAll';
import 'rxjs/add/operator/mergeAll';
import 'rxjs/add/operator/switchMap';
describe('Test', function () {
const marbles = new TestScheduler((a, b) => expect(a).to.deep.equal(b));
@adimit
adimit / Intersections.java
Last active October 28, 2016 20:03
An intersection of arbitrarily many collections.
/**
* Given a stream of collections, intersect it.
*
* @param stream A stream of collections you want to intersect
* @param <T> Any item that has a decent .equals(). Seriously, don't attempt this without a working .equals().
* @return The unique(!) elements present in *all* collections in the stream
*/
public static <T> Collection<T> intersect(Stream<Collection<T>> stream) {
// Optimization: sorting by size so that the biggest constrainer
// (smallest collection) comes first

Keybase proof

I hereby claim:

  • I am adimit on github.
  • I am adimit (https://keybase.io/adimit) on keybase.
  • I have a public key whose fingerprint is F3A8 8679 4256 CA5D C80B A9C9 0E1F 0EE4 290B BA85

To claim this, I am signing this object:

packages:
- '.'
- location:
git: https://github.com/haskell-servant/servant
commit: d46cde913c8bcd993c3341b252d2f1f2498211ca
extra-dep: true
subdirs:
- servant-server
- servant
@adimit
adimit / hlist-sequence.hs
Created July 2, 2014 09:45
HList sequence
data NodeList (l ∷ [*]) where
NNil ∷ NodeList '[]
(:-) ∷ e → NodeList l → NodeList (e ': l)
nodeSequence ∷ ∀ m e l. NodeList (m e ': l) → m (NodeList e ': l)
nodeSequence (m :- l) = (m ∷ m e) >>= \(e ∷ e) → return (e :- l)
@adimit
adimit / benchmark.hs
Created August 28, 2012 10:16
Test Text string escaping.
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Text as X
import Data.Text (Text)
import Criterion
import Criterion.Main
escapedChars :: String
escapedChars = '"':'\\':"-!@~/()*[]="
@adimit
adimit / WEIRD.R
Created July 9, 2012 23:18
R is weird.
s <- 1
png(paste("graphs/subjects/s",s,"qresp.png",sep=""),width=1000,height=1000)
ggplot(items[items$Subject == s,],aes(Condition,ScaledQRESP)) + geom_boxplot()
dev.off()
for (s in 1:31) {
print(paste("Plotting data for subject",s))
png(paste("graphs/subjects/s",s,"qresp.png",sep="-"),width=1000,height=1000)
print(ggplot(items[items$Subject == s,],aes(Condition,ScaledQRESP)) + geom_boxplot())
import Data.STRef
import Control.Monad (when,forM_)
import Control.Monad.ST
import Data.Array.ST
import Data.List (minimumBy)
import Data.Array
findShortestSublist0 :: (Eq a) => [a] -> [a] -> Maybe (Int,Int)
findShortestSublist0 n h = findShortestSublist (map (==) n) h
@adimit
adimit / hebrew.tex
Created June 11, 2012 10:03
Hebrew in XeLaTeX
\documentclass{article}
\usepackage[round]{natbib}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{bidi}
\newfontfamily{\hebrf}[Script=Hebrew]{SBLHebrew}
\newcommand{\hebr}[1]{\RL\hebrf #1}