Skip to content

Instantly share code, notes, and snippets.

View skeptycal's full-sized avatar
🏠
Available for Remote

Michael Treanor skeptycal

🏠
Available for Remote
View GitHub Profile
@skeptycal
skeptycal / detweet.swift
Created January 12, 2022 05:02 — forked from mxcl/detweet.swift
Delete all tweets and favorites older than two months ago. Instructions in comment.
#!/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"
extension UIImage {
func blurred(radius: CGFloat) -> UIImage {
let ciContext = CIContext(options: nil)
guard let cgImage = cgImage else { return self }
let inputImage = CIImage(cgImage: cgImage)
guard let ciFilter = CIFilter(name: "CIGaussianBlur") else { return self }
ciFilter.setValue(inputImage, forKey: kCIInputImageKey)
ciFilter.setValue(radius, forKey: "inputRadius")
guard let resultImage = ciFilter.value(forKey: kCIOutputImageKey) as? CIImage else { return self }
extension UIImage {
func darkened() -> UIImage? {
UIGraphicsBeginImageContextWithOptions(size, false, 0)
defer { UIGraphicsEndImageContext() }
guard let ctx = UIGraphicsGetCurrentContext(), let cgImage = cgImage else {
return nil
}
// flip the image, or result appears flipped
@skeptycal
skeptycal / uninstall_homebrew.sh
Last active January 12, 2022 04:55 — forked from mxcl/uninstall_homebrew.sh
Uninstall Homebrew
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
@skeptycal
skeptycal / closure.md
Created January 21, 2021 18:36 — forked from sgnl/closure.md
Closures - Princess Story
@skeptycal
skeptycal / postgres-brew.md
Created January 21, 2021 18:32 — forked from ibraheem4/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@skeptycal
skeptycal / pprint_number.py
Created January 16, 2021 07:46 — forked from lelandbatey/pprint_number.py
Pretty print large base 10 numbers and base 2 numbers
# Take a very large number and pretty print it in triplets of 3 digits, each triplet separated by a space.
def pnum_spc(n): print(' '.join([''.join(list(str(n))[::-1][i:i+3]) for i in range(0, len(str(n)), 3)][::-1]))
# >>> pnum_spc(32 ** 13)
# 36 893 488 147 419 103 232
# Print numbers as 32-bit binary numbers w/ spaces giving 4-bit words
def pbin_spc(n): print(' '.join([''.join(list(f'{n:032b}')[::-1][i:i+4][::-1]) for i in range(0, len(f'{n:032b}'), 4)][::-1]))
# >>> "{0:032b}".format(1234)
# '00000000000000000000010011010010'
# >>> pbin_spc(1234)
@skeptycal
skeptycal / assign_struct_field_by_tag_name.go
Created January 16, 2021 07:45 — forked from lelandbatey/assign_struct_field_by_tag_name.go
Golang reflection; assign to struct field by tag name
package main
import (
"fmt"
"reflect"
"strings"
)
// The goal: allow assignment to a go struct field based on the name that field
// is tagged with (specifically it's json-tagged name).
@skeptycal
skeptycal / git: gitignore.md
Created January 8, 2021 22:32 — forked from jstnlvns/git: gitignore.md
a gitignore cheatsheet

Git sees every file in your working copy as one of three things:

  1. tracked - a file which has been previously staged or committed;
  2. untracked - a file which has not been staged or committed; or
  3. ignored - a file which Git has been explicitly told to ignore.

Ignored files are usually build artifacts and machine generated files that can be derived from your repository source or should otherwise not be committed. Some common examples are:

  • dependency caches, such as the contents of /node_modules or /packages
  • compiled code, such as .o, .pyc, and .class files
@skeptycal
skeptycal / gist:b9901c79fd3f8a0e5753fdbc97a6d946
Created September 27, 2020 02:19 — forked from benjamingwynn/gist:3708951
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream