Skip to content

Instantly share code, notes, and snippets.

@speric
speric / sendgrid.py
Created April 26, 2012 16:29
Grab bounced emails from Sendgrid
import tornado.options
import urllib2
import json
from tornado.options import define, options
if __name__ == "__main__":
define("username", help="Your Sendgrid username (usually an email address)")
define("password", help="Your Sendgrid password")
@speric
speric / resize.js
Created May 14, 2012 12:10
Resize w/jQuery
<script src="/javascripts/jquery.resize.js"></script>
<script>
$('.agency_talent_photo').resize(150);
</script>
@speric
speric / multisite.rb
Created November 20, 2012 19:54
Multisite Shop Example w/MongoDB
# Order class
# see http://www.slideshare.net/wonko/persisting-dynamic-data-with-mongodb-and-mongomapper
class Order
include MongoMapper::Document
key :order_id, String
class << self
def for_site(site)
klass = Class.new(self)
@speric
speric / gist:6096965
Created July 28, 2013 01:20
vimtutor Lesson Summaries
Lesson 1 SUMMARY
1. The cursor is moved using either the arrow keys or the hjkl keys.
h (left) j (down) k (up) l (right)
2. To start Vim from the shell prompt type: vim FILENAME <ENTER>
3. To exit Vim type: <ESC> :q! <ENTER> to trash all changes.
OR type: <ESC> :wq <ENTER> to save the changes.

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@speric
speric / bialetti-tips.md
Last active December 28, 2015 08:08
Bialetti Moka Express tips

Bialetti Moka Express Tips

  • Put hot water inside the chamber just below the valve. Too much air will have your coffee pop out too fast, the process must be as slow as possible.

  • As soon as coffee starts to spill, turn down the heat to minimum and shut it off when 1/3 or 1/2 of the pot is filled. The rest will flow anyhow and you don't get a "tea-like" coffee.

  • Most important: coffee brewing with Moka or Expresso machines strongly depends on atmospheric pressure. You should grind yourself your beans accordingly to weather: good weather (high pressure) will need a finer ground, bad weather will need a coarser ground.

  • The quality of the final products depends also on the filter holes size.

@speric
speric / books.md
Created November 20, 2013 12:59
Books On The Cold War and Espionage

On the KGB, you have the Mitrokhin Archive. Several books got squeezed out of that one, including "KGB: the Untold Story."

There is an official history of MI6 out, but it deals with WWII/early Cold War. It is a multi-volume work in progress.

"Legacy of Ashes" is the CIA book, written by NYT reporter Tim Weiner. While the author tries to be comprehensive, he sticks mostly to CIA failures (because they are public). Successes are too few and/or too secret?

James Bamford's "Body of Secrets" is the better read, focusing on the NSA. Successes and failures get printed.

"Blind Man's Bluff" is a partial history of submarine-based US espionage, notable for its reliance on public documents and interviews with named persons. There are no anonymous sources quoted, ever.

require 'sinatra'
require 'openssl'
require 'json'
post '/' do
body = request.body.read
puts "Time : #{Time.now}"
puts "Actual Signature : #{request.env['HTTP_X_CHARGIFY_WEBHOOK_SIGNATURE_HMAC_SHA_256']}"
puts "Computed Signature: #{signature(body)}"
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@speric
speric / poodir-notes.md
Last active January 24, 2024 10:31
Notes From "Practical Object-Oriented Design In Ruby" by Sandi Metz

Chapter 1 - Object Oriented Design

The purpose of design is to allow you to do design later, and it's primary goal is to reduce the cost of change.

SOLID Design:

  • Single Responsibility Principle: a class should have only a single responsibility
  • Open-Closed Principle: Software entities should be open for extension, but closed for modification (inherit instead of modifying existing classes).
  • Liskov Substitution: Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
  • Interface Segregation: Many client-specific interfaces are better than one general-purpose interface.