Skip to content

Instantly share code, notes, and snippets.

View michaeldorner's full-sized avatar

Michael Dorner michaeldorner

View GitHub Profile
//Type.java
public enum Type { A, B, C, D, E, F, G, H, I, J };
// Base.java
public abstract class Base {
int i = 1;
final Type type;
public Base(Type type) {
import http.client
import ssl
import socket
import sys
import urllib
class HTTPSConnectionV3(http.client.HTTPSConnection):
def __init__(self, *args, **kwargs):
http.client.HTTPSConnection.__init__(self, *args, **kwargs)
version date
0.2 2008-09-02
0.3 2008-10-29
0.4 2008-11-24
1.0 2008-12-11
2.0 2009-05-24
3.0 2009-09-15
4.0 2010-01-25
4.1 2010-03-17
5.0 2010-05-25
import socket
import sys
import time
import struct
host = 'localhost'
port = 8888
buffersize = 1024
N = 1000000
server_address = (host, port)
import Darwin
public func arc4random <T: IntegerLiteralConvertible> (type: T.Type) -> T {
var r: T = 0
arc4random_buf(&r, UInt(sizeof(T)))
return r
}
public extension UInt {
public static func random(lower: UInt = min, upper: UInt = max) -> UInt {
@michaeldorner
michaeldorner / gist:746c659476429a86a9970faaa6f95ec4
Last active January 4, 2024 10:34 — forked from rgcottrell/gist:5b876d9c5eea4c9e411c
An FM Synthesizer in Swift using AVAudioEngine
import AVFoundation
import Foundation
// The single FM synthesizer instance.
private let gFMSynthesizer: FMSynthesizer = FMSynthesizer()
public class FMSynthesizer {
setup = '''
import pandas as pd
import numpy as np
df_small = pd.DataFrame(np.random.randn(10, 1), columns=[str(1)])
df_medium = pd.DataFrame(np.random.randn(100, 10), columns=[str(i) for i in range(0, 10)])
df_large = pd.DataFrame(np.random.randn(1000, 100), columns=[str(i) for i in range(0, 100)])
'''
if __name__ == '__main__':
import timeit
package main
import (
"encoding/gob"
"fmt"
"os"
)
func writeGob(file_path string, object interface{}) error {
file, err := os.Create(file_path)
@michaeldorner
michaeldorner / toggle_hidden_files
Last active November 2, 2018 16:35
Toggle the visibility of hidden files in macOS using Python
#!/usr/local/bin/python3
import subprocess
if __name__ == '__main__':
get_command = 'defaults read com.apple.finder AppleShowAllFiles'
current_visibility = subprocess.check_output([get_command], shell=True).decode().strip()
update_command = 'defaults write com.apple.finder AppleShowAllFiles ' + {'True': 'False', 'False': 'True'}[current_visibility] + '; killall Finder;'
subprocess.call([update_command], shell=True)

Keybase proof

I hereby claim:

  • I am michaeldorner on github.
  • I am michaeldorner (https://keybase.io/michaeldorner) on keybase.
  • I have a public key whose fingerprint is 25BC ED74 2ACF BB2F CB10 8E78 A1C3 90C0 CFC2 4F1F

To claim this, I am signing this object: