Skip to content

Instantly share code, notes, and snippets.

View tribou's full-sized avatar

Aaron Tribou tribou

View GitHub Profile
@tribou
tribou / sizes.sh
Created February 21, 2016 15:33
List file and folder sizes in current directory with bash
#!/bin/bash
# Example usage: sizes path/to/somewhere/
sizes ()
{
ls -lrt -d -1 ${PWD}/${1}* | xargs du -sh
}
@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 / ssh_config
Last active January 17, 2016 02:23
ssh_config hardening
# Insert these at the beginning of an existing ssh_config file
# Github needs diffie-hellman-group-exchange-sha1 some of the time but not always.
Host github.com
KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1
Host *
KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
HostKeyAlgorithms ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,ssh-rsa
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
@tribou
tribou / .eslintrc
Last active December 25, 2015 16:28
Example showing how to override rules in .eslintrc
{
"extends": "airbnb",
"rules": {
"no-multiple-empty-lines": [2, {"max": 2, "maxEOF": 2}]
}
}
@tribou
tribou / .babelrc
Created December 25, 2015 16:06
Example .babelrc file for use with ES6, React, and Flux
{
"presets": [
"es2015",
"react"
]
}
@tribou
tribou / search.sh
Created November 9, 2015 01:27
Bash script to locate all occurrences of a string recursively within a directory with file and directory exclusions
#!/bin/bash -l
# Recursively greps files for pattern match
search() {
usage='Usage: search PATTERN [directory]'
search_dir='.'
# Return usage if 0 or more than 2 args are passed
@tribou
tribou / replace.sh
Last active July 26, 2016 10:32
Bash script to find and replace a string recursively with file and directory exclusions
#!/bin/bash -l
# Recursively performs a perl replace on files in current or specified directory
# ...took me all afternoon to get it right.
# Examples:
# replace 's/stringtofind/stringtoreplacewith/g'
# replace 's/foo/bar/g' path/to/dir
replace() {
@tribou
tribou / EditTodo.jsx
Created October 15, 2015 01:10
A batteries-included React component implemented in ES6
import React from 'react';
import { saveItem } from '../actions/TodoActions.js';
export default class EditTodo extends React.Component {
constructor(props) {
super(props);
this._onChange = this._onChange.bind(this);
this._save = this._save.bind(this);
this._catchEnter = this._catchEnter.bind(this);
@tribou
tribou / AppDispatcher.js
Created October 15, 2015 01:07
A sample Flux dispatcher implemented in an ES6 class
// Todo app dispatcher with actions responding to both
// view and server actions
import { Dispatcher } from 'flux';
class DispatcherClass extends Dispatcher {
handleViewAction(action) {
this.dispatch({
source: 'VIEW_ACTION',
action: action,
@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';