Skip to content

Instantly share code, notes, and snippets.

View nuclearghost's full-sized avatar
🚀
Lost in Space

Mark Meyer nuclearghost

🚀
Lost in Space
  • TravelJoy
  • Chicago, IL
View GitHub Profile
@nuclearghost
nuclearghost / numWatches.js
Last active December 30, 2015 00:39
This gist contains an IIFE for finding the number of watches currently found on a page when using Angular.js. It's taken from Words Like Jareds answer on Stack Overflow http://stackoverflow.com/questions/18499909/how-to-count-total-number-of-watches-on-a-page
(function () {
var root = $(document.getElementsByTagName('body'));
var watchers = [];
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
angular.forEach(element.data().$scope.$$watchers, function (watcher) {
watchers.push(watcher);
});
}
@nuclearghost
nuclearghost / StretchToMargin.css
Created January 23, 2014 20:08
CSS to stretch to margin
.stretch-to-margin {
display:block;
position:absolute;
height:auto;
top:0;
bottom:0;
left:0;
right:0;
}
@nuclearghost
nuclearghost / depth.css
Created May 28, 2014 13:08
CSS Trick for seeing node Depth
* { background-color: rgba(255,0,0,.2); }
* * { background-color: rgba(0,255,0,.2); }
* * * { background-color: rgba(0,0,255,.2); }
* * * * { background-color: rgba(255,0,255,.2); }
* * * * * { background-color: rgba(0,255,255,.2); }
* * * * * * { background-color: rgba(255,255,0,.2); }
@nuclearghost
nuclearghost / CustomLog.m
Last active August 29, 2015 14:05
Objective C Custom Log Macros
#ifdef DEBUG
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
# define DLog(...)
#endif
// ALog always displays output regardless of the DEBUG setting
#define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
@nuclearghost
nuclearghost / UIColorFromRGB
Last active August 29, 2015 14:06
Create a UIColor from a Hex Value
func UIColorFromRGB(rgbValue: UInt) -> UIColor {
return UIColor(
red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
alpha: CGFloat(1.0)
)
}
//Call with UIColorFromRGB(0x209624)
@nuclearghost
nuclearghost / gist:ff33136e5bc883c8abbf
Created December 7, 2014 21:53
iOS Fonts available
for (NSString* family in [UIFont familyNames])
{
NSLog(@"%@", family);
for (NSString* name in [UIFont fontNamesForFamilyName: family])
{
NSLog(@" %@", name);
}
}
@nuclearghost
nuclearghost / index.md
Last active August 29, 2015 14:23
Swift Learning Resources

#Swift Resources

This is a set of open source resources that are useful for learning about app development in swift

Applicaions

  1. Todo Swift A simple Todo app written in swift. Shows how to enter text and some basic interactions with a UITableView
  2. Swift RSS Sample This is a simple app that injests a hardcoded RSS feed and displays the data in UITableView. This uses cocoapods which is the most widely used dependency maanger for developing iOS apps.
  3. Swift NYT Reader
@nuclearghost
nuclearghost / gif_gen.sh
Created September 15, 2015 19:48
Create a gif from a mp4 using ffmpeg
#!/bin/bash
input_video=$1
starting_second=$2
lenght_in_seconds=$3
output_file=$4
palette="/tmp/palette.png"
filters="fps=15,scale=320:-1:flags=lanczos"
@nuclearghost
nuclearghost / addDone.swift
Created December 23, 2015 02:13
Add done button to Numeric Keypad
@IBOutlet weak var numberTextField: UITextField!
@IBOutlet weak var numberTextField2: UITextField!
//Assumes that the tag's of the views are sequential
override func viewDidLoad() {
numberTextField.tag = 1
numberTextField.tag = 2
addDoneButtonTo(numberTextField)
addDoneButtonTo(numberTextField2)
}
@nuclearghost
nuclearghost / detector.js
Created March 2, 2016 18:40
Mobile UA Detector
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i)
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i)
},
iOS: function() {
return navigator.userAgent.match(/iPad|iPod|iPhone/i)
},