Skip to content

Instantly share code, notes, and snippets.

View ExpHP's full-sized avatar

Michael Lamparski ExpHP

View GitHub Profile
@ExpHP
ExpHP / bench-imperative-iterator.rs
Last active November 8, 2016 02:23
benching inside-out iterators
#![feature(test)]
#[derive(Clone)]
struct Iterate<T, F> {
cur: T,
func: F,
}
impl<T, F> Iterator for Iterate<T, F>
// Goal: make mistakes like the first function fail to compile.
import * as $ from 'jquery';
function makeThisNotCompile(): number {
// NOTE: With @types/jquery,
// this is defined to return 'any' (and very likely, NOT a number).
// The typechecker has been rendered useless, yet this looks no different
// at all from any piece of code where the type checker CAN be trusted.
//
"*":
"atom-reason-loader": {}
"autocomplete-plus":
confirmCompletion: "tab always, enter when suggestion explicitly selected"
"bracket-matcher":
autocompleteBrackets: false
core:
customFileTypes:
"source.ini": [
".buckconfig"
push %rbp
push %r15
push %r14
push %r13
push %r12
push %rbx
sub $0x78,%rsp
mov %rsi,%rbx
mov %rdi,0x30(%rsp)

In virtually all circumstances, the symmetry of some structural property of a structure at a given k point is defined through the same general means:


"Symmetry of some property..."

The structural property we want to analyze is first described as a complex vector field which has periodicity exactly equal to the Bravais lattice, and which is nonzero only at the discrete set of sites in the lattice.

@ExpHP
ExpHP / partitions.rs
Last active March 22, 2017 00:07
rust-partitions
//-----------------------------------------
//-----------------------------------------
//-----------------------------------------
// These functions are for unordered sequences (meaning that
// e.g. 2 + 3 and 3 + 2 are considered to be the same solution,
// and thus only one is returned)
//-----------------------------------------
// Unique ways (up to order) to add any amount of numbers x (min <= x <= max)
// to produce a specific sum.
type Item u e a = Either (Either u e) a
-- | 'Eggshell' is an eggshell-thin wrapper around 'Turtle.Shell' which makes it
-- easier to redirect @stdout@ and @stderr@. 'Eggshell' carries lines of
-- @stdout@ and @stderr@ (the white stuff) /implicitly/ alongside the
-- values we actually care about (the yolk), so that we can capture stdout
-- and stderr without them interfering with the comprehensions we actually
-- want to write. It contains a @Shell (Either (Either Line Line) a)@.
data Eggshell a = Eggshell
[ lampam@arch-t430s ] (!!!) ~/asd/haskell/terrible-filepath-subst
$ stack test
Warning: File listed in terrible-filepath-subst.cabal file does not exist: README.md
terrible-filepath-subst-0.1.0.0: test (suite: subst-test)
Subst
Source parsing
single elements
literal: OK
named: OK
@ExpHP
ExpHP / Please.hs
Created March 28, 2017 23:57
turtle please
{-# LANGUAGE PackageImports #-}
module Turtle.Please
( module Turtle
, fold, foldIO
) where
import qualified "turtle" Turtle as Turtle.Naughty
import "turtle" Turtle hiding (fold, foldIO)
main = shakeArgs opts $ do
-- ...
"[p]/[v]/freqs/[k]" !> \out fmt -> do
let i = List.elemIndex (fmt "[k]") kpointShorts -- HACK should use order in data
liftIO $ input (fmt "[p]/[v]/data.dat") & script "degnuplot"
& procs "jq" [idgaf $ "[.[]["++show i++"][0][1]]"] -- FIXME shelling out to jq!?
& toOut & output (idgaf out)