Skip to content

Instantly share code, notes, and snippets.

View leptos-null's full-sized avatar
🏔️
Darwin tooling

Leptos leptos-null

🏔️
Darwin tooling
View GitHub Profile
@leptos-null
leptos-null / pathdiff.m
Last active August 29, 2019 23:28
Find tools with the with the same name in a PATH
@import Foundation;
int main(int argc, const char *argv[]) {
const char *const arg = argv[1];
if (arg) {
if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0 || argc > 2) {
printf("Usage: %s [PATH]\n"
"Walk through PATH and find any repeated file names. "
"A different PATH can be provided by passing it in as the first argument.\n", argv[0]);
return 1;
@leptos-null
leptos-null / GenericError.swift
Created June 8, 2019 17:13
A generic error I use in Swift, typically for cases that are not intended to be dealt with in a manner other than being logged
struct GenericError: Error, CustomStringConvertible, CustomDebugStringConvertible, Equatable, Codable {
let description: String
let file: String
let function: String
let line: Int
init(message m: String, file f: String = #file, function n: String = #function, line l: Int = #line) {
description = m; file = f; function = n; line = l
}
@leptos-null
leptos-null / progress_bar.c
Last active April 28, 2019 19:37
Example of a VT100 progress bar in C
//
// progress_bar.c
//
// Created by Leptos on 2/17/19.
// Copyright © 2018 Leptos. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
@leptos-null
leptos-null / taylor_sin.c
Last active April 28, 2019 19:16
A C sine routine implemented using a Taylor series
//
// taylor_sin.c
//
// Created by Leptos on 4/25/19.
// Copyright © 2019 Leptos. All rights reserved.
//
#include <math.h> // not required- included only for the M_PI macros which are also included below
#include <errno.h> // needed to set errno in the even that the input of sin is an infinity
@leptos-null
leptos-null / UIOrientationPortableState.h
Created April 26, 2019 04:01
An idea for maintaining orientation state through notify_state
union UIOrientationPortableState {
struct UIOrientationState {
enum UIOrientation { /* this is UIInterfaceOrientation, but unsigned */
UIOrientationUnknown,
UIOrientationPortrait,
UIOrientationPortraitUpsideDown,
UIOrientationLandscapeRight,
UIOrientationLandscapeLeft
}
current : 3, // may be the orientation the device is transitioning to, if transition != UITransitionPhaseZero
@leptos-null
leptos-null / floating.c
Created March 3, 2019 23:00
Visualizing and understanding IEEE 754 floating point values
//
// floating.c
// funbits
//
// Created by Leptos on 8/18/18.
// Copyright © 2018 Leptos. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
@leptos-null
leptos-null / protobuf.nanorc
Last active December 19, 2018 23:50
Protobuf syntax highlighting for nano
## Protobuf syntax highlighting for nano by Leptos
## Based off creekpld's Swift syntax highlighter
syntax "Protobuf" "\.proto$"
# Default
color white ".+"
# Keywords
color yellow "^ *\<(syntax|package|import|option)\>"
@leptos-null
leptos-null / inspectivec.cy
Last active December 15, 2018 23:31
InspectiveC module for Cycript
/* InspectiveC by DavidGoldman
* Place this file in `/usr/lib/cycript0.9/com/golddavid/inspectivec.cy`
* Run `@import com.golddavid.inspectivec` in cycript to use.
*
* This file has been adapted from
* https://github.com/DavidGoldman/InspectiveC/blob/master/cycript/InspectiveC.cy
* to use new cycript module features.
*
* This module is based on
* https://github.com/limneos/classdump-dyld/blob/master/classdumpdyldlib/classdumpdyld.cy
@leptos-null
leptos-null / YTIThumbnailDetails.md
Last active December 15, 2018 22:57
Odd encoding in YTIThumbnailDetails property list

YTIThumbnailDetails classdump notes

While class dumping YouTube Music, I ran into two problematic properties in a protobuf-generated class.

The property largestImageSource had the type encoding

{YTImageSource=@@{YTClientResource=@@{optional<unsigned int>=B(?={dummy_type=[4{empty_struct=}]}I)}}{optional<unsigned int>=B(?={dummy_type=[4{empty_struct=}]}I)}{optional<unsigned int>=B(?={dummy_type=[4{empty_struct=}]}I)}}
@leptos-null
leptos-null / lw.zsh
Last active September 21, 2018 22:19
List which: zsh function to print full information about a command
function lw() {
for ARG in "$@"
do
WHICH_RESULT=$(which "$ARG") && {
[[ -e "$WHICH_RESULT" ]] && {
l "$WHICH_RESULT"
continue
}
}
echo "$WHICH_RESULT"