Skip to content

Instantly share code, notes, and snippets.

@michelp
michelp / postgrest-quick.sh
Last active April 13, 2022 21:42
From nothing to REST API with PostgREST
# Minimal example of getting a PostgREST API running from scratch for
# testing purposes. It uses docker to launch a postgres database and
# a postgrest api server.
# This should not be used to deploy a production system but to
# understand how postgrest works. In particular there is no security
# implemented, see the docs for more.
# https://postgrest.org/en/v4.4/
@norio-nomura
norio-nomura / PlayAppleSpecialEventSeptember2015InPlayground.swift
Created October 8, 2015 00:53
Playing "Apple Special Event September 2015" in Playground on Xcode 7.1 beta 3. #swiftlang
/// Playing Apple Special Event September 2015 in Playground on Xcode 7.1 beta 3
/// Work load will be lowest when Platform = "OS X"
import AVFoundation
import AVKit
import XCPlayground
protocol Playable: XCPlaygroundLiveViewable {
var player: AVPlayer? {get set}
}
@praeclarum
praeclarum / ArrayDiff.swift
Last active January 8, 2021 06:10
A generic diffing operation that can calculate the minimal steps needed to convert one array to another. It can be used to generate standard diffs, or it can be used more creatively to calculate minimal UI updates.
//
// ArrayDiff.swift
//
// Created by Frank A. Krueger on 6/30/15.
// Copyright © 2015 Krueger Systems, Inc. All rights reserved.
// License: MIT http://opensource.org/licenses/MIT
//
import Foundation
@chrismdp
chrismdp / s3.sh
Last active March 5, 2024 12:57
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@yoichitgy
yoichitgy / mergegenstrings.py
Last active July 9, 2022 23:59
A script to generate .strings file for .swift, .m, .storyboard and .xib files by genstrings and ibtool commands, and merge them with existing translations.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Localize.py - Incremental localization on XCode projects
# João Moreno 2009
# http://joaomoreno.com/
# Modified by Steve Streeting 2010 http://www.stevestreeting.com
# Changes
# - Use .strings files encoded as UTF-8
@Abizern
Abizern / loggingPrint.swift
Last active September 22, 2021 14:28
Debug logging for Swift
//
// LoggingPrint.swift
//
import Foundation
/**
Prints the filename, function name, line number and textual representation of `object` and a newline character into
the standard output if the build setting for "Active Complilation Conditions" (SWIFT_ACTIVE_COMPILATION_CONDITIONS) defines `DEBUG`.
@jspahrsummers
jspahrsummers / GHRunLoopWatchdog.h
Created January 28, 2015 20:50
A class for logging excessive blocking on the main thread
/// Observes a run loop to detect any stalling or blocking that occurs.
///
/// This class is thread-safe.
@interface GHRunLoopWatchdog : NSObject
/// Initializes the receiver to watch the specified run loop, using a default
/// stalling threshold.
- (id)initWithRunLoop:(CFRunLoopRef)runLoop;
/// Initializes the receiver to detect when the specified run loop blocks for
@kaneshin
kaneshin / install_mergepbx.sh
Last active May 21, 2021 03:44
To install mergepbx. This script is under the MIT License.
#!/bin/sh
MERGEPBX_TARGET=mergepbx
MERGEPBX_PREFIX=/usr/local/bin
MERGEPBX_BUILD_DIR=/tmp
MERGEPBX_REPO=https://github.com/simonwagner/mergepbx.git
build()
{
cd $MERGEPBX_BUILD_DIR/$MERGEPBX_TARGET
@watert
watert / UITableView.swift
Last active July 21, 2017 15:10
UITableView example in iOS Playground with XCode 6 beta
// Playground - noun: a place where people can play
import UIKit
class ViewController: UIViewController ,UITableViewDelegate, UITableViewDataSource
{
var tableView: UITableView!
var items: NSMutableArray!
override func viewDidLoad() {
super.viewDidLoad()
/**
Provides the ability to verify key paths at compile time.
If "keyPath" does not exist, a compile-time error will be generated.
Example:
// Verifies "isFinished" exists on "operation".
NSString *key = SQKeyPath(operation, isFinished);
// Verifies "isFinished" exists on self.