Skip to content

Instantly share code, notes, and snippets.

:shipit:
f*ck it, ship it

Sam Gammon sgammon

:shipit:
f*ck it, ship it
Block or report user

Report or block sgammon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sgammon
sgammon / transaction.kt
Created Sep 1, 2019
Firebase transaction sample in Kotlin
View transaction.kt
val dbReference: DatabaseReference = firebase.ref("some/db/path")
dbReference.runTransaction(object: Transaction.Handler {
/**
* This method will be called once, at completion, with the results of the transaction.
*
* @param error null if no errors occurred, otherwise it contains a description of the error
* @param committed True if the transaction successfully completed, false if it was aborted or
* an error occurred
View motd
                                                                       
                                                                         
                                                                            
                                                                              
                                         [48;5;237
@sgammon
sgammon / singleton.swift
Created May 26, 2019
Swift singleton pattern sample
View singleton.swift
class Something {
/// Counter. We keep this around to prove we aren't getting new copies of `Something` - just the same one, over and
/// over again.
var _counter: Int = 0
/// Cached instance. We put the one copy we make of `Something` here, so we can keep it around, and hand it back if
/// anyone else asks for it. It's important that this is private, too.
private static var _singleton: Something? = nil
@sgammon
sgammon / WifiLogic.swift
Created Jan 23, 2019
Hotspot configuration
View WifiLogic.swift
///
///
private func generateHotspotConfiguration() throws -> NEHotspotConfiguration {
let eap = NEHotspotEAPSettings()
eap.supportedEAPTypes = [21] /* TTLS (`21`) */
eap.ttlsInnerAuthenticationType = .eapttlsInnerAuthenticationMSCHAPv2
eap.isTLSClientCertificateRequired = true
eap.outerIdentity = "customer@vip.chalice.farm"
eap.password = "4zJmhhjj"
eap.preferredTLSVersion = ._1_0
View swagger-v1.json
{
"consumes": [
"application/json",
"application/x-www-form-urlencoded"
],
"produces": [
"application/json"
],
"schemes": [
"http",
View keybase.md

Keybase proof

I hereby claim:

  • I am sgammon on github.
  • I am samgammon (https://keybase.io/samgammon) on keybase.
  • I have a public key ASBD6RNSQSEvFd_ODPPS9UZSYN6k-trfUU8Nhi4epWEsOAo

To claim this, I am signing this object:

@sgammon
sgammon / lambdas.py
Last active Dec 22, 2015
lambdas for dayssssssssssss
View lambdas.py
# -*- coding: utf-8 -*-
# stdlib
import time
import datetime
# `_TO_TIMESTAMP`: converts a python datetime into a integer timestamp
_TO_TIMESTAMP = lambda dt: int(time.mktime(dt.timetuple()))
@sgammon
sgammon / filterKeenData.js
Last active Dec 22, 2015
JavaScript snippet to sanitize odd characters from keys, and build hierarchy where nested keys exist ("dot.paths.like.this"). Version 3 :).
View filterKeenData.js
// `filterKeenData`: removes invalid property keys and expands nested keys
var filterKeenData = (function () {
'use strict';
var _stop_list = [/\./g], // stop list dictates where we nest, strip list is char regexes to remove
_strip_list = [/\./g, /\|/g, /\\/g, /\&/g, /\?/g, /\:/g, /\;/g, /\~/g, /\!/g, /@/g, /#/g, /\//g, /'/g],
// `_filter_string`: filter a string of invalid characters
_filter_string = function (original) {
var strip_i, strip_c, _sanitized = original;
if (typeof original === 'string') {
@sgammon
sgammon / person.py
Created Jul 30, 2013
This sample demos the apptools model layer, which provides an expressive syntax for data modeling and a framework of adapters to allow engine agnostic storage.
View person.py
# -*- coding: utf-8 -*-
'''
models: sample
:author: Sam Gammon (sam@momentum.io)
:copyright: (c) 2013 momentum labs.
:license: This is private source code - all rights are reserved. For details about
embedded licenses and other legalese, see `LICENSE.md`.
'''
@sgammon
sgammon / sample.py
Created Jul 30, 2013
Self-contained example of a full apptools RPC service. Includes a `model.Model`-based RPC message class and service exception. This is literally all the code you need to write in apptools to deploy a service - once this file is autoloaded at construction time, the service appears in apptools JS at `$.apptools.api.sample.echo()`.
View sample.py
# -*- coding: utf-8 -*-
'''
api sample: service
:author: Sam Gammon (sam@momentum.io)
:copyright: (c) 2013 momentum labs.
:license: This is private source code - all rights are reserved. For details about
embedded licenses and other legalese, see `LICENSE.md`.
'''
You can’t perform that action at this time.