Skip to content

Instantly share code, notes, and snippets.

Avatar
💜
Hiring for Elixir, React, and React Native. Lmk if interested.

Dorian Karter dkarter

💜
Hiring for Elixir, React, and React Native. Lmk if interested.
View GitHub Profile
View chat_component.ex
defmodule KingOfTokyoWeb.ChatComponent do
@moduledoc """
Displays the chat history and allows sending new messages
"""
use KingOfTokyoWeb, :live_component
@impl true
def handle_event("send-message", %{"body" => body}, socket) do
send(self(), {:send_message, body})
View elixir.yml
name: Elixir CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
MIX_ENV: test
View automate elixir deployments.md

Automate Your Elixir Deployments - Part 1 - Ansible

Summary

This post will guide you through automating a "bare-metal" machine configuration, and getting a server ready for building and deploying Elixir / Phoenix applications (with LiveView support!)

Body

View automate-your-infrastructure-with-pulumi.md

Automate Your Infrastructure with Pulumi

Managing infrastructure can be frustratingly hard. Combing through byzantine interfaces with poor documentation and hidden features, clicking through hundreds of menus - these experiences are all too familiar to DevOps engineers using AWS. A DevOps engineer's worst fear is that the business will ask for a new instance of the application for a client, and they will have to repeat all those manual steps again. (Hopefully in the correct order, and not forgetting anything along the way!)

At Hashrocket we are big fans of automation, and part of that means we use the

View index.ts
import * as Pulumi from '@pulumi/pulumi';
import * as DigitalOcean from '@pulumi/digitalocean';
import * as fs from 'fs';
const projectName = Pulumi.getProject();
const config = new Pulumi.Config();
const sshPubKeyFilename = config.require('sshPubKeyFilename');
const publicKey = fs.readFileSync(sshPubKeyFilename).toString();
View zoomcontrol.scpt
on run argv
set zoom to "zoom.us"
set wait to 0.5
log "activating zoom"
tell application zoom to activate
# Wait for Zoom's create meeting window to open
tell application "System Events"
repeat until visible of process zoom is true
View .vimrc
let g:ale_pattern_options = {
\ '\.min\.js$': {'ale_linters': [], 'ale_fixers': []},
\ '\.min\.css$': {'ale_linters': [], 'ale_fixers': []},
\}
let g:ale_fixers = {
\ 'typescript': ['prettier'],
\ 'typescript.tsx': ['prettier'],
\ 'javascript': ['prettier'],
\ 'javascript.jsx': ['prettier'],
View zsh ;#neoterm
2019-09-03T22:02:12+00:00 constant-heavenly-redtailedhawk[gigalixir]: Readiness probe failed
: dial tcp 10.56.14.229:4000: connect: connection refused
2019-09-03T22:02:15+00:00 constant-heavenly-redtailedhawk[gigalixir]: Readiness probe failed
: dial tcp 10.56.14.229:4000: connect: connection refused
2019-09-03T22:02:18+00:00 constant-heavenly-redtailedhawk[gigalixir]: Readiness probe failed
: dial tcp 10.56.14.229:4000: connect: connection refused
2019-09-03T22:02:21+00:00 constant-heavenly-redtailedhawk[gigalixir]: Readiness probe failed
: dial tcp 10.56.14.229:4000: connect: connection refused
2019-09-03T22:02:22.756111+00:00 constant-heavenly-redtailedhawk[gigalixir-run]: Shutting do
wn 'constant-heavenly-redtailedhawk' on host 'constant-heavenly-redtailedhawk-7b8b998fd4-ltl
View tracking.ex
def most_viewed_posts(start_date, end_date) do
# v0
query = """
select
page,
count(page) as hits
from
requests
where
request_time between $1::timestamp and $2::timestamp and
View package.json
"scripts": {
"test": "./node_modules/jest/bin/jest.js",
"test:watch": "yarn test --watch",
"webpack:test:build": "RAILS_ENV=test bin/webpack",
"webpack:test:watch": "RAILS_ENV=test bin/webpack --watch --progress",
"webpack-dev-server": "node --max-old-space-size=4096 ./node_modules/webpack-dev-server/bin/webpack-dev-server --progress --hot --color --config",
"lint:js": "eslint ./app/javascript --ext .js --ext .jsx",
"lint:css": "stylelint app/assets/stylesheets/**/*.scss",
"webpack": "node --max-old-space-size=4096 ./node_modules/webpack/bin/webpack.js --progress"
},