Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Ryan Collins RyanCCollins

🎯
Focusing
View GitHub Profile
@RyanCCollins
RyanCCollins / category_plugin.rb
Created Oct 21, 2015 — forked from somic/category_plugin.rb
How I organize posts in Jekyll (code snippets for blog post - see comments)
View category_plugin.rb
module Jekyll
Page.class_eval {
def clone
Page.new(@site, @base, @dir, @name)
end
}
@RyanCCollins
RyanCCollins / Gruntfile.js
Created Jan 16, 2016
How to start mongo with Grunt
View Gruntfile.js
shell: {
mongo: {
command: "sh startMongoIfNotRunning.sh",
options: {
async: true
}
},
}
View install-nvm.md

Install NVM to manage NodeJS versions

Download and Install

Download and run the install script using curl:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.1/install.sh | bash

or use wget:

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.30.1/install.sh | bash
View npm-install-without-sudo.md

NPM install without SUDO

It's easy! Just change permissions on the .npm directory as shown below.

Try this:

sudo chown -R $(whoami) ~/.npm

Or this:

View oneline-packer-install.sh
curl -O -L https://releases.hashicorp.com/packer/0.8.6/packer_0.8.6_darwin_amd64.zip
unzip packer_0.8.6_darwin_amd64.zip
sudo mv packer_0.8.6 /usr/local/packer
sudo chown $USER /usr/local/packer/
# then update your .bash_profile with the new path e.g.:
# export PATH="/usr/local/git/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/local/packer:$PATH"
View react-lifecycle-parent-child.jsx
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: "" };
View privacy_policy.markdown

Privacy Policy

Last revised on [DATE]

The Gist

[COMPANY] will collect certain non-personally identify information about you as you use our sites. We may use this data to better understand our users. We can also publish this data, but the data will be about a large group of users, not individuals.

We will also ask you to provide personal information, but you'll always be able to opt out. If you give us personal information, we won't do anything evil with it.

View curry
const say = (what) =>
(times) =>
[...Array(times||0)].map((v,i)=>i).forEach((_) => console.log(what))
say("What")(30)
@RyanCCollins
RyanCCollins / thunks-rock.js
Last active Aug 31, 2016
Forget Callback inversion of control, thunks are the way to go!
View thunks-rock.js
// Playing with Thunks
// See: http://jsbin.com/qebuluveje/edit?js,console
// Awesome!
const fakeAjax = (text, cb) =>
setTimeout(() => {
cb(text);
}, 5000);
function getFile(file) {
var text, fn;
@RyanCCollins
RyanCCollins / array-from-range.md
Created Sep 2, 2016
Create an array of 1 through n numbers in one line of JS
View array-from-range.md

Create an array of numbers 1 to N

const N = 20;
Array.apply(null, { length: N }).map(Number.call, Number)

Another option

const arrayOfRange = (n) => Array(n).join().split(',').map((_, i) => i);