Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Barba AndrewBarba

View GitHub Profile
View keybase.io
### Keybase proof
I hereby claim:
* I am andrewbarba on github.
* I am andrewbarba (https://keybase.io/andrewbarba) on keybase.
* I have a public key ASD4KNX7lQ2UhhPB8TK-gT2_39m_3VExU6gwTn1y7Rbbmgo
To claim this, I am signing this object:
@AndrewBarba
AndrewBarba / EpsonDeviceNameToSeries.swift
Created May 25, 2017
Convert Epson printer device name to series enum
View EpsonDeviceNameToSeries.swift
func printerSeries(for name: String) -> Int32 {
switch name.uppercased() {
case "TM-M10":
return EPOS2_TM_M10.rawValue
case "TM-M30":
return EPOS2_TM_M30.rawValue
case "TM-P20":
return EPOS2_TM_P20.rawValue
case "TM-P60":
return EPOS2_TM_P60.rawValue
@AndrewBarba
AndrewBarba / cs6740-space-boilerplate.js
Last active Feb 11, 2016
A boilerplate for the cs6740 space colonization problem written in Javascript. Abstracts away parsing and organizing the data so you can focus on the algorithm needed to solve the challenge.
View cs6740-space-boilerplate.js
'use strict';
/**
* Returns the cheapest way to colonize the given species
* The first argument is an Array of species, and the second argument
* is an array of discounts.
*
* A single species in the array, accesed like species[0], has 2 properties:
* - cost: Int - the cost to bring 1 of these species without a discount
* - needToBring: Int - the number of species I need to bring
View Dispatch.swift
//
// Dispatch.swift
//
// Created by Andrew Barba on 8/25/15.
//
import Foundation
public struct Dispatch {
@AndrewBarba
AndrewBarba / make-xcode-fast
Created Apr 14, 2015
Make Xcode (with Cocoapods) faster by cleaning Pods, workspaces, and derived data folders
View make-xcode-fast
xcode-fast:
rm -rf Pods
rm -rf *.lock
rm -rf *.xcworkspace
rm -rf ~/Library/Caches/com.apple.dt.Xcode/*
rm -rf ~/Library/Developer/Xcode/DerivedData/*
pod install
@AndrewBarba
AndrewBarba / UIColorMake
Last active Aug 29, 2015
Objective-C macro for easily creating UIColor instances with RGB values between 0 and 255
View UIColorMake
/**
* Example: UIColor *teal = UIColorMake(9.0, 171.0, 161.0, 1.0)
*/
CG_INLINE UIColor*
__UIColorMake(CGFloat r, CGFloat g, CGFloat b, CGFloat a)
{
return [UIColor colorWithRed:(r/255.0) green:(g/255.0) blue:(b/255.0) alpha:a];
}
#define UIColorMake __UIColorMake
View Formatted Phone Number String
/**
* @updated: 2014-07-29
* @source: http://stackoverflow.com/questions/6052966/phone-number-formatting
*/
-(NSString*)phoneNumberString
{
static NSCharacterSet* set = nil;
TL_DISPATCH_ONCE(^{
set = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
});
View jQuery TouchClick
/*** ANDREW BARBA ***/
/**** April 2013 ****/
/********************/
// A replacement for jQuery's .click() event that
// automatically supports taps on mobile devices
// and clicks on desktops
jQuery.fn.touchClick = function(fnc)
{
You can’t perform that action at this time.