Skip to content

Instantly share code, notes, and snippets.

@jamescmartinez
jamescmartinez / gitignore_update.sh
Created December 10, 2012 07:38
Run this script to have your git repo reflect your new (or newly updated) .gitignore file
#!/bin/bash
# Please be aware to commit all your changes before; YOU WILL LOSE ALL CHANGES SINCE LAST COMMIT!
git rm -r --cached . # This removes everything from the index.
git add . # Add everything back using new .gitignore
git commit -m ".gitignore is now working" # Commit it!
@jamescmartinez
jamescmartinez / snapchat_decrypt.rb
Last active August 13, 2023 20:23
Snapchat Image Decrypt - This Ruby script decrypts the blob received from the `bq/blob` endpoint. Many thanks to @kivikakk, @adamcaudill, @tlack, and @NeilHanlon for inspiration, code, guides, and of course, the encryption key.
#!/usr/bin/env ruby
require 'openssl'
data = File.open('blob', 'r:ASCII-8BIT').read
c = OpenSSL::Cipher.new('AES-128-ECB')
c.decrypt
c.key = 'M02cnQ51Ji97vwT4'
o = ''.force_encoding('ASCII-8BIT')
data.bytes.each_slice(16) { |s| o += c.update(s.map(&:chr).join) }
@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,
@jamescmartinez
jamescmartinez / html5boilerplate.html
Created March 17, 2016 03:57
Super simple, no frills HTML5 boilerplate!
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello, World!</title>
<link rel="stylesheet" href="stylesheet.css">
</head>
<body>
Hello, World!
<script src="javascript.js"></script>
@jamescmartinez
jamescmartinez / githubssh.sh
Last active November 4, 2023 14:58
Because setting up SSH on GitHub shouldn't take 10 pages of tutorials...
ssh-keygen -t ed25519 -C "[email protected]"
pbcopy < ~/.ssh/id_ed25519.pub
@jamescmartinez
jamescmartinez / eq_time.rb
Created October 22, 2021 15:11
RSpec time comparison matcher to 6 decimal places
# On MacOS, time has a precision of 6. On Linux (e.g. CI), time is more precise.
#
# For example:
# Linux: Fri, 22 Oct 2021 11:24:40.219256519 UTC +00:00
# MacOS: Fri, 22 Oct 2021 11:24:40.219256000 UTC +00:00
#
# This matcher compares time with a precision of 6 decimal places to prevent
# time comparison failures in CI.
#
RSpec::Matchers.define(:eq_time) do |expected|
@jamescmartinez
jamescmartinez / curl-format.txt
Created June 28, 2023 18:36
curl with durations
\n\n
time_namelookup: %{time_namelookup}s\n
time_connect: %{time_connect}s\n
time_appconnect: %{time_appconnect}s\n
time_pretransfer: %{time_pretransfer}s\n
time_redirect: %{time_redirect}s\n
time_starttransfer: %{time_starttransfer}s\n
--------------------------------------------------\n
time_total: %{time_total}s\n
@jamescmartinez
jamescmartinez / request_validator.go
Last active June 12, 2024 20:11
Validate a Mergent Task in Go
package main
import (
"bytes"
"crypto/hmac"
"crypto/sha1"
"encoding/base64"
"io"
"net/http"
"net/http/httptest"