Skip to content

Instantly share code, notes, and snippets.

View Wevah's full-sized avatar
💻
Computerin‘

Nate Weaver Wevah

💻
Computerin‘
View GitHub Profile
@Wevah
Wevah / pzmakedownloadblock
Created May 10, 2021 18:51
Paparazzi! download block generator
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "I need a file!"
exit 1
fi
baseName=$(basename "$1")
downloadName="${baseName%.*}"
@Wevah
Wevah / buildsqlite
Last active April 20, 2021 23:55
Build an SQLite dylib from an amalgamation directory, automatically parsing out the version
#!/usr/bin/env perl
# Run from inside an SQLite amalgamation directory
# (i.e., extracted from an amalgamation archive).
use warnings;
use strict;
use Cwd;
my $macosxminversion = "10.12";
### Keybase proof
I hereby claim:
* I am wevah on github.
* I am wevah (https://keybase.io/wevah) on keybase.
* I have a public key ASCYaKnIPRFxUJL1JIIKe6wpEkNz4ROhhNzarALeMBOsvQo
To claim this, I am signing this object:
@Wevah
Wevah / dl-alias.bash
Last active December 23, 2016 02:24
Simple`dl` command for downloading a file to the current directory
# simple 'dl' command for downloading a file to the current directory
dl () {
if [ $# -eq 0 ]; then
echo -e 'usage: dl \033[4murl\033[0m [\033[4mfile\033[0m]';
elif [ $# -eq 1 ]; then
parsed="$(basename $(echo -n "$1" | sed 's/\?.*$//'))"; #strip query string and fragment
curl -C - "$1" -o "$parsed";
else
curl -C - "$1" -o "$2";
@Wevah
Wevah / buildsqlite.txt
Last active January 27, 2021 20:46
Build SQLite dylib
clang -dynamiclib -Os -Wl,-install_name,@rpath/libsqlite3.dylib -mmacosx-version-min=10.9 -o libsqlite3.dylib sqlite3.c
@Wevah
Wevah / Makefile
Created March 14, 2016 00:50
Simple makefile for compiling single-file Cocoa test binaries.
# Toss in a directory
# Usage: make <binname>
# Compiles <binname>.m to <binname>
%: %.m
rm -f $@
$(CC) $(CPPFLAGS) $(CFLAGS) -Wall -fobjc-arc -fmodules $^ -o $@
@Wevah
Wevah / gist:10145527
Created April 8, 2014 15:44
Using kPasteboardTypeFileURLPromise/kPasteboardTypeFilePromiseContent
- (NSArray *)writableTypesForPasteboard:(NSPasteboard *)pasteboard {
// pasteboard must be stored away because there's no way to get it in -pasteboardPropertyListForType: :(
_currentPasteboard = pasteboard;
NSArray *types = @[(id)kPasteboardTypeFileURLPromise, (id)kPasteboardTypeFilePromiseContent];
return types;
}
// ...
@Wevah
Wevah / NSString+MaxWidth.m
Last active December 29, 2015 14:29
Truncate a string, with an ellipsis in the center, to a max point width, without splitting composed character sequences (grapheme clusters).
- (NSString *)stringByInsertingCenterEllipsisWithMaxWidth:(CGFloat)maxWidth font:(NSFont *)font {
NSDictionary *attrs = @{ NSFontAttributeName: font };
NSSize size = [self sizeWithAttributes:attrs];
if (size.width <= maxWidth)
return self;
NSMutableString *mutable = [self mutableCopy];
NSMutableString *mutableWithEllipsis = nil;
@Wevah
Wevah / gist:3483048
Created August 26, 2012 19:47
Adium 1.5.4b1 + Growl 2.0b6 crash
Process: Adium [12517]
Path: /Applications/Internet/Adium.app/Contents/MacOS/Adium
Identifier: com.adiumX.adiumX
Version: 1.5.4b1 (1.5.4b1)
Code Type: X86-64 (Native)
Parent Process: launchd [256]
User ID: 501
Date/Time: 2012-08-26 14:45:17.761 -0500
OS Version: Mac OS X 10.8.1 (12B19)
@Wevah
Wevah / gist:3365918
Last active October 8, 2015 17:38
Pipe Parse
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
NSString *str = @"foo|bar|baz\\|quux";
BOOL lastWasBackslash = NO;
NSMutableString *sub = [NSMutableString string];
NSMutableArray *matches = [NSMutableArray array];
for (NSUInteger idx; idx < [str length]; ++idx) {