Skip to content

Instantly share code, notes, and snippets.

View benjamin-thomas's full-sized avatar

Benjamin Thomas benjamin-thomas

View GitHub Profile
@benjamin-thomas
benjamin-thomas / shared_logger.rb
Last active August 29, 2015 14:02
Shared logger setup
require 'logger'
require 'singleton'
module Logging
def logger
Logger.instance
end
class Logger < ::Logger
include Singleton
@benjamin-thomas
benjamin-thomas / bootstrap.sh
Created September 2, 2014 22:28
Small script to test a rails container with docker
#!/bin/bash
set -e
DEBUG=0
function notify() {
echo -e "\033[1;33m"
echo '================================================================================================='
echo $1
@benjamin-thomas
benjamin-thomas / migrate.sh
Created March 27, 2015 08:32
Sync all emails from one mail server to the next (iRedMail)
#!/bin/bash
set -e
function syncAccount() {
# Important: need trailing slash
FROM=$1
TO=$2
[[ $FROM =~ /$ ]] || (echo "Missing trailing slash!" && exit 1)
[[ $TO =~ /$ ]] || (echo "Missing trailing slash!" && exit 1)
@benjamin-thomas
benjamin-thomas / send_email_attachment_multipart.eml
Created February 13, 2013 10:18
The bare minimum to send an email attachment (multipart)
MIME-Version: 1.0
Content-Type: multipart/mixed;boundary="-----------MIME_BOUNDARY
-------------MIME_BOUNDARY
Content-Type: application/octet-stream;
Content-Transfer-Encoding: Base64
PHhtbD48bm9kZT5UaGlzIGlzIGEgbXVsdGlwYXJ0IGF0dGFjaG1lbnQ8L25v
ZGU+PC94bWw+
@benjamin-thomas
benjamin-thomas / send_email_attachment_monopart.eml
Created February 13, 2013 10:14
The bare minimum to send an email attachment (monopart)
Content-Type: application/octet-stream;
Content-Transfer-Encoding: Base64
PHhtbD48bm9kZT5UaGlzIGlzIGEgbW9ub3BhcnQgYXR0YWNobWVudDwvbm9k
ZT48L3htbD4=
class AccordionRails
=begin
This should be called inside an erb template (currently not working)
<%= AccordionRails.new(parent_id: "front-page-accordion") do |accordion| %>
<%= accordion.element(template: self, title: "My first title link", target_id: "collapseFirstRow") do %>
<p>This is the body content of the first accordion row</p>
<% end %>
#!/usr/bin/env ruby
# gem install colored
require "colored"
# The idea of this class is to encapsulate the creation of complex html elements such
# as the bootstrap carousel found here
# http://twitter.github.io/bootstrap/javascript.html#collapse
#
# This is a ruby prototype before implementing the idea in rails.
module Forms exposing (..)
import Browser
import Char
import Html exposing (Html, br, div, input, p, text)
import Html.Attributes exposing (placeholder, style, type_, value)
import Html.Events exposing (onInput)
main =
Browser.sandbox { init = init, update = update, view = view }
@benjamin-thomas
benjamin-thomas / my_pass.sh
Created January 20, 2018 11:31
WIP : bypass XFCE clipboard manager when using pass/passwordstore.org
#!/bin/bash
# Load the bash completion first
# my_pass.sh needs to be on the load path
# complete -F _pass mypass.sh
pgrep clipman
if [[ $? -ne 0 ]];then
# clipman not running...
@benjamin-thomas
benjamin-thomas / autocomplete_live.ex
Last active August 18, 2022 19:05
PragmaticStudio Elixir/Phoenix/LiveView solutions
defmodule LiveViewStudioWeb.AutocompleteLive do
use LiveViewStudioWeb, :live_view
alias LiveViewStudio.Stores
alias LiveViewStudio.Cities
def mount(_params, _session, socket) do
socket =
assign(socket,
zip: "",