Skip to content

Instantly share code, notes, and snippets.

View SimplGy's full-sized avatar

Eric Miller SimplGy

View GitHub Profile
@kristopherjohnson
kristopherjohnson / sumAndMean.swift
Last active September 21, 2019 13:29
Generic sum() and mean() extensions for Swift numeric collections
/// To use reduce() to sum a sequence, we need
///
/// - a zero (identity) element
/// - an addition operator
protocol Summable {
/// Identity element for this type and the + operation.
static var Zero: Self { get }
@trey
trey / getbundles.md
Created May 18, 2012 02:32
Installing GetBundles on a Fresh Copy of TextMate

Installing GetBundles on a Fresh Copy of TextMate

$ mkdir -p ~/Library/Application\ Support/TextMate/Bundles
$ cd !$
$ svn co http://svn.textmate.org/trunk/Review/Bundles/GetBundles.tmbundle/
$ osascript -e 'tell app "TextMate" to reload bundles'

Sources

@eeichinger
eeichinger / Immutable Data Types with Jackson and Lombok.md
Last active February 7, 2019 15:56
Example tests and notes for making Jackson work with Lombok

Examples for getting Jackson and Lombok to work together to create immutable data types.

Demonstrates use of:

  • Nullable Types
  • Optional
  • immutable java.util.List
  • immutable array
  • validating custom types on instantiate/unmarshalling
  • use & customize Lombok-@Builder with Jackson
//
// Demonstration of using a channel to receive and dispatch IOHIDManager events using the ChannelZ framework.
//
// Created by Marc Prud'hommeaux on 3/8/15.
//
import Cocoa
import IOKit
import ChannelZ
@NSApplicationMain
@barneycarroll
barneycarroll / detectCSS.js
Created July 21, 2011 08:23
Simple function to determine whether a given CSS property is supported or not. Useful for conditional execution of JS animations, rounded corners, etc.
// Is the passed CSS property supported?
// eg. detectCSS('transition')
function detectCSS(prop){
var
prop = prop.replace(/-(\w)/g,function(s,g){return g.toUpperCase()}),
pre = ',Icab,Khtml,Moz,Ms,O,Webkit'.split(',');
for (var i = 0; i < pre.length; ++i){
if(i==1)
prop = prop.slice(0,1).toUpperCase() + prop.slice(1);
@justindujardin
justindujardin / complexRequireDirective.js
Last active May 26, 2018 16:16
AngularJS Directive require ancestor AND this controller
var app = angular.module('yourApp');
app.directive("parentDirective", function(){
return {
restrict: "A",
controller:function(){
this.test = function(){
console.log("parentController - okay");
}
}
};
anonymous
anonymous / angular-SignalTowerService.markdown
Created March 5, 2015 20:05
angular SignalTowerService

angular SignalTowerService

Adds the js-signals implementation to AngularJS. There is no good way for AngularJS services to send or receive events. The 'angular way' for events to be sent uses $rootScope, but angular services should never know about any scope. Enter SignalTowerService and it's publish/subscribe model of Signals ala js-signals

A Pen by Keldon Rush on CodePen.

License.

/*
ericasadun.com
Sometimes letting go doesn't mean saying goodbye
*/
prefix operator ++
prefix operator --
postfix operator ++
@kristopherjohnson
kristopherjohnson / contentsOfDirectoryAtPath.swift
Last active November 15, 2017 18:11
Using NSFileManager contentsOfDirectoryAtPath in Swift, with tuple result and CPS interfaces
import Foundation
// Tuple result
// Get contents of directory at specified path, returning (filenames, nil) or (nil, error)
func contentsOfDirectoryAtPath(path: String) -> (filenames: String[]?, error: NSError?) {
var error: NSError? = nil
let fileManager = NSFileManager.defaultManager()
let contents = fileManager.contentsOfDirectoryAtPath(path, error: &error)
@christophercliff
christophercliff / Makefile
Created December 14, 2012 00:19
Makefile for deploying a Wintersmith static site to Github Pages without exposing the source (assumes you're using the default build directory).
deploy:
rm -rf ./build
wintersmith build
cd ./build && \
git init . && \
git add . && \
git commit -m "Deploy"; \
git push "git@github.com:{YOUR NAME}/{YOUR REPO}.git" master:gh-pages --force && \
rm -rf .git