Skip to content

Instantly share code, notes, and snippets.

View wess's full-sized avatar
💭
When am I not writing code?

Wess Cope wess

💭
When am I not writing code?
View GitHub Profile
// This script has been updated from Sam Soffes'
// original version located at
// https://gist.github.com/soffes/dda0f842d1aa0547293e
import Foundation
import UIKit
struct Mixpanel {
// MARK: - Types
@wess
wess / Alter.swift
Created July 17, 2015 18:49
Alter - JSON Decoding/Modeling lib for Swift 2.0
//
// Alter.swift
// Alter
//
// Created by Wesley Cope on 7/16/15.
// Copyright © 2015 Wess Cope. All rights reserved.
//
/* USAGE:
@wess
wess / Byway.swift
Created July 22, 2015 19:57
Byway
//
// Byway.swift
// Byway
//
// Created by Wesley Cope on 7/16/15.
// Copyright © 2015 Wess Cope. All rights reserved.
//
/* USAGE:
@brainix
brainix / install_do_postgres.sh
Last active January 3, 2016 13:19
Install the do_postgres gem with Postgres.app
gem install do_postgres -- \
--with-pgsql-server-dir=/Applications/Postgres.app/Contents/Versions/9.3 \
--with-pgsql-server-include=/Applications/Postgres.app/Contents/Versions/9.3/include/postgresql/server
import Foundation
import Vapor
import Console
import PathKit
final class SassCommand: Command {
public let id = "sass"
public let help = ["This command compiles all scss files to css"]
public let console: ConsoleProtocol
@jordiboehme
jordiboehme / gist:3168819
Created July 24, 2012 08:25
iOS Pixel-to-Points conversion
+(CGFloat)pixelToPoints:(CGFloat)px {
CGFloat pointsPerInch = 72.0; // see: http://en.wikipedia.org/wiki/Point%5Fsize#Current%5FDTP%5Fpoint%5Fsystem
CGFloat scale = 1; // We dont't use [[UIScreen mainScreen] scale] as we don't want the native pixel, we want pixels for UIFont - it does the retina scaling for us
float pixelPerInch; // aka dpi
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
pixelPerInch = 132 * scale;
} else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
pixelPerInch = 163 * scale;
} else {
pixelPerInch = 160 * scale;
@senning
senning / US Zip Codes from 2016 Government Data
Last active May 11, 2020 20:43 — forked from erichurst/US Zip Codes from 2013 Government Data
All US zip codes with their corresponding latitude and longitude coordinates.Comma delimited for your database goodness.Source: http://www.census.gov/geo/maps-data/data/gazetteer.html
This file has been truncated, but you can view the full file.
ZIP,LAT,LNG
00601,18.180555, -66.749961
00602,18.361945, -67.175597
00603,18.455183, -67.119887
00606,18.158345, -66.932911
00610,18.295366, -67.125135
00612,18.402253, -66.711397
00616,18.420412, -66.671979
00617,18.445147, -66.559696
00622,17.991245, -67.153993
@zumbojo
zumbojo / bijective.rb
Created July 9, 2011 22:09
Simple bijective function (base(n) encode/decode)
# Simple bijective function
# Basically encodes any integer into a base(n) string,
# where n is ALPHABET.length.
# Based on pseudocode from http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener/742047#742047
ALPHABET =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split(//)
# make your own alphabet using:
# (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle.join
; CR-1 Custom Start G-code
M140 S{material_bed_temperature_layer_0} ; Set Heat Bed temperature
M190 S{material_bed_temperature_layer_0} ; Wait for Heat Bed temperature
M104 S160; start warming extruder to 160
G28 ; Home all axes
G29 ; Auto bed-level (BL-Touch)
G92 E0 ; Reset Extruder
M104 S{material_print_temperature_layer_0} ; Set Extruder temperature
G1 X0.1 Y20 Z0.3 F5000.0 ; Move to start position
M109 S{material_print_temperature_layer_0} ; Wait for Extruder temperature
@wess
wess / websocket_server.sh
Created November 10, 2021 20:47
Websocket Server in Bash [poc]
#!/usr/bin/env bash
IN_PIPE=$1;
_hex() {
typeset num=`echo 'obase=16; ibase=10; '"$1" | bc`
if ((${#num} == 1)); then
num=0"$num"
fi