Skip to content

Instantly share code, notes, and snippets.

View ryanseys's full-sized avatar
🌴

Ryan Seys ryanseys

🌴
View GitHub Profile
@ryanseys
ryanseys / format.js
Created September 16, 2014 23:59
util.format
/**
* Format a string with values from the provided object.
*
* @param {string} template - String with {} denoted keys. (See example)
* @param {object} args - Key/value pairs matching the holes in the template.
* @return {string}
*
* @example
* format('This is a {language} ({abbr}) codebase.', {
* language: 'JavaScript',
@ryanseys
ryanseys / hello.js
Last active August 29, 2015 14:06
Simple JavaScript module
function hello() {
console.log('hello from a github gist');
}
module.exports = hello;
@ryanseys
ryanseys / ramanujan.js
Created July 6, 2014 22:28
Finding Ramanujan numbers
/**
* Find all possible sum of cubes for a particular number
* @param {Number} Number to find all sum of cube pairs
* @return {Array} Array of sum of cubes
*/
function findAllPossiblePairs(n) {
var doneFinding = false;
var i = 1;
var found = [];
var j = Math.floor(Math.pow(n, 1/3));
@ryanseys
ryanseys / increment.js
Last active August 29, 2015 14:03
Increment number represented in Array
/**
* Increment number represented in array
*
* E.g. Take [1, 2, 3] increment to [1, 2, 4]
* @param {[Number]} arr Array to increment
* @return {[Number]} Array of numbers
*/
function increment(arr) {
for(var i = arr.length - 1; i >= 0; i--) {
if(arr[i] === 9) {
.heart {
font-size: 200pt;
line-height: 0.9;
text-align: center;
color: red;
-webkit-animation:beat 0.6s infinite; /* Chrome, Safari, Opera */
-moz-animation:beat 0.6s infinite;
animation:beat 0.6s infinite;
}
@ryanseys
ryanseys / update.sh
Created March 15, 2014 20:31
Update/upgrade a bunch of stuff on my system
#!/usr/bin/env sh
gem update
brew update
brew upgrade
upgrade_oh_my_zsh
@ryanseys
ryanseys / fizzbuzz.rkt
Last active August 29, 2015 13:56
Recursive FizzBuzz in Scheme
#lang racket
(define (fizzbuzz n limit)
(cond
((eq? (modulo n 15) 0)
(printf "~a: FizzBuzz~n" n))
((eq? (modulo n 3) 0)
(printf "~a: Fizz~n" n))
((eq? (modulo n 5) 0)
(printf "~a: Buzz~n" n)))
@ryanseys
ryanseys / gist:7305562
Created November 4, 2013 16:50
Empty array in Python treated as None-ish type
//JavaScript
[] || 'hello' // returns []
# Python
[] or 'hello' # returns 'hello'
@ryanseys
ryanseys / deploy
Last active December 26, 2015 17:29
deploy
#!/bin/sh
set -e
echo 'Deploying...'
apt-get install -y nginx
service nginx start
update-rc.d nginx defaults
docker build -t ryanseys/hello github.com/ryanseys/node-helloworld
docker run -d ryanseys/hello
docker ps
@ryanseys
ryanseys / Dockerfile
Last active December 26, 2015 15:19
Dockerfile for Node.js apps
FROM ubuntu:12.04
MAINTAINER Ryan Seys <ryan@ryanseys.com>
RUN echo "deb http://archive.ubuntu.com/ubuntu precise universe" >> /etc/apt/sources.list
RUN apt-get update # DATE: 2013/10/26
RUN apt-get upgrade -y
RUN apt-get install -y python-software-properties python g++ make software-properties-common
RUN add-apt-repository ppa:chris-lea/node.js && apt-get update
RUN apt-get install -y nodejs
ADD . /src
RUN cd /src; npm install