Skip to content

Instantly share code, notes, and snippets.

@csexton
csexton / delete-slack-files.rb
Created June 22, 2017 20:08
Bulk delete files from slack that are older than 30 days.
#!/usr/bin/env ruby
require 'net/http'
require 'json'
require 'uri'
puts " You need a slack toke for your user on the team you'd like to delete"
puts "files from. Visit the following url to get a token:"
puts
puts "https://api.slack.com/custom-integrations/legacy-tokens"
@csexton
csexton / 01.md
Last active June 14, 2017 15:32
Copied from jay0lee/cros-scripts

To run this:

  1. Put ChromeOS in developer mode

  2. Log into device. Press CTRL+ALT+T to open crosh shell.

  3. Type "shell" to enter Bash shell.

  4. Run this command

    bash <(curl -s -S -L https://rn-s.net/chrome-dev)
    
@csexton
csexton / .vimrc
Created April 19, 2017 19:38
A not-too-opinionated version of my vimrc file's basic settings
" https://github.com/csexton/dotfiles/blob/master/home/vimrc
" Plugins {{{
" A few plugis I like and recomend:
"
" https://github.com/csexton/spacemanspiff.vim
" https://github.com/csexton/trailertrash.vim
" https://github.com/kchmck/vim-coffee-script
" https://github.com/slim-template/vim-slim
" https://github.com/thoughtbot/vim-rspec
@csexton
csexton / 1-how-to.md
Last active March 24, 2017 22:50
Do you even git, bro?

Step 1: Save the script to some place in your $PATH and make it executable.

Step 2: git config --global alias.bro '!git-browse'

Step 3: When everyou want to view a branch on github, just git bro

@csexton
csexton / add_template_data_to_contents.rb
Last active November 17, 2016 01:49
Migrate url to template_data hstore
class AddTemplateDataToContents < ActiveRecord::Migration[5.0]
def up
add_column :contents, :template_data, :hstore, default: '', null: false
execute <<~END
UPDATE contents
SET template_data = hstore('url', subquery.url)
FROM (SELECT id, url FROM contents) as subquery
WHERE contents.id=subquery.id;
END
remove_column :contents, :url, :string
@csexton
csexton / openssl.cnf
Created November 7, 2016 16:10
Multi-Domain CSR Config for OpenSSL with Wildcards
#
# OpenSSL example configuration file.
# This is mostly being used for generation of certificate requests.
#
# This definition stops the following lines choking if HOME isn't
# defined.
HOME = .
RANDFILE = $ENV::HOME/.rnd
@csexton
csexton / deploy-to-chrome-webstore.rb
Created November 5, 2016 15:42
Deploy to Chrome Webstore
#!/usr/bin/env ruby
require "net/http"
require "net/https"
require "uri"
require "json"
require "optparse"
require "ostruct"
### What is going on here?
#
require "rails_helper"
RSpec.describe "My Controller Requests", type: :request do
end
@csexton
csexton / wait-for-db
Created August 6, 2016 14:01
A ruby script that will wait for a port to be connectable on a host, normally used to check if another Docker container has booted up
#!/usr/bin/env ruby
require "socket"
require "uri"
if ENV["DATABASE_URL"]
url = URI.parse ENV["DATABASE_URL"]
puts "Waiting for DB on #{url}..."
30.times do
begin
@csexton
csexton / application_controller.rb
Created July 28, 2016 14:48
OAuth Provider User Cache Key
class ApplicationController < ActionController::Base
before_action :set_radius_user_cache_key
# bunch-o-auth stuff goes here
private
def set_radius_user_cache_key
if current_user
cookies[:_radius_user_cache_key] = { value: current_user.cache_key, domain: :all, tld_length: 2 }