Skip to content

Instantly share code, notes, and snippets.

import React from 'react'
import i18n from 'i18n-js'
import { sanitize } from 'dompurify'
import _ from 'lodash'
export const htmlTranslate = (scope, options) => {
if (!scope.endsWith('_html')) {
return i18n.t(scope, options)
}
@coryf
coryf / dev-dnsmasq.sh
Last active November 11, 2020 20:17
dev dnsmasq osx
#!/bin/sh
brew install dnsmasq
echo "address=/dev3d.org/127.0.0.1" >> /usr/local/etc/dnsmasq.conf
sudo brew services start dnsmasq
sudo mkdir -p /etc/resolver
sudo tee /etc/resolver/dev3d.org >/dev/null <<EOF
nameserver 127.0.0.1
EOF
@coryf
coryf / fizzbuzz-fp-iterator.js
Last active June 11, 2019 20:03
javascript fizzbuzz functional iterator
const fizzBuzz = {
[Symbol.iterator]: (() => {
const stop = 100
const iterate = function* (number = 1, count5 = 1, count7 = 1) {
if (number > stop) { return }
if (count5 == 5 && count7 == 7) {
yield 'fizzbuzz'
yield *iterate(number + 1, 1, 1)
@coryf
coryf / .vimrc
Last active December 12, 2018 19:53
Vim ripgrep and fzy
" ripgrep
" https://github.com/BurntSushi/ripgrep
set grepprg=rg\ --vimgrep\ --no-heading
set grepformat^=%f:%l:%c:%m
command -nargs=+ -complete=file Rg silent! grep! <args> | copen | redraw!
nmap <silent> <leader>a :Rg "\b<C-R><C-W>\b"<CR>
" fzy - fuzzy find
" https://github.com/jhawthorn/fzy
function! FzyCommand(choice_command, vim_command)

Keybase proof

I hereby claim:

  • I am coryf on github.
  • I am coryf (https://keybase.io/coryf) on keybase.
  • I have a public key whose fingerprint is 6C9E 35B5 473C 4A5C 02C5 FC71 02BA 3DF7 E946 03F8

To claim this, I am signing this object:

@coryf
coryf / .tmux.conf
Created December 21, 2016 16:34
tmux battery status
# clone https://github.com/tmux-plugins/tmux-battery to <tmux-battery-path>
# add to .tmux.conf:
set -g status-right "#[fg=yellow]#(date +'%a %d') #[fg=green]#(date +'%I:%M%p')#[fg=white] #[bg=black] #{battery_percentage} #{battery_icon} "
set -g @batt_charged_icon "🔌"
set -g @batt_charging_icon "⚡"
set -g @batt_discharging_icon "🔋"
set -g @batt_attached_icon "⚠️"
@coryf
coryf / Dockerfile
Created September 1, 2016 15:53
Phoenix + Docker Compose + Live Reload
# Starting from the official Elixir 1.3.2 image:
# https://hub.docker.com/_/elixir/
FROM elixir:1.3.2
# Based off of a Dockerfile by David Anguita <david@davidanguita.name>
MAINTAINER Cory Fabre <cfabre@gmail.com>
ENV DEBIAN_FRONTEND=noninteractive
# Install hex
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
# Forces all threads to share the same connection. This works on
@coryf
coryf / deep_munge_fix.rb
Created May 26, 2014 00:51
Rails deep_munge patch
# This is a monkey patch to fix the Rails deep_munge issue described here:
# https://github.com/rails/rails/issues/13420
#
# Rails converts incoming empty array params into nils. This patch reverts that.
# This goes in /config/initializers
#
# Before patch:
#
# | JSON | Hash |
# |----------------------------------|-------------------------|
@coryf
coryf / bootstrap_alert_helper.rb
Created May 23, 2014 15:38
Bootstrap alert Rails helpers
def bootstrap_alert(type, message, options = {})
options.reverse_merge!(dismissable: true)
classes = %w(alert)
classes << case type
when :error, :alert
'alert-danger'
else
'alert-info'
end