Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
USERNAME=""
IDENTITY=""
IP=""
STATE=""
usage() { echo "Usage: $0 [-u <ssh username> ] [-k <ssh identity file>] [-i <ip address>] [-s <on|off>]" 1>&2; exit 1; }
while getopts "u:k:i:s:" o; do
@bradley219
bradley219 / video_to_gif.sh
Created December 13, 2018 07:17
Convert a video file to high quality gif
#!/bin/bash
FPS=14
WIDTH=640
PALETTE=/tmp/palette.png
INPUT="$1"
OUTPUT="$2"
KEEP_PALETTE="$3"
# Usage:
# osascript sendimessage.applescript <recipient> <message>
on run {targetBuddyPhone, targetMessage}
tell application "Messages"
set targetService to 1st service whose service type = iMessage
set targetBuddy to buddy targetBuddyPhone of targetService
send targetMessage to targetBuddy
end tell
end run
@bradley219
bradley219 / num.c
Last active February 14, 2020 00:35
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
#include <getopt.h>
#define VERSION "1.1"
typedef enum {
@bradley219
bradley219 / readserial.c
Last active May 24, 2018 08:33
Simple utility for logging from serial port
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
#include <sys/select.h>
#include <signal.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <stdlib.h>
@bradley219
bradley219 / focus.py
Created November 27, 2017 04:55
Python script for generating a focus routine gcode file. To use, set parameters in the script and execute on the command line. Pipe the output into a gcode file. Example: `./focus.py > focus.gcode`.
#!/usr/bin/env python
def g1_from_point(point):
return "G1 X{} Y{} Z{}\n".format(round(point[0], 5), round(point[1], 5), round(point[2], 5))
def g1_from_speed(speed):
return "G1 F{}\n".format(speed)
if __name__ == '__main__':
#!/usr/bin/env python
import sys
c = sys.stdin.read(1)
while len(c) > 0:
sys.stdout.write("{0:02x}".format(ord(c)))
c = sys.stdin.read(1)
#include <stdint.h>
#include <stdio.h>
int ones_count(uint32_t i) {
    i = i - ((i >> 1) & 0x55555555);
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
    return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
}
int main (int argc, char *argv[]) {
@bradley219
bradley219 / fix_xcode_plugins
Last active December 11, 2019 06:08
Fix Xcode Plugin UUIDs
#!/bin/bash
UUID=`defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID`
echo "UUID=$UUID"
find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add "$UUID"
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.