Skip to content

Instantly share code, notes, and snippets.

@lukeredpath
lukeredpath / ExampleClass.m
Created June 30, 2011 22:18
Macro for creating your "shared instance" using GCD
@implementation MySharedThing
+ (id)sharedInstance
{
DEFINE_SHARED_INSTANCE_USING_BLOCK(^{
return [[self alloc] init];
});
}
@end
@jasonrudolph
jasonrudolph / about.md
Last active May 14, 2024 16:36
Programming Achievements: How to Level Up as a Developer
@danpalmer
danpalmer / OAuthRequestSigner.m
Created September 16, 2012 15:42
Sign OAuth Requests
//
// OAuthRequestSigner.m
// -----
//
// Created by Dan Palmer on 29/07/2012.
// Copyright (c) 2012 Dan Palmer. All rights reserved.
//
#import "OAuthRequestSigner.h"
@psobko
psobko / UITextField leftView UIImageView padding
Created October 26, 2013 18:53
UITextField padding with a custom leftView UIImageView
-(UIView*)paddingViewWithImage:(UIImageView*)imageView andPadding:(float)padding
{
float height = CGRectGetHeight(imageView.frame);
float width = CGRectGetWidth(imageView.frame) + padding;
UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
[paddingView addSubview:imageView];
return paddingView;
@JeanMeche
JeanMeche / gist:50102a47937e9896e4f4
Created April 19, 2015 16:47
Levenshtein — swift
/**
* Levenshtein edit distance calculator
* Usage: levenstein <string> <string>
*
* Inspired by https://gist.github.com/bgreenlee/52d93a1d8fa1b8c1f38b
* Improved with http://stackoverflow.com/questions/26990394/slow-swift-arrays-and-strings-performance
*/
class Tools {
@k4kfh
k4kfh / arduinoWelder.ino
Created February 21, 2017 22:38
Non-blocking Arduino Arc Welder Simulator
unsigned long currentMillis = 0;
unsigned long previousMillisArc = 0;
unsigned long previousMillisFlicker = 0;
int timeArcOff = 3000;
int timeArcOn = 3000;
bool arc = false; //whether there's an arc right now or not
int ledState = LOW;
const int ledPin = 2;
int timeFlickerOn = 50;
int timeFlickerOff = 170;
@sanzaru
sanzaru / Collapsible.swift
Last active February 15, 2024 15:26
SwiftUI collapsible view
import SwiftUI
struct Collapsible<Content: View>: View {
@State var label: () -> Text
@State var content: () -> Content
@State private var collapsed: Bool = true
var body: some View {
VStack {