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 / gist:6057397
Created July 22, 2013 20:32
ssh tunnel script inspired by http://bit.ly/14c8aGb
#!/bin/bash
# Usage:
#
# create-ssh-tunnel <host> <remote-internal-port>
#
# Add this to your crontab:
#
# */1 * * * * ~/bin/create-ssh-tunnel joe@server 3333 > ~/ssh-tunnel.log 2>&1
#
# Then on the remote host:
@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 / 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 / heroku-environments
Created April 27, 2016 14:09
Heroku Environment CLI Wrapper
#!/usr/bin/env ruby
# Heroku enviroment helper script
#
# This is to streamline using differnt heroku enviroments from one repo.
# Symlink this file to an envroment name (as set by the git-remote name), then
# when running that symlink the script will look up the name in the git config
# and use that remote as the heroku name.
#
# Setup:
@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