Skip to content

Instantly share code, notes, and snippets.

import React from "react";
import { render } from "react-dom";
const ParentComponent = React.createClass({
getDefaultProps: function() {
console.log("ParentComponent - getDefaultProps");
},
getInitialState: function() {
console.log("ParentComponent - getInitialState");
return { text: "" };
@truetone
truetone / handy_cli.md
Last active November 7, 2017 14:39
Handy cli stuff

Handy cli stuff

Generate password (install pwgen first)

pwgen -Cs 20 1 | tr -d ' ' | tr -d '\n' | pbcopy

Moving around

Erase word

@truetone
truetone / handy.js
Created May 22, 2015 13:13
Handy JavaScript Functions
/**
* JavaScript's typeof method returns "object" for arrays and null values. This fixes that.
* http://javascript.crockford.com/remedial.html
*/
function typeOf(value) {
var s = typeof value;
if (s === 'object') {
if (value) {
if (value instanceof Array) {
s = 'array';
@truetone
truetone / python_snippets.py
Created September 29, 2014 18:37
Handy Python Console Snippets
# This works in the Flask debugging console as well.
# Very handy for pretty output of Python dictionaries
# Source: http://stackoverflow.com/questions/3733554/howto-format-dict-string-outputs-nicely
import json
x = {'planet' : {'has': {'plants': 'yes', 'animals': 'yes', 'cryptonite': 'no'}, 'name': 'Earth'}}
print json.dumps(x, indent=2)
"""
Output:
@truetone
truetone / server-admin.sh
Created September 15, 2014 14:43
Handy Linux (Ubuntu) Commands
# Show security updates only:
apt-get -s dist-upgrade |grep "^Inst" |grep -i securi
# Show all upgradeable packages
apt-get -s dist-upgrade | grep "^Inst"
# Install security updates only
@truetone
truetone / slug.js
Last active August 29, 2015 14:06 — forked from bentruyman/slug.js
JavaScript slug generator
// Generates a URL-friendly "slug" from a provided string.
// For example: "This Is Great!!!" transforms into "this-is-great"
function generateSlug (value) {
// 1) convert to lowercase
// 2) replace anything that's not an alphanumeric character or dash with a dash
// 3) replace instances of more than one dash with a single dash
// 4) remove leading and trailing dashes
return value.toLowerCase().replace(/[^a-z0-9-]/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '');
};
@truetone
truetone / _handy-console-methods.md
Last active August 29, 2015 14:04
Handy JavaScript console Methods

Handy console methods

log

Prints to the console:

console.log('Hello World!')

String Interpolation

@truetone
truetone / git-tips.md
Last active March 22, 2018 17:07
Semi-frequent git commands that I have to look up every time

Git Tips

Push New Remote Branch

git push -u origin feature_branch_name

Checkout Remote Branch

git fetch

git checkout test

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
" inner word
iw
" around word
aw
" a sentence
as
" inner sentence