Skip to content

Instantly share code, notes, and snippets.

@4e6
4e6 / DuplicatesFinder.scala
Created August 8, 2011 23:45
Scala script to find duplicate resources in android projects
/*
* to run from console:
* $scala DuplicatesFinder.scala /path/to/android/project
*/
import java.io.File
import scala.xml._
val folder = args(0)
val project = new File(folder)
@4e6
4e6 / default.nix
Last active December 16, 2018 16:50
The result of running stackage2nix on stack git repo
# Generated by stackage2nix 0.7.0 from "./stack.yaml"
{ _nixpkgs ? import <nixpkgs> {} }:
let
stackageOverlay = builtins.fetchGit {
url = "https://github.com/typeable/nixpkgs-stackage.git";
rev = "0852a4b5097c576a4d42a6cd1fdb9e1746a85e3e";
};
nixpkgs = import <nixpkgs> {
overlays = [ (import stackageOverlay) ];
@4e6
4e6 / Main.hs
Created October 17, 2018 09:40
parallel map with timeout
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE PartialTypeSignatures #-}
module Main where
Dec 29 18:12:07 localhost systemd[1]: Starting Fetch host keys and authorized_keys for root user...
Dec 29 18:12:07 localhost fetch-ssh-keys-start[891]: obtaining SSH key...
Dec 29 18:12:07 localhost fetch-ssh-keys-start[891]: --2017-12-29 18:12:07-- http://metadata.google.internal/0.1/meta-data/authorized-keys
Dec 29 18:12:07 localhost fetch-ssh-keys-start[891]: Resolving metadata.google.internal (metadata.google.internal)... 169.254.169.254
Dec 29 18:12:07 localhost fetch-ssh-keys-start[891]: Connecting to metadata.google.internal (metadata.google.internal)|169.254.169.254|:80... connected.
Dec 29 18:12:07 localhost fetch-ssh-keys-start[891]: HTTP request sent, awaiting response... 200 OK
Dec 29 18:12:07 localhost fetch-ssh-keys-start[891]: Length: 113 [application/text]
Dec 29 18:12:07 localhost fetch-ssh-keys-start[891]: Saving to: ‘/run/tmp.OQwfTw2zGL’
Dec 29 18:12:07 localhost fetch-ssh-keys-start[891]: 0K 100% 53.0M=0s
Dec 29 18:12:07 localhos
@4e6
4e6 / ghc-7.10.3 Runner.dump-simpl-stats
Last active October 15, 2017 07:47
ddump-simpl-stats for ghc issue #14338
==================== FloatOut stats: ====================
2017-10-14 20:45:26.943053 UTC
4 Lets floated to top level; 0 Lets floated elsewhere; from 68 Lambda groups
==================== FloatOut stats: ====================
2017-10-14 20:45:27.479678 UTC
@4e6
4e6 / Main.hs
Last active July 11, 2017 16:38 — forked from snoyberg/Main.hs
Comparing iterators, streams, and loops in Haskell, Rust, and C
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE TypeFamilies #-}
module Main (main) where
import Foreign
import Foreign.C.Types
@4e6
4e6 / tests.rs
Last active September 12, 2016 14:31
Rust benchmark ASM
test tests::xor_black_box ... bench: 69 ns/iter (+/- 1)
test tests::xor_closure_a ... bench: 70 ns/iter (+/- 1)
test tests::xor_closure_b ... bench: 921 ns/iter (+/- 5)
test tests::xor_pointer_a ... bench: 60 ns/iter (+/- 1)
test tests::xor_pointer_b ... bench: 0 ns/iter (+/- 0)
@4e6
4e6 / example.out
Created February 4, 2016 19:54
Variable `counter` passed to a macros behaves as if it was passed by-reference.
scala> var c = 0
c: Int = 0
scala> inc(c)
scala> c
res1: Int = 1
@4e6
4e6 / gist:5488205
Created April 30, 2013 11:46
Check if type is concrete
def f[T]: Unit = macro f_impl[T]
def f_impl[T: c.WeakTypeTag](c: Context): c.Expr[Unit] = {
import c.universe._
def isConcreteTypeSymbol(sym: Symbol) =
sym.isType && !sym.asType.isAbstractType
def isConcreteType(tpe: Type): Boolean = tpe match {
case NoPrefix =>
@4e6
4e6 / jsglr-layout
Created March 22, 2013 18:13
jsglr_layout ParseTableManager
jsglr-layout [scala-ast]± scala -cp org.spoofax.terms_1.0.0.201105211714.jar:bin/
Welcome to Scala version 2.10.0-20121205-235900-18481cef9b (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_17).
Type in expressions to have them evaluated.
Type :help for more information.
scala> val tableMgr = new org.spoofax.jsglr_layout.io.ParseTableManager()
tableMgr: org.spoofax.jsglr_layout.io.ParseTableManager = org.spoofax.jsglr_layout.io.ParseTableManager@1b3821a6
scala> import java.io.File
import java.io.File