Code moved to https://github.com/HalCanary/mastodoner
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
#include <CoreFoundation/CoreFoundation.h> | |
#include <Foundation/NSObjCRuntime.h> | |
#include <IOKit/ps/IOPSKeys.h> | |
#include <IOKit/ps/IOPowerSources.h> | |
#include <assert.h> | |
int main() { | |
CFTypeRef psInfo = IOPSCopyPowerSourcesInfo(); | |
assert(psInfo != NULL); | |
CFArrayRef list = IOPSCopyPowerSourcesList(psInfo); | |
assert(list != NULL); |
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
#! /usr/bin/env python3 | |
import matplotlib.pyplot as plt | |
import matplotlib.animation as anim | |
import numpy as np | |
x = np.arange(0,2*(np.pi),.01) | |
y, z = 0 * x, 0 * x | |
fig = plt.figure() | |
ax = plt.axes(xlim=(0, 2*np.pi), ylim=(-2, 2)) | |
yline, = ax.plot([], []) | |
zline, = ax.plot([], []) |
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 urllib.request | |
import urllib.parse | |
import json | |
################################################################################ | |
def Get(auth, host, path, query={}): | |
q = urllib.parse.urlencode(query) | |
req = urllib.request.Request( | |
f"https://{host}{path}?{q}", |
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
/////////////////////////////////////////////// | |
// header | |
#include <string_view> | |
#define RAINBOW(X) \ | |
X(Red) \ | |
X(Orange) \ | |
X(Yellow) \ | |
X(Green) \ |
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
// Go Playground: https://go.dev/play/p/ao7M54vTDRQ | |
package main | |
import ( | |
"os" | |
"strings" | |
"golang.org/x/net/html" | |
) |
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/sh | |
if command -v gofmt > /dev/null 2>&1; then | |
BAD='' | |
while IFS= read -r f; do | |
if echo "$f" | grep -q '\.go$'; then | |
HASH="$(git ls-files --stage -- "$f" | awk '{print $2}')" | |
if [ "$(git show "$HASH" | gofmt -l 2>&1)" ]; then | |
if [ -z "$BAD" ]; then | |
BAD='Y' |
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/zsh | |
if command -v gofmt > /dev/null 2>&1; then | |
BAD=() | |
git diff --cached --name-only --diff-filter=AM | while IFS= read -r f; do | |
if echo "$f" | grep -q '\.go$'; then | |
HASH="$(git ls-files --stage -- "$f" | awk '{print $2}')" | |
if [ "$(git show "$HASH" | gofmt -l 2>&1)" ]; then | |
BAD+=(${f}) | |
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
#import <Foundation/Foundation.h> | |
#include <stdlib.h> | |
static inline char* strdupNS(NSString* nss) { | |
static const NSStringEncoding enc = NSUTF8StringEncoding; | |
NSUInteger len = [nss lengthOfBytesUsingEncoding:enc]; | |
if (len <= 0) { | |
return NULL; | |
} | |
char* cstr = malloc((size_t)(1 + len)); | |
if (![nss getCString:cstr maxLength:(1 + len) encoding:enc]) { |
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
#!/usr/bin/env python3 | |
'''Usage: | |
{} TO_ADDR SUBJECT CONTENT_TEXT_FILE_PATH [ATTACHMENTS] | |
''' | |
import email.message | |
import email.utils | |
import os | |
import smtplib |