Skip to content

Instantly share code, notes, and snippets.

View whazzmaster's full-sized avatar
:shipit:
Re-architect the world

Zachery Moneypenny whazzmaster

:shipit:
Re-architect the world
View GitHub Profile
scalar :time, description: "ISOz time" do
parse &Timex.parse(&1.value, "{ISO:Extended:Z}")
serialize &Timex.format!(&1, "{ISO:Extended:Z}")
end
@whazzmaster
whazzmaster / schema.ex
Created September 20, 2017 14:56
Elixir Many-to-Many Schemas
defmodule User do
schema "users" do
field :email, :string
# ...
many_to_many :companies, Company, join_through: "users_companies"
timestamps()
end
end
@whazzmaster
whazzmaster / update.ex
Created September 20, 2017 15:02
Associating Two Records in a Many-to-Many Relationship
defmodule Identity do
# ...
defp link_user_and_company(user = %User{}, company = %Company{}) do
user = Repo.preload(user, :companies)
companies = user.companies ++ [company]
|> Enum.map(&Ecto.Changeset.change/1)
user
|> Ecto.Changeset.change
@whazzmaster
whazzmaster / app.js
Last active October 5, 2017 15:38
ES6 Debugging: Application
import Cloud from '../cloud';
import program from 'commander';
let command, value;
const INC_CMD = 'increment';
const DEC_CMD = 'decrement';
program
.description('online incrementer: increment cloud-based counters')
.arguments('<cmd> [args]')
@whazzmaster
whazzmaster / package.json
Last active October 5, 2017 15:39
ES6 Debugging: package.json
{
"name": "incrementor",
"version": "1.0.0",
"description": "increment",
"main": "dist/cloud.js",
"private": true,
"scripts": {
"build:lib": "BABEL_ENV=lib $(npm bin)/babel src/ --ignore=src/__mocks__ --out-dir=dist --source-maps",
"build:bin": "BABEL_ENV=cli $(npm bin)/babel src/bin/ --out-dir=dist/bin --copy-files --source-maps",
"build": "rm -rf dist/ && npm run build:lib && npm run build:bin",
@whazzmaster
whazzmaster / launch.json
Created October 5, 2017 14:12
ES6 Debugging: launch.json
{
"version": "0.2.0",
"configurations": [{
"type": "node",
"request": "launch",
"name": "Debug Increment Command",
"cwd": "${workspaceRoot}",
"sourceMaps": true,
"preLaunchTask": "npm: build",
"program": "${workspaceRoot}/dist/bin/app",
@whazzmaster
whazzmaster / app
Created October 5, 2017 14:34
ES6 Debugging: app
#!/usr/bin/env node
require('./app.js');
@whazzmaster
whazzmaster / .babelrc
Created October 5, 2017 15:40
ES6 Debugging: .babelrc
{
"presets": [
["env", {
"targets": {"node": "8.0"},
"useBuiltIns": true
}]
],
"plugins": [
"transform-object-rest-spread"
]
@whazzmaster
whazzmaster / launch.json
Last active October 23, 2017 18:21
golang vscode launch configuration
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch tests",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${workspaceRoot}"
},
@whazzmaster
whazzmaster / fuz.sh
Created December 7, 2017 16:11 — forked from BaseCase/fuz.sh
#!/usr/bin/env bash
set -e
main() {
previous_file="$1"
file_to_edit=`select_file $previous_file`
if [ -n "$file_to_edit" ] ; then
"$EDITOR" "$file_to_edit"
main "$file_to_edit"