Skip to content

Instantly share code, notes, and snippets.

Avatar
🏴
free labor

Jesse Squires jessesquires

🏴
free labor
View GitHub Profile
View protocols_vs_generics.swift
import Cocoa
protocol Shape { }
struct Triangle: Shape { }
// Function signature requires a concrete type T, it is specialized by T
// Think of it as having a unique function per type:
// - `protoflip(_ s: Triangle) -> Shape`
// - `protoflip(_ s: Square) -> Shape`
@jessesquires
jessesquires / detweet.swift
Created Jan 15, 2019 — forked from mxcl/detweet.swift
Delete all tweets and favorites older than two months ago. Instructions in comment.
View detweet.swift
#!/usr/bin/swift sh
import Foundation
import PromiseKit // @mxcl ~> 6.5
import Swifter // @mattdonnelly == b27a89
let swifter = Swifter(
consumerKey: "FILL",
consumerSecret: "ME",
oauthToken: "IN",
oauthTokenSecret: "https://developer.twitter.com/en/docs/basics/apps/overview.html"
View keybase.md

Keybase proof

I hereby claim:

  • I am jessesquires on github.
  • I am jsq (https://keybase.io/jsq) on keybase.
  • I have a public key whose fingerprint is BBAE BA80 7CF2 7BC2 5E5C FB43 1537 66AC 1FA1 A758

To claim this, I am signing this object:

View gist:8781c86206dfb70e78eb7f1aa4fc6fac
git config --global alias.trim '!f() { git branch | grep -v "\*" | xargs -n 1 git branch -D; }; f'
@jessesquires
jessesquires / feed.json
Last active Sep 5, 2017
Jekyll JSON Feed
View feed.json
---
layout: null
---
{
"version": "https://jsonfeed.org/version/1",
"title": "{{ site.title }}",
"home_page_url": "{{ site.url }}",
"feed_url": "{{ site.url }}/feed.json",
"description": "{{ site.description }}",
@jessesquires
jessesquires / gitsl.sh
Last active Apr 15, 2020
git "smartlog" / "pretty log"
View gitsl.sh
# blog post
#
# https://www.jessesquires.com/blog/customizing-git-log/
git log --graph --pretty=format:'commit: %C(bold red)%h%Creset %C(red)<%H>%Creset %C(bold magenta)%d %Creset%ndate: %C(bold yellow)%cd %Creset%C(yellow)%cr%Creset%nauthor: %C(bold blue)%an%Creset %C(blue)<%ae>%Creset%n%C(cyan)%s%n%Creset'
@jessesquires
jessesquires / FCPrivateBatteryStatus.m
Created Mar 18, 2016 — forked from marcoarment/FCPrivateBatteryStatus.m
How to get raw battery info (mAh remaining, etc.) from iOS using private APIs. For internal testing only, NOT APP STORE DISTRIBUTION!
View FCPrivateBatteryStatus.m
#import <Foundation/Foundation.h>
#include <dlfcn.h>
NSDictionary *FCPrivateBatteryStatus()
{
static mach_port_t *s_kIOMasterPortDefault;
static kern_return_t (*s_IORegistryEntryCreateCFProperties)(mach_port_t entry, CFMutableDictionaryRef *properties, CFAllocatorRef allocator, UInt32 options);
static mach_port_t (*s_IOServiceGetMatchingService)(mach_port_t masterPort, CFDictionaryRef matching CF_RELEASES_ARGUMENT);
static CFMutableDictionaryRef (*s_IOServiceMatching)(const char *name);
View boom.swift
import Cocoa
import MASShortcut
func pow() {
let rect = NSScreen.mainScreen()?.frame
let window = NSWindow(contentRect: rect!, styleMask: NSBorderlessWindowMask, backing: .Buffered, `defer`: false)
window.backgroundColor = NSColor.clearColor()
window.opaque = false
window.alphaValue = 1
window.makeKeyAndOrderFront(NSApplication.sharedApplication())
@jessesquires
jessesquires / generics_playground.swift
Last active Jun 27, 2018
Swift optional generic parameters?
View generics_playground.swift
protocol FactoryAType {
typealias Product
}
protocol FactoryBType {
typealias Product
}
You can’t perform that action at this time.