Skip to content

Instantly share code, notes, and snippets.

View skoch's full-sized avatar
🍋
Surly, since 1999.

Stephen Koch skoch

🍋
Surly, since 1999.
View GitHub Profile
@skoch
skoch / konami.js
Created May 25, 2017 19:42
Konami code with node
module.exports = function(pattern, callback) {
var konami = {
addEvent: function(obj, type, fn, refObj) {
if (obj.addEventListener) {
obj.addEventListener(type, fn, false);
} else if (obj.attachEvent) {
// IE
obj[`e${type}${fn}`] = fn;
obj[type + fn] = function() {
obj[`e${type}${fn}`](window.event, refObj);
@skoch
skoch / contentful-retina-output.css
Last active April 21, 2017 22:15
Output from contentful-retina mixin
/* usage */
.something {
@include contentful_retina('space_id/asset_id/token/name.jpg', 1024, 3, cover, no-repeat center center);
}
/* output */
.something {
background: url("http://images.contentful.com/space_id/asset_id/token/name.jpg?w=1024") no-repeat center center;
background-size: cover; }
@media all and (-webkit-min-device-pixel-ratio: 1.5), all and (-o-min-device-pixel-ratio: 3 / 2), all and (min--moz-device-pixel-ratio: 1.5), all and (min-device-pixel-ratio: 1.5) {
.something {
@skoch
skoch / contentful-retina.scss
Created April 21, 2017 22:05
Allows you to use retina images at various pixel densities on Contentful.
/**
* Allows you to use retina images at various pixel densities on Contentful.
* Note: you will need to upload the highest resolution!
* Examples:
*
* @include retina("/images/mypic.jpg", 2);
* @include retina("/images/mypic.jpg", 3, 100px 100px, left top no-repeat transparent);
*
* @param {Value} $path The path to the file name.
* @param {Value} $base_size The base size to start with. Will at least create @1x and @2x and more if cap is 3 or higher
@skoch
skoch / tokenRefreshNotification.m
Created October 21, 2016 20:16
So that we can connect to the FMS once we get that token
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(tokenRefreshNotification:)
name:kFIRInstanceIDTokenRefreshNotification object:nil];
@skoch
skoch / firebase-appdelegate.h
Created October 21, 2016 20:11
Firebase AppDelegate.h
@import UserNotifications;
@import Firebase;
@import FirebaseMessaging;
@interface AppDelegate : UIResponder <UIApplicationDelegate, UNUserNotificationCenterDelegate, FIRMessagingDelegate>
@skoch
skoch / firebase-init-notification-setup.m
Created October 21, 2016 20:06
Firebase initialization and register for remote notifications
[FIRApp configure];
if( floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max )
{
// iOS 9
UIUserNotificationType allNotificationTypes = ( UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge );
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
}else
{
@skoch
skoch / hcs-naming-conventions.md
Last active October 5, 2016 19:53
Naming Conventions

HCS Naming Conventions

Files

  • No spaces, always lowercase
  • Hyphens for word boundaries, underscore for content/concern separation
  • IMAGES: bg/logo/graphic/icon prefix. Illustrates file purpose at a glance
@skoch
skoch / setContentGutterForIphoneUsingView
Created June 12, 2015 16:59
All this to center content in a view for iPhones
- ( void )setContentGutterForIphoneUsingView:( UIView * )view
{
// macro to determine device
if( IS_IPHONE )
{
UIView *container = [UIView new];
container.backgroundColor = [UIColor clearColor];
container.translatesAutoresizingMaskIntoConstraints = NO;
UIView *content = [UIView new];
@skoch
skoch / hmh-home-skip-buttons
Created June 9, 2015 14:37
Home & Skip button (HMH)
NSString *homeImageName = @"button-home";
NSString *homeImageBGName = @"button_bg";
NSString *skipImageName = @"button-skip";
NSString *skipImageBGName = @"button_bg";
CGRect frame = CGRectMake( -50, BUTTON_MARGIN_IPAD, 50, 50 );
if( IS_IPHONE )
{
frame = CGRectMake( -46, BUTTON_MARGIN_IPHONE, 46, 46 );
@skoch
skoch / keybase.md
Created April 8, 2015 13:43
keybase.io

Keybase proof

I hereby claim:

  • I am skoch on github.
  • I am skoch (https://keybase.io/skoch) on keybase.
  • I have a public key whose fingerprint is 028C 43D8 6544 5E92 B7ED C776 8B03 2F53 9820 80CD

To claim this, I am signing this object: