Skip to content

Instantly share code, notes, and snippets.

View andrewmcnamara's full-sized avatar

Andrew McNamara andrewmcnamara

  • Sydney, Australia
View GitHub Profile
(defn is_anagram?
[word anagram]
(and (= (.length anagram) (.length word)) (empty? (clojure.set/difference (set word) (set anagram)))))
(filter (partial is_anagram? "yellow") ["yellow" "lowyelq"])
@andrewmcnamara
andrewmcnamara / 0_reuse_code.js
Created June 13, 2014 00:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@andrewmcnamara
andrewmcnamara / strong-parameters.rb
Last active November 1, 2016 00:53
Strong parameters and nested attributes
#Set this in development and test rails config to allow any missing parameters to raise an error
config.action_controller.action_on_unpermitted_parameters = :raise
# Given the following structure
# Parameters: {"utf8"=>"✓", "parent_param"=>{"param1"=>"test","some_ids"=>["3", "4", ""], "some_hash"=>{"key1" => "value2"}}}
#This means that the whitelisting hack will no longer work
params.require(:parent_param).permit(:param1,{some_ids:[]})do |whitelisted|
whitelisted[:some_hash] = params[:parent_param][:some_hash]
end
@andrewmcnamara
andrewmcnamara / react-native-notes.md
Created May 31, 2016 21:48
Things I learned the hard way using React Native

Things I learned the hard way using React Native

Set up your environment carefully: It's important to have one canonical source of truth per environment, per platform. (i.e. iOS Development, iOS Testflight, iOS Production, ditto Android.) Every time you build, your config should propagate values from one input source (per platform) to either Java/JavaScript or Objective-C/JavaScript. Here's what we did for Android and here's what we did for iOS. I don't doubt that you can do better. Please do better. But you can't say that we didn't have one canonical source of truth that worked very simply and effectively throughout the development process.

Don't wait until the end to develop Android and iOS concurrently: Even if you're not actively focusing on both platforms, don't assume that "RN is cross platform… we can develop iOS and flip the Android switch when we'r

<!DOCTYPE HTML>
<body>
<div id="app" />
<script src="https://fb.me/react-15.1.0.js"></script>
<script src="https://fb.me/react-dom-15.1.0.js"></script>
<script src="https://npmcdn.com/mobx@2.2.2/lib/mobx.umd.js"></script>
<script src="https://npmcdn.com/mobx-react@3.3.0/index.js"></script>
<script src="https://npmcdn.com/mobx-react-devtools@4.2/index.js"></script>
<script id="jsbin-javascript">
"use strict";
@andrewmcnamara
andrewmcnamara / index.html
Created June 6, 2016 04:22
Run React/Redux with in browser transform
<!DOCTYPE html>
<html>
<head>
<title>React Example</title>
<meta name="description" content="A React example made with HyperDev">
<link id="favicon" rel="icon" href="https://hyperweb.space/favicon.ico" type="image/x-icon">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/style.css">
@andrewmcnamara
andrewmcnamara / index.html
Created June 6, 2016 04:22
Run React/Redux with in browser transform
<!DOCTYPE html>
<html>
<head>
<title>React Example</title>
<meta name="description" content="A React example made with HyperDev">
<link id="favicon" rel="icon" href="https://hyperweb.space/favicon.ico" type="image/x-icon">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/style.css">
@andrewmcnamara
andrewmcnamara / index.html
Last active June 6, 2016 04:22
Run React/Redux with in browser transform. Based on http://codetheory.in/babel-6-and-above-in-browser/
<!DOCTYPE html>
<html>
<head>
<title>React Example</title>
<meta name="description" content="A React example made with HyperDev">
<link id="favicon" rel="icon" href="https://hyperweb.space/favicon.ico" type="image/x-icon">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/style.css">
@andrewmcnamara
andrewmcnamara / Fastfile
Created June 20, 2016 20:38 — forked from kennydee/Fastfile
Fastfile for staging environment with Appetize.io on React Native (iOs & Android), with statuses update on Github Enterprise
require 'httparty'
fastlane_version "1.95.0"
default_platform :ios
before_all do
# put here your token and iOs scheme app
ENV["GITHUB_TOKEN"] = "---"
ENV["APPETIZE_TOKEN"] = "---"
ENV["APP_IOS_SCHEME"] = "---"
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
.box {
border: 1px solid black;
width: 5px;