Skip to content

Instantly share code, notes, and snippets.

View paulfarino's full-sized avatar

Paul Farino paulfarino

View GitHub Profile
@paulfarino
paulfarino / iOS-Network-Connection
Created September 27, 2014 16:29
Reachability API Conditional Statement
Reachability * networkReachability = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [networkReachability currentReachabilityStatus];
if (networkStatus == NotReachable) {
NSLog(@”There Is NO internet connection”);
// show no connection view
} else {
NSLog(@”There IS internet connection”);
// show connected view
@paulfarino
paulfarino / asset-place.sh
Created September 11, 2015 02:50
Create a folder called on your Desktop called 'assets'. Use an 'img' & 'ic' suffix in your Sketch export panel. After exporting run this shell script to place those images in their appropriate folders.
cd Desktop/assets/
mkdir images; mkdir icons
done
for file in $(find . -type f -iname '*-img*'); do
mv "$file" "images/${file/-images/}"
done
for file in $(find . -type f -iname '*-ic*'); do
mv "$file" "icons/${file/-icons/}"
done
@paulfarino
paulfarino / EOL-semicolon.sublime-macro
Created November 12, 2015 04:41
Sublime Text Macro to insert a semicolon at the end of a line
// Add the following to `Sublime Text > Preferences > Keybindings - User`
[
{ "keys": ["command+shift+;"], "command": "run_macro_file", "args": {"file": "Packages/User/EOL-semicolon.sublime-macro"} }
]
// The macros should look like the following
// The file should be placed in `cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/User/EOL-semicolon.sublime-macro`
[
{
@paulfarino
paulfarino / first_ux.rb
Created February 12, 2016 06:14
First time user experience for using the Devise Gem
def after_sign_in_path_for(resource)
if resource.sign_in_count == 1
first_time_user_experience_path
else
your_apps_main_path
end
end
@paulfarino
paulfarino / whitespace-helper.scss
Last active February 24, 2016 20:12
Whitespace Helper
// Spacing Helpers
// --------------------------------------------------
// ex: mtxl = margin-top: 20px
//
$orientation_list: (
v,
h,
a
);
$direction_list: (
@paulfarino
paulfarino / user-offline.js
Created May 17, 2016 23:54
Displays message a message to a user who is offline
// Displays message a message to a user who is offline
// Example using Boostrap classes
// <div id="offline" class="alert alert-danger">You're offline</div>
if (navigator.onLine) {
document.getElementById('offline').style.display = "block";
} else {
console.log('User is online')
}
@paulfarino
paulfarino / Loading.swift
Last active May 31, 2016 19:48
Loading spinner to drop into your iOS projects (Swift)
// Display your spinner by calling Loading.start() and hide it with Loading.stop()
// Include asset 'spinner.png'
import UIKit
class Loading {
static let backgroundColor = UIColor(red: 46.0/255.0, green: 204.0/255.0, blue: 113.0/255.0, alpha: 0.44)
static let fade = 0.1
static var indicator: UIView = {
var view = UIView()
@paulfarino
paulfarino / localstorage_object.js
Last active September 14, 2016 23:34
Store a JS object in localstorage
// Local Storage workaround: Stringify your object before storing it, and later parse it when you retrieve it
// Create object
var testObject = { 'one': 1, 'two': 2, 'three': 3 };
// Put the object into storage
localStorage.setItem('testObject', JSON.stringify(testObject));
// Retrieve the object from storage
var retrievedObject = localStorage.getItem('testObject');
@paulfarino
paulfarino / sass-theme.scss
Created October 21, 2016 22:02
Sass Theming
// Variables
$black : #000000;
$white : #FFFFFF;
$alpha : #FF0000;
$themes: (
blue: (
alpha: blue,
beta: orange
),
@paulfarino
paulfarino / typography.scss
Created November 30, 2016 23:21
Typography SCSS
// Round number to 2 decimal places
@function decimal-round ($number, $digits: 0, $mode: round) {
$n: 1;
// $number must be a number
@if type-of($number) != number {
@warn '#{ $number } is not a number.';
@return $number;
}
// $digits must be a unitless number
@if type-of($digits) != number {