Skip to content

Instantly share code, notes, and snippets.

View tribou's full-sized avatar

Aaron Tribou tribou

View GitHub Profile
@tribou
tribou / .babelrc
Created December 25, 2015 16:06
Example .babelrc file for use with ES6, React, and Flux
{
"presets": [
"es2015",
"react"
]
}
@tribou
tribou / nvm_auto_switching.sh
Last active January 9, 2020 02:40
Use PROMPT_COMMAND and nvm to auto-switch versions of node
#!/bin/bash
# Activate a version of Node that is read from a text file via NVM
function use_node_version()
{
local TEXT_FILE_NAME="$1"
local CURRENT_VERSION=$([ -n "$HAS_NVM" ] && nvm current)
local PROJECT_VERSION=$([ -n "$HAS_NVM" ] && nvm version $(cat "$TEXT_FILE_NAME"))
# If the project file version is different than the current version
@tribou
tribou / init.coffee
Created September 17, 2017 22:02
Customize Atom tab titles to display folder and file name
# Add folder and filename to tab title
atom.workspace.observeTextEditors (editor) ->
if editor.getTitle() isnt "untitled"
sp = editor.getPath().split('/')
title = sp.slice(sp.length-2).join('/')
editor.getTitle = -> title
editor.getLongTitle = -> title
editor.emitter.emit "did-change-title", editor.getTitle()
atom.workspace.onDidOpen (event) ->
@tribou
tribou / sshd_config
Last active February 26, 2019 18:55
sshd_config hardening
# Insert these at the beginning of an existing sshd_config file
KexAlgorithms curve25519-sha256@libssh.org
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-ripemd160-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,umac-128@openssh.com
Protocol 2
HostKey /etc/ssh/ssh_host_ed25519_key
HostKey /etc/ssh/ssh_host_rsa_key
PasswordAuthentication no
ChallengeResponseAuthentication no
@tribou
tribou / Header.jsx
Last active February 15, 2019 21:48
Example React component that changes classes on scroll and supports passive event listeners where available
import React, { Component } from 'react'
import css from './Header.css'
class Header extends Component {
componentDidMount () {
this._bindScroll()
@tribou
tribou / TodoStore.js
Last active September 12, 2018 16:12
A sample Flux store in ES6
// Todo store
//
// Requiring the Dispatcher, Constants, and
// event emitter dependencies
import AppDispatcher from '../dispatcher/AppDispatcher';
import { TodoConstants } from '../constants/TodoConstants';
import { EventEmitter } from 'events';
const CHANGE_EVENT = 'change';
@tribou
tribou / Home.android.js
Created June 11, 2018 20:50
Android vs iOS image sharing on React Native
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { PureComponent } from 'react'
import {
Button,
Image,
gcloud container clusters create cluster-1 \
--num-nodes 1 \
--disk-size 10 \
--machine-type f1-micro \
--no-enable-cloud-logging \
--no-enable-cloud-monitoring
# When it's done, your kubectl command should work
kubectl cluster-info
@tribou
tribou / MainApplication.java
Created March 23, 2018 11:38
Example react-native MainApplication class that implements getFileProviderAuthority
package com.example.myapp;
import android.app.Application;
import com.facebook.react.ReactApplication;
import cl.json.RNSharePackage;
import cl.json.ShareApplication;
import com.facebook.react.ReactNativeHost;
# On OSX, install brew for all the things
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install Brew Caskroom
brew install caskroom/cask/brew-cask
# Install Google Cloud SDK
brew cask install google-cloud-sdk
# After installing, follow the printed instructions to add the paths