Skip to content

Instantly share code, notes, and snippets.

@ajsharma
ajsharma / postgresql.conf
Last active May 23, 2022 22:16
How to tail Homebrew Postgres logs in terminal
# File located at /opt/homebrew/var/postgres/postgresql.conf
# Find `log_statement` and set it to 'all'.
log_statement = 'all'
# Postgres must be restarted before changes take effect.
@ajsharma
ajsharma / google_fi_mark_as_read.js
Created December 14, 2021 23:58
Mark all Google Fi Voicemails as Read
// Go to https://messages.google.com/web/voicemail
// Scroll through your messages to load all the unread messages
// Run this in your browser
const inputs = document.querySelectorAll('.unread');
for (let i = 1; i < inputs.length; i++) { inputs[i].click() }
#!/usr/local/bin/phantomjs --ssl-protocol=tlsv1
// Script to screenshot the given URL. It renders when it receives
// a callPhantom invocation with {renderNow: true}. The viewport
// defaults to the URL's body size.
var system = require('system');
// --------------------- Set Timeout ---------------------
### Keybase proof
I hereby claim:
* I am ajsharma on github.
* I am ajsharma (https://keybase.io/ajsharma) on keybase.
* I have a public key ASC1LMGkHapAsykKIWOHbD9EUpKW0uoeBtq1ob4r_ZLGKgo
To claim this, I am signing this object:
@ajsharma
ajsharma / resque_retry.rb
Last active February 28, 2017 23:41
Resque retry with prompt
# Prompt the user for each failed Resque job
# Respond with `y` to retry, otherwise it's skipped
def triage
# Pop jobs off the queue until there are no more
Resque::Failure.all( 0, 0 ).each.with_index do |job, index|
puts "JOB:"
pp job.except( "backtrace" )
puts "Retry? ('y')"
@ajsharma
ajsharma / rollbar24.rql
Created February 3, 2017 00:33
Rollbar RQL to pull most frequent Rails errors in the last 24 hours
SELECT item.counter, item.title, count(*), max(timestamp), item.framework
FROM item_occurrence
WHERE timestamp > unix_timestamp() - 60 * 60 * 24
AND item.environment = 'production'
AND item.framework = 1
AND item.level > 30
GROUP BY item.counter
ORDER BY count(*) DESC
LIMIT 1000
@ajsharma
ajsharma / rollbar.rql
Last active March 1, 2022 23:12
Rollbar RQL query to pull number of exceptions that have occurred in the last 60 days
SELECT body.trace.exception.class, count(*), sum(item.total_occurrences), min(timestamp), max(timestamp), level, environment, item.status
FROM item_occurrence
WHERE timestamp > unix_timestamp() - 60 * 60 * 24 * 77
AND item.status = 1
AND language = 'ruby'
AND item.level >= 40
AND environment = 'production'
GROUP BY body.trace.exception.class
LIMIT 500
@ajsharma
ajsharma / Gemfile
Last active July 5, 2016 23:35
Simple rake script to run failed specs from CircleCi on your computer
group :development do
gem 'circleci', require: false
end
@ajsharma
ajsharma / ZeroCaterMathy.py
Last active December 14, 2015 03:39
My solution to ZeroCater's February Mathy challenge.
class Primes:
"""Get primes, fast. Eat lots of memory"""
@staticmethod
def list_all_up_to(ceiling):
"""Creates a list of prime numbers up to the ceiling"""
limit = int((ceiling - 1) / 2)
prime_map = [True] * limit
list_of_primes = [2]
index = 0
/**!
* Basic boilerplate for writing JQuery plugins
**/
;(function ( $, window, document, undefined ) {
//TODO: code goes here
$(document).ready(function() {
// TODO: runtime code goes here
}