Skip to content

Instantly share code, notes, and snippets.

View madson's full-sized avatar
👨‍💻
Always coding

Madson Mac madson

👨‍💻
Always coding
View GitHub Profile
@1kastner
1kastner / reflect.py
Last active August 12, 2024 15:24 — forked from huyng/reflect.py
A simple echo server to inspect http web requests
#!/usr/bin/env python
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
# Written by Nathan Hamiel (2010)
from http.server import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
@CollectiveHealth-gists
CollectiveHealth-gists / rxSwiftTask.swift
Created August 8, 2017 18:50
RxSwift Download Image from Url
URLSession.shared.rx
.response(imageURL)
// subscribe on main thread
.subscribeOn(MainScheduler.sharedInstance)
.subscribe(onNext: { [weak self] data in
// Update Image
self?.imageView.image = UIImage(data: data)
}, onError: {
// Log error
}, onCompleted: {
@adamcichy
adamcichy / ImageDarkness.swift
Created March 15, 2017 15:28
Determine if a UIImage is generally dark or generally light in Swift 3
extension CGImage {
var isDark: Bool {
get {
guard let imageData = self.dataProvider?.data else { return false }
guard let ptr = CFDataGetBytePtr(imageData) else { return false }
let length = CFDataGetLength(imageData)
let threshold = Int(Double(self.width * self.height) * 0.45)
var darkPixels = 0
for i in stride(from: 0, to: length, by: 4) {
let r = ptr[i]
@phatblat
phatblat / SpecFunctions.swift
Last active May 29, 2016 14:46
Swift 2.2 curried functions for asserting IB outlets and actions are wired up correctly.
//
// SpecFunctions.swift
//
// Created by Ben Chatelain on 6/6/15.
// Copyright (c) 2015-2016 Ben Chatelain.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//: Mocks Playground
import UIKit
struct User {
}
struct PushNotificationController {
let registrar: PushNotificationRegistrar
init(registrar: PushNotificationRegistrar) {

Implementing a Strong Code-Review Culture

As an author

  • Provide more/sufficient context around changes
  • Linking to the issue isn't always enough
  • Challenge: 2 paragraphs of context

As a reviewer

  • Offer compliments in PRs when you learn or something is done well
  • Ask questions rather than make demands/commands, engage in conversation
@mtauraso
mtauraso / add_launchd_to_tcc.sh
Last active February 10, 2021 04:45
TCC Database Script
#!/bin/bash
# This will add lauchd to the list of allowed processes for accessibility access
sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "INSERT or REPLACE INTO access VALUES('kTCCServiceAccessibility','/sbin/launchd',1,1,1,NULL)"
# This outputs the rows in the TCC database
sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db 'select * from access'
echo "Restart is required for these changes to take effect"
@edwardmp
edwardmp / gist:df8517aa9f1752e73353
Created May 22, 2015 16:06
Using NSURLSession with SSL public key pinning
/*
1. Adhere to the NSURLSessionDelegate delegate
2. Initialize NSURLSession and specify self as delegate (e.g. [NSURLSession sessionWithConfiguration:defaultConfigObject delegate:self delegateQueue: [NSOperationQueue mainQueue]];)
3. Add the method below to your class
4. Change the certificate resource name
*/
- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler
{
SecTrustRef serverTrust = challenge.protectionSpace.serverTrust;
@JadenGeller
JadenGeller / Logical XOR.swift
Created March 26, 2015 23:26
Swift Logical XOR
infix operator ^^ { associativity left precedence 120 }
func ^^<T : BooleanType, U : BooleanType>(lhs: T, rhs: U) -> Bool {
return lhs.boolValue != rhs.boolValue
}
// Example
false ^^ false // -> false
false ^^ true // -> true
@Pilon
Pilon / gist:57f7ccd27b58e3b2d375
Created March 12, 2015 18:19
desafio_de_programação_mobile
Como parte do processo seletivo do Elo7, gostaríamos que você fizesse uma
pequena tarefa. Conforme seu resultado daremos continuidade ao processo te
convidando para uma sessão de pair-programming.
Durante o desenvolvimento dê preferência para implementação em Android ou iOS.
O objetivo dessa tarefa é avaliar como você vai desenvolver o código em termos
de estilo, eficiência e qualidade.
Crie um projeto no seu Github para que vejamos os passos feitos através dos