Skip to content

Instantly share code, notes, and snippets.

View willricketts's full-sized avatar
🇺🇸

Will Ricketts willricketts

🇺🇸
View GitHub Profile
@willricketts
willricketts / name_registry.ex
Created November 6, 2019 21:51
Name Generation and Registry for Rhea
defmodule DB.NameRegistry do
@moduledoc """
Creates and verifies usage of names
"""
import Ecto.Query
alias DB.Repo
@adjectives ~w(
aged ancient autumn billowing bitter black blue bold
@willricketts
willricketts / map_graph.ex
Created November 6, 2019 21:27
Elixir module for persisting a list of Rhea SolarSystem structs into Neo4j
defmodule GalaxyMap.Importers.MapGraph do
@moduledoc """
Responsible for building the game map within Neo4j
- Creates each solar system within Neo4j
- Builds relationships between solar system nodes within Neo4j
"""
def run(solar_systems) do
solar_systems
|> Enum.map(fn(system) -> persist_system(system) end)
|> Enum.map(fn(system) -> build_connections(system) end)
defmodule MyApp.ActivationToken do
import Ecto.Query
alias MyApp.Accounts.User
alias MyApp.Repo
@moduledoc """
Responsible for generating uniuqe email activation tokens
"""
@length 64

Keybase proof

I hereby claim:

  • I am willricketts on github.
  • I am willricketts (https://keybase.io/willricketts) on keybase.
  • I have a public key ASCrD4QXihD0R7bJhjCIRKd8rPwRptMgt7onyn-ObVI08Ao

To claim this, I am signing this object:

#! /bin/bash
find . -name '*.go' -exec grep -niw 'TODO' {} \; -print

Keybase proof

I hereby claim:

  • I am willricketts on github.
  • I am willricketts (https://keybase.io/willricketts) on keybase.
  • I have a public key ASB2ezEbzUopD3p8pEUKVyzbIbbWVngzAVGd_e6qlieOBQo

To claim this, I am signing this object:

@willricketts
willricketts / commandant.js
Last active August 29, 2015 14:27
Express.js endpoint to parse JSON payloads via POST request and execute bash strings on the server
app.post('/command', function(req, res, next) {
var b = req.body,
payload = JSON.parse(b),
spawn = require(‘child_process’).spawn;
spawn(‘sh’, [-c, payload.command], { stdio: ‘inherit’ });
next();
});
@willricketts
willricketts / auth.js
Created August 20, 2015 14:45
Simple authentication system for Sails.js
var bcrypt = require('bcrypt');
module.exports = {
hashPassword: hashPassword,
verifyPassword: verifyPassword
}
function hashPassword(prehash, callback) {
bcrypt.genSalt(10, function(err, salt) {
if(err) {
@willricketts
willricketts / gist:8880d880341d0d95862c
Created January 27, 2015 19:01
Super simple Node.js password hashing and checking
var bcrypt = require('bcrypt');
module.exports = {
hashPassword: hashPassword,
checkPassword: checkPassword
};
function hashPassword(password, callback) {
bcrypt.genSalt(10, function(err, salt) {
bcrypt.hash(password, salt, function(err, hash) {
@willricketts
willricketts / MongoBlogPagination
Last active December 22, 2015 00:39
I can't seem to figure out why my Posts index page isn't paging. Halp!
#Gemfile
gem "will_paginate_mongoid"