Skip to content

Instantly share code, notes, and snippets.

View hosh's full-sized avatar

Ho-Sheng Hsiao hosh

  • Remine
  • Phoenix, AZ
View GitHub Profile
@hosh
hosh / convert_to_post.ex
Created October 13, 2018 00:23
Kludge to add additional body_params parsing for HTTP verbs such as REPORT
defmodule Legalio.Plug.ConvertToPost do
@moduledoc """
A Plug to convert a list of methods to POST so
that body_params can be populated
"""
@behaviour Elixir.Plug
alias Elixir.Plug.Conn
@hosh
hosh / redis.rb
Created May 24, 2017 19:19
Matsuri Example
# Matsuri.define will generate a custom class and registers it
# Because it is a Ruby class, you can create mixins by creating a Ruby
# module and `include` it in.
# Everything is broken down into smaller `let()`. If you are not familiar
# with it, it is taken from Rspec, and defines a memoized method. We can
# then customize functionality by overriding any of the lets. In this case,
# the base class of the pod definition defines the manifests:
# https://github.com/matsuri-rb/matsuri/blob/master/lib/matsuri/kubernetes/pod.rb#L10
# Notice how I am overriding just enough to create a pod. However, I can override
@hosh
hosh / tmux.conf
Created October 25, 2016 19:20
tmux.conf
# Disable delay in escape so that spacemacs will work under here
set -s escape-time 0
# utf-8 support
setw -g utf8 on
set -g status-utf8 on
set -g default-terminal "screen-256color"
set -g prefix C-z
unbind-key C-b

Keybase proof

I hereby claim:

  • I am hosh on github.
  • I am hosh (https://keybase.io/hosh) on keybase.
  • I have a public key whose fingerprint is 4F16 11A6 0573 ACDB 6695 A803 C33D 336C 2601 19B8

To claim this, I am signing this object:

@hosh
hosh / some_api.rb
Last active August 29, 2015 14:16
A neat thing you can do with Intermodal + functional Ruby
require 'rlet/functional'
module SomeApi
module API
class V1_0 < Intermodal::API
using RLet::Functional
self.default_per_page = 25
map_data do
Failures:
1) Search API endpoint /search/node POST targeted toward many nodes with body of {"possibly_nested"=>["top", "middle", "bottom"], "the_name"=>["name"], "not_found"=>["foo", "bar", "baz", "totally_not
_a_real_field"], "empty"=>[]} should succeed, and return multiple nodes
Failure/Error: r.should look_like search_success_response
Expected a full match of the result
{"total"=>4,
"start"=>0,
-- Copyright 2013 Opscode, Inc. All Rights Reserved.
--
-- This file is provided to you under the Apache License,
-- Version 2.0 (the "License"); you may not use this file
-- except in compliance with the License. You may obtain
-- a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing,
Migrating from Chef 10 to Chef 11
Strategy
We stand up a new Chef 11 server. We then download all the artifacts and data from Chef 10 using knife download, and then upload them to the Chef 11 server using knife upload. Since the data is saved into a repo before uploading, we can verify the data and modify it as needed.
Considerations
Chef 10 uses CouchDB. Chef 11 uses PostgreSQL. There are also changes in the underlying data. However, the data from the API are communicated in JSON and knife knows how to handle the differences between Chef 10 and 11. `knife upload` and `knife download` in knife-essentials will take us most of the way there.
@hosh
hosh / Gemfile
Created July 31, 2012 19:39
Gemfile.local
# Add this snippet at the bottom of your Gemfile
# This allows you to add gems for debugging that you may not want to
# version.
# If you want to load debugging tools into the bundle exec sandbox,
# add these additional dependencies into Gemfile.local
eval(IO.read(__FILE__ + '.local'), binding) if File.exists?(__FILE__ + '.local')
@hosh
hosh / gist:2285755
Created April 2, 2012 17:58
What is Devops?
Devops is for people who want to get their product out to their customers.
Devops is...
1. Software Eats Infrastructure.
http://online.wsj.com/article/SB10001424053111903480904576512250915629460.html
2. Disposable Resources.