Skip to content

Instantly share code, notes, and snippets.

View arosenb2's full-sized avatar

Aaron arosenb2

View GitHub Profile
@arosenb2
arosenb2 / Weather.ex
Last active July 7, 2020 03:53
OpenWeatherMap API Basic Integration using Elixir
defmodule Weather do
@moduledoc """
deps: [
{:poison, "~> 4.0"},
{:httpoison, "~> 1.7"}
]
"""
@api_key "" # obtain for free at https://openweathermap.org/api
@base_url "https://api.openweathermap.org/data/2.5"
@arosenb2
arosenb2 / ContentView.swift
Created October 15, 2019 21:38
SwiftUI Demo
import SwiftUI
struct ContentView: View {
var content: [Offer]
var body: some View {
List(content, rowContent: OfferRow.init)
}
}
struct ContentView_Previews: PreviewProvider {
@arosenb2
arosenb2 / UserReducer.js
Last active February 13, 2019 15:15
O(1) Reducer
const actionTypes = {
USER_LOGIN_SUBMIT: 'USER_LOGIN_SUBMIT',
USER_LOGIN_SUCCESS: 'USER_LOGIN_SUCCESS',
USER_LOGIN_FAILURE: 'USER_LOGIN_FAILURE'
};
const createInitialState = (initialState = {}) => ({
id: null,
email: null,
isLoading: false,

Keybase proof

I hereby claim:

  • I am arosenb2 on github.
  • I am arosenb2 (https://keybase.io/arosenb2) on keybase.
  • I have a public key ASBx3jWXMlQdGq_9ZLI7tao996S-gdZWnEeQuhbbp4Fhdgo

To claim this, I am signing this object:

@arosenb2
arosenb2 / todoItem.js
Created December 20, 2017 15:08
Annotated TodoItem component
import React from 'react';
import PropTypes from 'prop-types';
import './todoItem.css';
// Export named class individually for better unit test integration
export class TodoItem extends React.Component {
// No need for a constructor because all it was doing was calling super, so it wasn't actually overriding the parent constructor
// Assign to an arrow function - see https://cdb.reacttraining.com/react-inline-functions-and-performance-bdff784f5578
removeToDo = () => {
@arosenb2
arosenb2 / SubscriptVsFirst.groovy
Created June 6, 2016 17:41
Proving [0] is actually safer than .first() on lists
def list = [].toList()
println "List: $list" // []
println "[0]: ${list[0]}" // Null
println ".first(): ${list.first()}" // Throws
@arosenb2
arosenb2 / OrPlus.groovy
Last active May 24, 2016 15:20
Test for Null or Boolean Map Attribute
def foo = null
def bar = [active: false]
def foobar = [active: true]
println "Long hand version"
println "--------"
println "Foo: ${! foo || ! foo.active}"
println "Bar: ${! bar || ! bar.active}"
println "Foobar: ${! foobar || ! foobar.active}"
@arosenb2
arosenb2 / CriticalBookmarklet.js
Last active August 29, 2015 14:05
Front End Optimization
javascript:!function(){!function(){var e=function(e,t,n){var r=n||{},o={},i=function(e){!!o[e.selectorText]==!1%26%26(o[e.selectorText]={});for(var t=e.style.cssText.split(/;(%3F![A-Za-z0-9])/),n=0;n<t.length;n++)if(!!t[n]!=!1){var r=t[n].split(": ");r[0]=r[0].trim(),r[1]=r[1].trim(),o[e.selectorText][r[0]]=r[1]}},a=function(){for(var n=e.innerHeight,o=t.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,function(){return NodeFilter.FILTER_ACCEPT},!0);o.nextNode();){var a=o.currentNode,c=a.getBoundingClientRect();if(c.top<n||r.scanFullPage){var l=e.getMatchedCSSRules(a);if(l)for(var f=0;f<l.length;f++)i(l[f])}}};this.generateCSS=function(){var e="";for(var t in o){e+=t+" { ";for(var n in o[t])e+=n+": "+o[t][n]+"; ";e+="}\n"}return e},a()},t=new e(window,document),n=t.generateCSS();console.log(n)}()}();
@arosenb2
arosenb2 / BasicChildBrowser.swift
Last active September 9, 2017 20:50
A child web browser without navigation features in iOS using WKWebView in Swift
import Foundation
import UIKit
import Webkit
class BasicChildBrowser:UIViewController, WKNavigationDelegate {
let web = WKWebView()
let toolbar = UIToolbar()
let progressSpinner = UIActivityIndicatorView(activityIndicatorStyle: .White)
let progressBar = UIProgressView(progressViewStyle: .Bar)