Skip to content

Instantly share code, notes, and snippets.

View lf-'s full-sized avatar
πŸ’­
GitHub πŸ’§πŸ§Š

jade lf-

πŸ’­
GitHub πŸ’§πŸ§Š
View GitHub Profile
@lf-
lf- / fuposix.c
Created April 20, 2017 06:43
Because POSIX behaviour is obnoxious sometimes. A super thin syscall wrapper so posix will never bother us again.
#include <stdio.h>
#include <unistd.h>
#include <string.h>
typedef int (*scfunc)(const char *, const char *);
struct SysCall {
char* name;
scfunc func;
import json
import os
import os.path
import platform
import requests
import shutil
import subprocess
import time
@lf-
lf- / leftpad.py
Last active October 21, 2024 18:48
leftpad.py
class left_pad:
def __init__(this,PadChar=' ',width=4):
this.PadChar=PadChar
this.width = width
def LeftPad(this,stringToPadWithChar):
charsToPad=this.width-len(stringToPadWithChar)
OutStr=''
if(charsToPad>0):
for i in range(0,charsToPad):
OutStr=OutStr+this.PadChar
#include <SoftwareSerial.h>
const int MD49_RX = 8;
const int MD49_TX = 9;
SoftwareSerial md49(MD49_RX, MD49_TX);
void setup() {
// put your setup code here, to run once:
#include <SoftwareSerial.h>
const int MD49_RX = 8;
const int MD49_TX = 9;
const int SABER_TX = 10;
const int SABER_UNUSED = 11;
const int CMD_MD49 = 0x01;
const int CMD_SABER = 0x02;
SoftwareSerial md49(MD49_RX, MD49_TX);
@lf-
lf- / fail.js
Created March 12, 2017 06:54
because js
var a = ''
var b = []
if (a == b && !a && b) {
console.log('win')
}
import json
import os
import os.path
import platform
import requests
import shutil
import subprocess
import time
cat file | python2 -c 'import json,sys;print json.dumps({"files":{"f":{"content":sys.stdin.read()}}})' | curl -d '@-' https://api.github.com/gists | grep -Pom1 '(?<="url": ")(.+)(?=")' | sed 's@api\.@gist.@;s@gists/@@'
#!/usr/bin/env python3
import subprocess
import re
import sys
OUTPUT_RE = r'(.+) = (.+)'
PROP_CURRENT = '_NET_CURRENT_DESKTOP(CARDINAL)'
PROP_DESKTOPS = '_NET_DESKTOP_NAMES(UTF8_STRING)'
#!/bin/ksh
if [ "x$1" == x ]; then
echo "Usage: $0 ifaces dir" >&2
echo "ifaces -- comma-separated network interfaces" >&2
echo "dir -- path to put output files in" >&2
exit 1
fi
IFS=',' set -A ifaces $1