Skip to content

Instantly share code, notes, and snippets.

@jamescmartinez
jamescmartinez / slack_delete.rb
Last active May 28, 2024 15:00
This Ruby script will bulk remove all Slack files older than 30 days. Just add your API token from https://api.slack.com/web#authentication into the token quotes at the top of the file.
require 'net/http'
require 'json'
require 'uri'
@token = ''
def list_files
ts_to = (Time.now - 30 * 24 * 60 * 60).to_i # 30 days ago
params = {
token: @token,
@phiggins
phiggins / gist:7850ccf50d2924f88ad0
Last active December 15, 2016 21:44
bash scripts for finding dead rails code
for i in app/models/post.rb ; do sed -e "s/\s\+def \(self\.\)\?\([^( ]*\).*\|\s\+scope :\([^,]*\).*/\2\3/" -e 'tx' -e 'd' -e ':x' $i | while read j ; do echo $(grep -R $j app/ lib/ config/ | wc -l) $j ; done ; done | sort -rn
for i in $(find app/views/ -type f) ; do echo $(grep -R $(echo $i | sed "s/.*\/_\?\([^.]*\).*/\1/") app/ | wc -l) $i ; done | sort -rn
@slyness
slyness / rename_node.md
Last active November 11, 2023 18:09
Rename a Chef Node

How to rename a chef node

  1. Edit existing node name. Update name and save. Chef will copy the node and create a new client entry.
knife node edit oldnode
  1. ssh to node
  2. Change hostname and dns information
@emcmanus
emcmanus / gist:2894558
Created June 8, 2012 08:50
Git Status in FishFish Prompt - Fish port of __git_ps1
# Port of __git_ps1 for Fish shell (tested with FishFish)
#--------------------------------------------------------------------------------------------------
# https://github.com/bjeanes/dot-files/tree/294254ce2f064bbfc586e98107da1ed510898ffd/fish/functions
# via @bjeanes - https://github.com/bjeanes
function __git_ps1
set -l g (git rev-parse --git-dir ^/dev/null)
if [ -n "$g" ]
set -l r ""
set -l b ""