Skip to content

Instantly share code, notes, and snippets.

@aboisvert
aboisvert / fish-heredoc-example.fish
Last active January 18, 2021 18:51
Example workaround for the lack of native "heredoc" support in fish shell
#!/usr/bin/env fish
#
# Example working with 'heredoc' documents
#
# Recommended: Define the heredoc using single quotes
#
# Use the `fish-heredoc-quote` script to generate quoted document
#
import zip/zlib
import streams
const BufferSize = 16384*2
type
GZipInputStream* = ref GZipInputStreamObj
GZipInputStreamObj* = object of Stream
source: Stream
zstream: ZStream
type
SharedString* = object
str: cstring
proc newSharedString*(s: string): SharedString =
result = SharedString(str: cast[cstring](allocShared(s.len + 1)))
copyMem(result.str, s.cstring, s.len)
proc deallocSharedString*(s: SharedString) =
deallocShared(s.str)
@aboisvert
aboisvert / avxcount.nim
Last active August 21, 2023 10:59
Nim port of Daniel Lemire's fast newline count `avxcount` .
# Nim port of Daniel Lemire's fast newline count `avxcount`
#
# See https://lemire.me/blog/2017/02/14/how-fast-can-you-count-lines/
# https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/blob/master/2017/02/14/newlines.c
import os, memfiles, times, strutils
{.passc: "-march=native".}
{.pragma: imm, header:"immintrin.h".}
import os, sets, hashes, strutils, sequtils
type
HString = object
str: string
hash: Hash
proc hash*(str: HString): Hash =
str.hash
import strutils
const SHA512Len = 64
proc SHA512(d: cstring, n: culong, md: cstring = nil): cstring {.cdecl, dynlib: "libssl.dylib", importc.}
proc SHA512(s: string): string =
result = ""
let s = SHA512(s.cstring, s.len.culong)
for i in 0 .. < SHA512Len:

sudo apt-get install compiz-plugins # needed for ring switcher and such.

@aboisvert
aboisvert / intel_7260_wifi.md
Last active August 29, 2015 13:57
Using Intel's 7260 Wifi on Ubuntu 13.10 - March 4th, 2014
@aboisvert
aboisvert / Blog Index.markdown
Last active August 29, 2015 13:57
Alex Boisvert's Blog
@aboisvert
aboisvert / proguard.rb
Created April 5, 2013 22:25
Proguard plugin for Apache Buildr
#
# Usage:
#
# Add the following at the top of your buildfile,
#
# require 'proguard.rb'
#
# And specify your proguard jar in your project,
#
# package(:proguard).tap do |proguard|