Skip to content

Instantly share code, notes, and snippets.

Eric Miller SimplGy

Block or report user

Report or block SimplGy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@SimplGy
SimplGy / logVCinitAndDeinit.swift
Created Feb 12, 2016
Sometimes you need to make sure init and deinit happen in the right order on your View Controllers, and you don't stand up two at once.
View logVCinitAndDeinit.swift
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
print("init nibName: \(self) \(unsafeAddressOf(self))")
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
print("init coder: \(self) \(unsafeAddressOf(self))")
}
deinit {
print("deinit coder: \(self) \(unsafeAddressOf(self))")
@SimplGy
SimplGy / app.analytics.coffee
Last active Jan 4, 2016
Abstraction for an SPA's Analytics Library
View app.analytics.coffee
define(
[]
() ->
_analyticsSites =
DEMO: 1
LOCALHOST: 2
_libUrl = (server) ->
'js!' + server + '/js/piwik.js'
@SimplGy
SimplGy / rotationalCipher.rb
Created Oct 10, 2013
Ruby Implementation of a Rotational Cipher. Wrote in https://coderpad.io/966172
View rotationalCipher.rb
$ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
$alphabet = 'abcdefghijklmnopqurstvwxyz'
# Get an index of an alphabetic letter based on the index and offset
def calculateOffset(index, offset)
index += offset
index -= 26 while index >= 26 # keep subtracting until we get to the right range
index
end
@SimplGy
SimplGy / promise.js
Last active Dec 25, 2015
Sample Promise Implementation. Wrote in https://coderpad.io/626322
View promise.js
// --------------------------------------------- Promise Implementation
Promise = function () {
this._stack = [];
this._isResolved = false;
}
Promise.prototype = {
success: function(callback){
// Is the promise already resolved?
if(this._isResolved) {
callback( this._result );
@SimplGy
SimplGy / algorithm test
Created Aug 30, 2013
Favorite unit test yet :) Uses a loop over a hash to test expectations
View algorithm test
define [
'./circles'
],
(
Circles
) ->
_data = [
{ size: 2 }
{ size: 2 }
@SimplGy
SimplGy / 2xBackground
Created Aug 12, 2013
Creates 1x and 2x background images. The 200% means that the pixel offsets will work on both the small and large images. Make sure your sprites line up exactly, so that the 2x images are exactly twice as big, twice as low, and twice as left.
View 2xBackground
//Support 1 and 2x image sizes
@mixin 2xBackground($url)
background-image: url($url + ".png")
@media only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3)
background-image: url($url + "@2x.png")
background-size: 200%
@SimplGy
SimplGy / screenSizeHelpers.sass
Last active Dec 20, 2015
Allows you to use simple block statements to conditionally target +phone, +desktop, and +tablet
View screenSizeHelpers.sass
$sizePhone: 603px
$sizeTablet: 1024px
@mixin phone
@media (max-width: $sizePhone)
@content
@mixin tablet
@media (min-width: $sizePhone+1) and (max-width: $sizeTablet)
@content
@SimplGy
SimplGy / apple-app-site-association
Last active Dec 20, 2015
Waitress app site assoc file
View apple-app-site-association
{
"applinks": {
"apps": [],
"details": [
{
"appID": "68Q8TRPLTN.com.waitress.ios",
"paths": [ "/place/*" ]
}
]
}
@SimplGy
SimplGy / animationPlay
Last active Dec 18, 2015
SASS Animation Play
View animationPlay
$colorGood: lawngreen
.circle
background: $colorGood
.circle.yay
+animation( blammo .5s )
+keyframes(blammo)
@SimplGy
SimplGy / rockerButton.sass
Last active Dec 17, 2015
SASS styles for an image free rocker switch button for yes/no or similar 2 option choices. It's tricky in part because it's the `.active` state that has little styling, but the inactive state has transforms and other wonkiness. Output looks like this: http://i.imgur.com/twwQM3e.png
View rockerButton.sass
// Result: http://i.imgur.com/twwQM3e.png
@import '../bower_components/bourbon/app/assets/stylesheets/_bourbon.scss'
$colorBackbground: whitesmoke
$colorForeground: #333
$colorGood: springgreen
$radiusSmall: 4px
$spaceTiny: 3px
$spaceLil: 10px
You can’t perform that action at this time.