This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
get_power_source() { | |
if [ -f /sys/class/power_supply/ACAD/online ]; then | |
cat /sys/class/power_supply/ACAD/online | |
else | |
echo "Unable to determine power source" | |
exit 1 | |
fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!D::HideShowTaskbar() | |
HideShowTaskbar() { | |
static ABM_SETSTATE := 0xA, ABS_AUTOHIDE := 0x1, ABS_ALWAYSONTOP := 0x2 | |
static hide := 0 | |
hide := !hide | |
APPBARDATA := Buffer(size := 2*A_PtrSize + 2*4 + 16 + A_PtrSize, 0) | |
NumPut("UInt", size, APPBARDATA), NumPut("Ptr", WinExist("ahk_class Shell_TrayWnd"), APPBARDATA, A_PtrSize) | |
NumPut("UInt", hide ? ABS_AUTOHIDE : ABS_ALWAYSONTOP, APPBARDATA, size - A_PtrSize) | |
DllCall("Shell32\SHAppBarMessage", "UInt", ABM_SETSTATE, "Ptr", APPBARDATA) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Use AHK v2.0. In Windows set Touchpad settings > Advanced Gestures > Configure three-finger gestures > Tap: Middle mouse button | |
; Then use this AHK script: | |
toggle := false | |
#HotIf toggle | |
LButton:: | |
{ | |
Click "Up" | |
global toggle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std/httpclient | |
import std/strutils | |
import std/json | |
import std/random | |
proc toJson(o: auto): string = | |
result = $(%*o) | |
type | |
MyBody = object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.Threading | |
type WorkerGroup = | |
{ wait: unit -> unit | |
release: unit -> unit | |
waitGroup: unit -> unit } | |
let initWorkerGroup count = | |
let semaphore = new SemaphoreSlim(count) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function AccurateInterval(intervalMs, callback) { | |
var repeat; | |
var expected; | |
var timer; | |
function step() { | |
var err = Date.now() - expected; | |
callback(); | |
console.log("error was", err, "ms"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let pi = System.Math.PI | |
let sqrt x = System.Math.Sqrt x | |
let inline squared x = x * x | |
let radiusA = 1.0 | |
let radiusB = 1.158728 //should be "1.158728" | |
let area = pi*(radiusA**2.0) | |
let randr min max = System.Random.Shared.NextDouble() * (max - min) + min | |
let rand () = randr -1.0 1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Keep updated here https://gist.github.com/peheje/ea1d067803c8bb2a9fdbbc17b763174a | |
package main | |
import ( | |
"fmt" | |
"math" | |
"math/rand" | |
"time" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Microsoft.VisualBasic.FileIO | |
let read (path: string) = | |
let rec loop (parser: TextFieldParser) output = | |
if parser.EndOfData then output |> List.rev | |
else loop parser ((parser.ReadFields()) :: output) | |
let parser = new TextFieldParser(path, Delimiters = [|","|], HasFieldsEnclosedInQuotes = true) | |
loop parser [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
} | |
typealias Function = (x: Double) -> Double | |
typealias Rule = (f: Function, x: Double, h: Double) -> Double | |
fun leftRectangle(f: Function, x: Double, h: Double) = f(x) | |
fun midRectangle(f: Function, x: Double, h: Double) = f(x + h / 2.0) | |
fun rightRectangle(f: Function, x: Double, h: Double) = f(x + h) |
NewerOlder