Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# Open Chrome in profile depending on the name it's invoked as.
# Echo URL regardless of profile
echo "${url:=$1}"
# Select profile by binary name.
# If invoked as..... Open in profile...
# wopen work
package main
// #include <linux/reboot.h>
// typedef unsigned int* magic;
// void get_magicks(magic amulet) {
// *amulet++ = LINUX_REBOOT_MAGIC1;
// *amulet++ = LINUX_REBOOT_MAGIC2;
// *amulet++ = LINUX_REBOOT_MAGIC2A;
// *amulet++ = LINUX_REBOOT_MAGIC2B;
// *amulet++ = LINUX_REBOOT_MAGIC2C;
@penryu
penryu / ctrl-no-caps.reg
Last active April 14, 2022 22:55
Windows Registry patch to turn Caps Lock key into Control
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
import java.util.List;
public class Util {
public static void f(List<Double> x) { }
public static void f(List<Long> x) { }
}
#!/usr/bin/env python3
import aiohttp
import asyncio
import statistics
import time
from aiohttp import request
from typing import Dict, List
#!/bin/bash -e
TITLE=`basename $0`
while getopts "hs:t:" opt; do
case "${opt}" in
s) SUBTITLE="${OPTARG}";;
t) TITLE="${OPTARG}";;
*) echo "Usage: $0 [-t TITLE] [-s SUBTITLE] BODY" && exit 1;;
esac
module type CALC = sig
type stack
val display_stack: (stack -> string)
val evaluate: (string -> string)
end
module Calc : CALC = struct
open Core.Std
@penryu
penryu / chutes.scala
Created December 27, 2015 09:27
Estimates the minimum, maximum, and average number of turns in a game of Chutes and Ladders.
object Chutes {
val adjust = Map(
1 -> 38, 4 -> 14, 9 -> 31, 16 -> 6, 21 -> 42, 28 -> 84, 36 -> 44,
48 -> 26, 49 -> 11, 51 -> 67, 56 -> 53, 62 -> 19, 64 -> 60, 71 -> 91,
80 -> 100, 87 -> 24, 93 -> 73, 95 -> 75, 98 -> 78
)
val rand = new util.Random
val runCount = 10000
@annotation.tailrec
object Example {
def main(args: Array[String]): Unit = {
println("Scala!")
// create some values to use
// TERM: assignment
val a = 1
val b = 2
val c = 3
@penryu
penryu / pop_quiz.pl
Last active February 27, 2018 23:58
# Note that the first three lines are just setup so that the last line
# compiles and runs. Have a look and answer the two questions below:
package Father;
$hacked += 'Perl is awesome!';
$i = {have => ($me = sub {[{Perl => "@{[print qq{Success!\n}]}"}]})};
bless $me, Father for $i->{have}()[$hacked]{Perl};
# 1) Without running it, what does the code display?
# 2) Would you ever want me to write Perl for you? ... for anyone?