Skip to content

Instantly share code, notes, and snippets.

//
// Keyboardable.swift
//
// Created by Matěj Jirásek on 18/10/2016.
// Copyright © 2016 Matěj K. Jirásek. All rights reserved.
//
import Foundation
protocol Keyboardable {
@algal
algal / PrintToStdErr.swift
Last active July 27, 2022 06:47
print to stderr in Swift 3
// known-good: Xcode 8, Swift 3
import Foundation
var standardError = FileHandle.standardError
extension FileHandle : TextOutputStream {
public func write(_ string: String) {
guard let data = string.data(using: .utf8) else { return }
@zthomas
zthomas / intercom-delete-old-users.js
Last active May 1, 2023 15:28
Script to delete and clear old users from intercom. Useful for lowering the monthly bill
// License: MIT, feel free to use it!
const Intercom = require('intercom-client');
const appId = 'APP_ID'
const apiKey = 'APP_KEY'
const client = new Intercom.Client(appId, apiKey);
const async = require('async-q')
//REF: https://developers.intercom.com/reference#iterating-over-all-users
//WARNING: you can only have one scroll working at once. you need to wait for that scroll to clear to try again
@troyhunt
troyhunt / Build-Troys-Network
Last active November 14, 2024 09:56
Help me spec out a replacement home network using Ubiquiti bits
That's it - I've finally lost it with Linksys and both my WRT 1900ACs that are only a year old are getting chucked. Don't get me started on all the reasons why, but it's primarily down to continued degradation of wifi signal and the constant need for reboots. Going by the responses to this tweet, that's just what they do: https://twitter.com/troyhunt/status/778867707655487488
I’m going all out with Ubiquiti instead. No, I'm not interested in [insert the other thing you think rocks here], there's a really vocal majority in favour of Ubiquiti so that's that. Now I need help speccing out what I need for my house as it’s not quite as straight forward as just chucking in a couple of (dodgy) routers.
Here’s what I’m working with:
- Large multi-level house about 500m2 (needs at least 2 APs, probably more)
- Wired ethernet to every room (I believe Cat 5e, was here when I got here)
- Patch board in the garage and a 100Mbps hub (running patch cables out to a Linksys 8 port gigabit switch instead)
- 4 wired connection
@wesleybliss
wesleybliss / docker-compose-node-mongo.yml
Created September 9, 2016 21:37
Docker Compose with example App & Mongo
version: '2'
services:
myapp:
build: .
container_name: "myapp"
image: debian/latest
environment:
- NODE_ENV=development
- FOO=bar
volumes:
@at-daonguyen
at-daonguyen / Podfile
Created June 30, 2016 03:45
Disable BITCODE for all Pods
source 'https://github.com/CocoaPods/Specs.git'
inhibit_all_warnings!
platform :ios, '8.0'
use_frameworks!
target 'Example' do
# frameworks
end
# BITCODE bug fix
//
// UIImage+CKAsset.swift
// CloudKitDemo
//
// Created by Marcus Smith on 2/29/16.
// Copyright © 2016 FrozenFireStudios. All rights reserved.
//
import UIKit
import CloudKit
@alexpchin
alexpchin / socket-cheatsheet.js
Created December 15, 2015 16:58
A quick cheatsheet for socket.io
// sending to sender-client only
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
@hxx0215
hxx0215 / UIFont+ChangeFont.m
Created September 25, 2015 14:37
Change SystemFont through runtime (include xib and storyboard)
#import "UIFont+ChangeFont.h"
#import <objc/message.h>
NSString *const CustomFontName = @"RTWSYueRoudGoDemo-Regular";
@implementation UIFont (ChangeFont)
+ (void)load {
[self exchangeClassMethod:@selector(systemFontOfSize:) modified:@selector(custom_systemFontOfSize:)];
[self exchangeClassMethod:@selector(boldSystemFontOfSize:) modified:@selector(custom_boldSystemFontOfSize:)];
[self exchangeInstanceMethod:@selector(initWithCoder:) modified:@selector(initCustomWithCoder:)];
}
@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;