Skip to content

Instantly share code, notes, and snippets.

View kouky's full-sized avatar

Michael Koukoullis kouky

View GitHub Profile
@nsforge
nsforge / gist:8949790
Created February 12, 2014 03:51
Demonstration of uint64 accuracy bug in NSJSONSerialization
NSString *jsonString = @"{\"myNumber\":1029742590268606522}";
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:NULL];
NSLog(@"jsonDict: %@", jsonDict);
uint64_t myNumber = [jsonDict[@"myNumber"] unsignedLongLongValue];
NSLog(@"myNumber: %llu", myNumber);
/*
@nsforge
nsforge / Warnings.xcconfig
Created February 26, 2015 04:39
Standard Xcode Warnings (for use in .xcconfig files)
// Apple LLVM - Warnings - All languages
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES
CLANG_WARN_EMPTY_BODY = YES
GCC_WARN_SHADOW = YES
CLANG_WARN_CONSTANT_CONVERSION = YES
GCC_WARN_64_TO_32_BIT_CONVERSION = YES
CLANG_WARN_ENUM_CONVERSION = YES
CLANG_WARN_INT_CONVERSION = YES
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES
# Rackup file for serving up a static site from a "public" directory
#
# Useful for chucking a static site on Heroku
class IndexRewriter
def initialize(app) @app = app end
def call(env)
env["PATH_INFO"].gsub! /\/$/, '/index.html'
@app.call(env)
end
@xaviershay
xaviershay / ruby_require_speed.patch
Created May 1, 2011 01:00
This drastically speeds up require time on ruby 1.9 (17s down to 10s in our production rails app) , at the expense of disabling some edge case handling around autoloading. YMMV but it works for our rails app.
From 2fb8432982b7e8ffc4c05f912f47cd9ca7261427 Mon Sep 17 00:00:00 2001
From: Xavier Shay <xavier@rhnh.net>
Date: Sun, 1 May 2011 10:25:18 +1000
Subject: [PATCH] Disable some edge cases in requiring to speed it up.
---
load.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/load.c b/load.c
@RayHughes
RayHughes / SKTexture gradient extension
Last active October 6, 2016 20:42 — forked from craiggrummitt/SKTexture gradient extension
SKTexture gradient extension
/**
Extensions.swift
- Create a linear gradient texture for a SKShapeNode and SKSpriteNode
- UIColor from hex value
- Get (n)th character of a string
- Convert string to float
Based on Extensions.swift by Craig Grummit (https://gist.github.com/craiggrummitt/ad855e358004b5480960)
Swift 2 Compatability by Ray Hughes (https://gist.github.com/RayHughes/3162fcbda6439893b539)
@kristopherjohnson
kristopherjohnson / NSData_hexadecimalString.swift
Last active July 14, 2018 12:44
Convert NSData bytes to hexadecimal string
import Foundation
extension NSData {
/// Return hexadecimal string representation of NSData bytes
@objc(kdj_hexadecimalString)
public var hexadecimalString: NSString {
var bytes = [UInt8](count: length, repeatedValue: 0)
getBytes(&bytes, length: length)
@gwengrid
gwengrid / TypeErasure.swift
Last active September 12, 2018 05:14
Example of type erasure with Pokemon
class Thunder { }
class Fire { }
protocol Pokemon {
typealias PokemonType
func attack(move:PokemonType)
}
struct Pikachu: Pokemon {
typealias PokemonType = Thunder
@warnergodfrey
warnergodfrey / gist:7512051
Last active September 21, 2018 03:20
Access the ATO Business Portal using AusKey Mac OS X Mountain Lion
  • Install the latest JRE from Oracle
  • In the Java Control Panel, go to the Security tab and make sure 'Enable Java Content' is checked
  • Open Safari
  • Go to the ATO Business portal site https://bp.ato.gov.au/BpStatics/homepage.htm
  • Click Login
  • A dialog will apear asking you 'Do you want to trust the website “authentication.business.gov.au” to use the “Java” plug-in?'
  • Click 'Trust'
  • Now you will be asked 'Do you want to run this application?'
  • Click 'Run'
  • Another dialog will appear asking you to 'Allow access to the following application from this website?'
@paulirish
paulirish / README.md
Created January 4, 2010 02:38
imagesLoaded() jquery plugin
@rwarbelow
rwarbelow / running_app_in_production_locally.markdown
Created November 11, 2015 18:26
How to Run a Rails App in Production Locally
  1. Add gem 'rails_12factor' to your Gemfile. This will add error logging and the ability for your app to serve static assets.
  2. bundle
  3. Run RAILS_ENV=production rake db:create db:migrate db:seed
  4. Run rake secret and copy the output
  5. From the command line: export SECRET_KEY_BASE=output-of-rake-secret
  6. To precompile your assets, run rake assets:precompile. This will create a folder public/assets that contains all of your assets.
  7. Run RAILS_ENV=production rails s and you should see your app.

Remember to clobber your assets (rake assets:clobber) and re-precompile (rake assets:precompile) if you make changes.