Skip to content

Instantly share code, notes, and snippets.

View nickoneill's full-sized avatar
🌯
eating a burrito

Nick O'Neill nickoneill

🌯
eating a burrito
View GitHub Profile
@nickoneill
nickoneill / Location.tsx
Created November 24, 2020 17:45
Lightweight Redux alternative, context through HOCs
// first, start with the usage in a react component, very simple and you just get access to state in stateProvider below,
// HOC injects our location-relation props from our state provider
import { WithLocationProps } from "../state/locationState";
import { withLocation } from "../state/stateProvider";
interface Props {}
class Location extends React.Component<Props & WithLocationProps> {
render() {
0x57e9088cCAe9Ba689c8EDAE30b8925d1E121A0C7
@nickoneill
nickoneill / ZebraPrinter.swift
Created July 17, 2016 17:53
Too many enums?
/**
`ZebraPrinterStatus` is a list of status responses we handle from the printer or during a connection attempt with the printer.
*/
enum ZebraPrinterStatus {
case Ready
case NotReady([ZebraPrinterError])
case Unknown
func message() -> String {
switch self {
@nickoneill
nickoneill / TableState.swift
Last active March 30, 2023 22:03
Easily add async state tracking to your UITableView data sources
protocol TableValuable {
associatedtype TableItem
static func loadingValue() -> TableItem
static func failedValue() -> TableItem
func value() -> TableItem
}
enum TableState<T: TableValuable> {
case Loading
case Failed
var autopersist: String? {
set {
if let newValue = newValue {
Pantry.pack(newValue, key: "autopersist")
}
}
get {
return Pantry.unpack("autopersist")
}
}
@nickoneill
nickoneill / Usage
Last active May 19, 2016 00:40
Post to Slack from Parse Cloud Code
var Slack = require('cloud/slack.js');
var slack = new Slack('https://hooks.slack.com/services/INCOMING_SLACK_WEBHOOK_URL');
return slack.send({text: msg}).then(function(){
// success
}, function(error){
// error
});

Keybase proof

I hereby claim:

  • I am nickoneill on github.
  • I am nickoneill (https://keybase.io/nickoneill) on keybase.
  • I have a public key whose fingerprint is 1461 8A87 015A 2A12 91FF 1BBF 6F16 159E 7BA1 11F2

To claim this, I am signing this object:

@nickoneill
nickoneill / index.html
Created June 15, 2013 23:39
slightly saner boilerplate from html5 boilerplate
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
@nickoneill
nickoneill / gist:5206442
Created March 20, 2013 17:09
Export a video path as mp4 and use the document interaction controller to send it
AVAsset *asset = [AVAsset assetWithURL:self.videoPaths[0]];
AVAssetExportSession *export = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetPassthrough];
[export setOutputURL:temp];
[export setOutputFileType:AVFileTypeMPEG4];
NSLog(@"export started");
[export exportAsynchronouslyWithCompletionHandler:^{
NSLog(@"export done: %d",[export status]);
UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL:temp];
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
Non-NIB-Code & other changes: Max Horn <max@quendi.de>
Feel free to customize this file to suit your needs
*/
#ifndef _SDLMain_h_
#define _SDLMain_h_