Skip to content

Instantly share code, notes, and snippets.

View ryanwinchester's full-sized avatar
⚗️
Working on open-source and side projects

Ryan Winchester ryanwinchester

⚗️
Working on open-source and side projects
View GitHub Profile
@ryanwinchester
ryanwinchester / composer.json
Last active February 12, 2016 21:10
Installing and updating Flashtag
{
"repositories": [
{
"type": "vcs",
"url": "git@github.com:flashtag/admin.git"
},
{
"type": "vcs",
"url": "git@github.com:flashtag/api.git"
},
# Before Script
before_script:
- composer self-update
- composer install --prefer-dist > /dev/null
- cp .env.example .env
- php artisan key:generate
- php artisan migrate:refresh
# Services
services:
@ryanwinchester
ryanwinchester / get_query_var.js
Last active July 28, 2016 22:23
Get query parameter from url
get_query_var(name) {
var pairs = window.location.search.substring(1).split("&");
return pairs.reduce((carry, pair) => {
if (pair.split("=")[0] == name)
return pair.substring(pair.indexOf("=") + 1);
return carry;
}, {});
};
@ryanwinchester
ryanwinchester / array_helpers.js
Created July 28, 2016 18:23
Javascript array helpers
array_shuffle(arr) {
var new_array = arr.slice();
var current_index = new_array.length;
var temp_value;
var random_index;
while (0 !== current_index) {
random_index = Math.floor(Math.random() * current_index);
current_index -= 1;
@ryanwinchester
ryanwinchester / codeship-elixir.sh
Created December 6, 2016 16:37 — forked from paulgoetze/codeship-elixir.sh
Codeship Elixir/Phoenix test setup
#!/bin/bash
# Erlang
ERLANG_VERSION=${ERLANG_VERSION:-19.0}
ERLANG_CACHED_DOWNLOAD="${HOME}/cache/OTP-${ERLANG_VERSION}.tar.gz"
ERLANG_DIR=${ERLANG_DIR:="$HOME/erlang"}
# Elixir
ELIXIR_VERSION=${ELIXIR_VERSION:-1.3.1}
ELIXIR_CACHED_DOWNLOAD="${HOME}/cache/elixir-v${ELIXIR_VERSION}.zip"
@ryanwinchester
ryanwinchester / .babelrc
Last active December 20, 2016 19:04
Phoenix Webpack Config with Sass and Vue
{
"presets": ["es2015"],
"plugins": ["transform-runtime"]
}
defmodule PersistentBugger do
@moduledoc """
Calculate multiplicative persistence.
https://www.codewars.com/kata/persistent-bugger/train/elixir
"""
def persistence(num, count \\ 0) when num < 10, do: count
def persistence(num, count \\ 0) do
num
|> Integer.digits

The Erlang VM only allows a limited set of expressions as guards:

  • comparison operators (==, !=, ===, !==, >, <, <=, >=);
  • boolean operators (and, or) and negation operators (not, !);
  • arithmetic operators (+, -, *, /);
  • <> and ++ as long as the left side is a literal;
  • the in operator;
  • all the following type check functions:
    • is_atom/1
  • is_binary/1
@ryanwinchester
ryanwinchester / install_elixir_phoenix.sh
Last active March 26, 2024 17:01
Install Elixir and Phoenix on macOS
# Update brew
brew update
# Need postgres
brew install postgresql
# Install elixir
brew install elixir
# Install hex package manager