Skip to content

Instantly share code, notes, and snippets.

View iainsmith's full-sized avatar

Iain Smith iainsmith

View GitHub Profile
@kmayer
kmayer / sidekiq.rb
Created September 8, 2013 17:41
Sidekiq Exception tracer for NewRelic Add this to your sidekiq initializer
module NewRelic
class SidekiqException
def call(worker, msg, queue)
begin
yield
rescue => exception
NewRelic::Agent.notice_error(exception, :custom_params => msg)
raise exception
end
end
@jayuen
jayuen / gist:6787780
Created October 2, 2013 01:22
DateWithTimezone
define("DateWithTimezone", function(module) {
var DateWithTimezone = function(moment){
this.moment = moment
moment.tz(DateWithTimezone.getTimezone())
}
_.extend(DateWithTimezone.prototype, {
toISO: function(){
return this.format()
},
@bomberstudios
bomberstudios / sketch-plugins.md
Last active January 2, 2026 16:22
A list of Sketch plugins hosted at GitHub, in no particular order.
@kharmabum
kharmabum / tappable-nav-bar.m
Last active July 20, 2016 15:17
Tappable title view UINavigationBar
#pragma mark - UIGestureRecognizerDelegate
// Toggle mode through touch gesture on navigation bar
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
return (self.navigationController.visibleViewController == self &&
(ABS([touch locationInView:self.navigationController.navigationBar].x - self.navigationController.navigationBar.width/2) < 50));
}
- (void)viewWillAppear:(BOOL)animated {
@nonamelive
nonamelive / DMNavigationBar.h
Last active July 20, 2016 15:17
Prevent UINavigationBar from stealing touches
@interface DMNavigationBar : UINavigationBar
@property (nonatomic, assign) BOOL shouldOnlyReceiveTouchEventsInsideNavigationBar;
@end
@Koze
Koze / DynamicTypeUI.m
Last active October 10, 2018 20:57
Dynamic Type for some UI components
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// UINavigationBar title
[[UINavigationBar appearance] setTitleTextAttributes:@{NSFontAttributeName: [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline]}];
// UIBarButtonItem title
[[UIBarButtonItem appearance] setTitleTextAttributes:@{NSFontAttributeName: [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]}
forState:UIControlStateNormal];
// UITabBarItem title
[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName: [UIFont preferredFontForTextStyle:UIFontTextStyleCaption1]}
forState:UIControlStateNormal];
@TheRayTracer
TheRayTracer / lm75a.sh
Created November 8, 2015 11:20
This entry contributes a simple Bash script to query and control a LM75 Digital Temperature Sensor via I2C. The second Bash script is a utility to interact with a real-time clock (RTC). The third entry is a Python script for a mini web server to retrieve the temperature in either Celsius (default) or Fahrenheit. These were a few very fun weekend…
#!/bin/bash
readonly lm75=0x48 # Slave address with A0, A1, and A2 set to 0v (ground).
while [ $# -gt 0 ]
do
if [ "$1" == "-debug" ]
then
debug=true
fi
@rnapier
rnapier / observable.swift
Last active January 27, 2018 20:45
Observable sketch
import Foundation
typealias ObserverRemover = () -> Void
/*! An observable value
An `Observable` wraps any value. If you add an observer handler, then every time the value is set, your handler will be
called with the new value. Adding an observer returns a closure that is used to remove the observer. Note that the handler
is called every time the value is set, even if this does not change the value. If you only want the handler to be called
when the value changes, see `CoalescingObservable`.
@KeithPiTsui
KeithPiTsui / thin-frameworks.sh
Created October 31, 2017 08:40 — forked from sundeepgupta/thin-frameworks.sh
Bash script to thin fat iOS frameworks. Strips non-valid architectures from fat framework binaries.
# Adapted from https://github.com/realm/realm-cocoa/blob/master/scripts/strip-frameworks.sh
# This script strips all non-valid architectures from dynamic libraries in
# the application's `Frameworks` directory which is required for App Store submission.
#
# The following environment variables are required:
#
# BUILT_PRODUCTS_DIR
# FRAMEWORKS_FOLDER_PATH
# VALID_ARCHS
@markd2
markd2 / typealias.swift
Created January 22, 2018 18:16
libsyntax typealias creation
import SwiftSyntax
@greeble(bork) typealias Element = Int
let typeAliasKeyword = SyntaxFactory.makeTypealiasKeyword(leadingTrivia: .spaces(1),
trailingTrivia: .spaces(1))
let elementID = SyntaxFactory.makeIdentifier("Element", leadingTrivia: .zero, trailingTrivia: .spaces(1))
let equal = SyntaxFactory.makeEqualToken(leadingTrivia: Trivia.zero, trailingTrivia: .spaces(1))
let intType = SyntaxFactory.makeTypeIdentifier("Int", leadingTrivia: .zero, trailingTrivia: .zero)
let initializer = SyntaxFactory.makeTypeInitializerClause(equal: equal, value: intType)