Skip to content

Instantly share code, notes, and snippets.

@ajsharma
ajsharma / story-template.html
Created August 23, 2011 22:04
A general layout of what a ui story should look like inside a webapp
<!-- a story is an item that exists in a list that leads into its own. An active story is one that is meant to be interacted with, whereas an inactive story is just for display -->
<article class="story [storyObjectType] [in]active" href="[storyController]/view/[storyId]">
<!-- Optional: Appropriate avatar item for story (user photo, task time etc.) the thing that identifies the story in a quick glance -->
<div class="story-avatar">
<!-- img or time or div or span -->
</div>
<div class="story-content">
<div class="story-content-wrapper">
<header class="story-content-header">
@ajsharma
ajsharma / gist:1169591
Created August 24, 2011 23:37
pseudo-code to have nice slide in and out of twitter logo for twitter category articles
.category-twitter:hover {
background-position: -50px -50px;
-webkit-transition: all 0.5s ease-out;
}
.category-twitter {
background: url(http://a2.twimg.com/a/1314204713/images/logos/twitter_newbird_boxed_blueonwhite.png);
background-repeat: no-repeat;
background-position: -300px -50px;
-webkit-transition: all 0.5s ease-out;
@ajsharma
ajsharma / gist:3725207
Created September 14, 2012 22:02 — forked from deenseth/gist:1514633
Add Google Calendar Event Bookmarklet
javascript: var s;
/*Figure out the selected text*/
if ( window.getSelection ) {
s = window.getSelection();
} else if ( document.getSelection ) {
s = document.getSelection();
} else {
s = document.selection.createRange().text;
}
/*If there isn't any text selected, get user input*/
@ajsharma
ajsharma / ScrollTop.js
Last active December 10, 2015 10:48 — forked from anonymous/gist:4422788
/**
* Overrides default JQuery.scrollTop to account for top header nav
* @requires JQuery
* @see http://api.jquery.com/scrollTop/
* @see https://github.com/jquery/jquery/blob/master/src/offset.js for scrollTop declaration
**/
(function($) {
var topOffset = 120; // height to account for in scrolling
/**!
* Basic boilerplate for writing JQuery plugins
**/
;(function ( $, window, document, undefined ) {
//TODO: code goes here
$(document).ready(function() {
// TODO: runtime code goes here
}
@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
@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 / 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 / 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 / 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')"