Skip to content

Instantly share code, notes, and snippets.

View lulu-berlin's full-sized avatar
🏠

Lulu lulu-berlin

🏠
  • Berlin
View GitHub Profile
@lulu-berlin
lulu-berlin / unfoldf.fsx
Last active October 13, 2015 20:40
F# unfold without tuples
// Seq.unfold (https://msdn.microsoft.com/en-us/library/ee340363.aspx)
// works with a generator function that gets a state and returns
// Some (element, state) to generate another iterator, or
// None to stop the iteration.
// The problem is that tuples are allocated every single iteration.
//
// The solution below uses instead a generator function that gets
// a state and an iterator function. The iterator function can be called
// to yield a new element and set a new state for the next iterator. If the
// generator function returns a unit, i.e. (), the iteration stops.
@lulu-berlin
lulu-berlin / timer.fs
Created August 6, 2015 17:28
An accurate timer for F# without using System.Diagnostics
//
// This is in fact a thin wrapper around QueryPerformanceCounter() and QueryPerformanceFrequency().
// When those are not available it falls back to System.DateTime.UtcNow.Ticks.
// This module is based on the C# code of StopWatch.
// See: http://referencesource.microsoft.com/#System/services/monitoring/system/diagnosticts/Stopwatch.cs
//
open System.Runtime.InteropServices
open System.Runtime.Versioning
@lulu-berlin
lulu-berlin / yiddish.vim
Created August 16, 2015 22:17
A Yiddish keyboard layout for VIM
" VIM keyboard layout for Yiddish and Hebrew
" based on the Mac keyboard layout by Jack (Yosl) and Shoshke-Reyzl Juni
" (url: http://www.shoshke.net/)
" Adapted to VIM by Ya'ar Hever
" Last Updated: Sun Aug 16 22:22:22 CEST 2015
" Use this short name in the status line.
let b:keymap_name = "UYIP"
loadkeymap
a <char-0x5e9> " ש - shin
@lulu-berlin
lulu-berlin / multiwordthesaurus.vim
Last active September 16, 2015 22:15
A script to handle multi-word thesaurus files with underscores instead of spaces
function! MultiWordThesaurus()
" if a thesaurus is already open, abort.
if pumvisible() || &thesaurus == ""
return 0
endif
" mark the cursor position
silent exec "normal! mt"
" take a window of 6 words
@lulu-berlin
lulu-berlin / FSharpCompilerService-error.fsx
Last active December 19, 2016 19:58
An FSI script to reproduce an error in FSharp.Compiler.Service: doesn't find identifiers beginning with an underscore (with double backticks)
#r "FSharp.Compiler.Service.dll"
open System.IO
open Microsoft.FSharp.Compiler.SourceCodeServices
let checker = FSharpChecker.Create ()
let filesource1 = """
module Abc
let x = 1
let y = x + 1
@lulu-berlin
lulu-berlin / cygwin-setup.sh
Created October 4, 2015 19:58
A shell script for Cygwin to download and run the install program
#!/bin/bash
if [[ $(getconf LONG_BIT) == "64" ]]; then
setup_file="setup-x86_64.exe"
else
setup_file="setup-x86.exe"
fi
wget -N "https://cygwin.com/$setup_file" -P /usr/local/bin
" Alternative Vim Keymap file for hebrew
" Created by: Ya'ar Hever
" Last Updated: 09/08/2015 23:13:10
" Use this short name in the status line.
let b:keymap_name = "heb-lyx"
loadkeymap
a <char-0x5e9> " ש - shin
b <char-0x5e0> " נ - nun
c <char-0x5d1> " ב - bet
@lulu-berlin
lulu-berlin / .block
Last active May 4, 2016 19:05
cat-and-paste
license: cc-by-4.0
border: no
height: 800
@lulu-berlin
lulu-berlin / fix-numeric-keypad
Last active July 1, 2017 11:39
How to fix numeric keypad on Linux not working with java applications
# credit to Peter L on StackOverflow:
# https://stackoverflow.com/questions/32753190/how-to-get-numeric-keypad-arrows-working-with-java-applications-on-linux/32753332#32753332
#!/bin/bash
SYMBOLS="/usr/share/X11/xkb/symbols"
KEYPAD="$SYMBOLS/keypad"
# create a backup in a temporary directory
TMP=$(mktemp -d)
@lulu-berlin
lulu-berlin / fix-screensaver-kblayout.sh
Created March 27, 2017 03:53
fix for gnome-screensaver lock not allowing to change keyboard layout
#!/usr/bin/env bash
# This bug is well documented and still not fixed for a long time:
# https://bugs.launchpad.net/gnome-screensaver/+bug/872701
# This script is inspired by two scripts that were submitted on askubuntu.com
# to fix this issue in Gnome and in Unity:
# http://askubuntu.com/a/803418/472924
# http://askubuntu.com/a/857652/472924