Skip to content

Instantly share code, notes, and snippets.

View cmer's full-sized avatar

Carl Mercier cmer

  • Dallas-Fort Worth, TX
  • 05:40 (UTC -05:00)
View GitHub Profile

Keybase proof

I hereby claim:

  • I am cmer on github.
  • I am cmer (https://keybase.io/cmer) on keybase.
  • I have a public key whose fingerprint is D086 FC72 06E0 89F8 7FAE C495 E5F6 43EA 38F0 16D0

To claim this, I am signing this object:

@cmer
cmer / gist:6063133
Created July 23, 2013 15:10
Hetzner EX40 UnixBench
# # # # # # # ##### ###### # # #### # #
# # ## # # # # # # # ## # # # # #
# # # # # # ## ##### ##### # # # # ######
# # # # # # ## # # # # # # # # #
# # # ## # # # # # # # ## # # # #
#### # # # # # ##### ###### # # #### # #
Version 5.1.3 Based on the Byte Magazine Unix Benchmark
Multi-CPU version Version 5 revisions by Ian Smith,
# routes.rb
put '/payment_details' => 'payment_details#update'
# controller
class PaymentDetails < Controller
def update
stripe = Stripe.new
stripe.email = params[:stripe][:email]
stripe.address = params[:stripe][:address]
@cmer
cmer / gist:3821654
Created October 2, 2012 17:50
Ok, Ruby. What's the real here?
[1] pry(#<NotificationCreationService>)> record
=> #<Item id: 58, kind: 1, user_id: 79, community_id: 43, category_id: nil, root_category_id: nil, title: "Autem optio molestias unde laudantium fugit officii...", description: "Aut at quod officiis repellendus. Expedita pariatur...", price: nil, original_price: nil, lowest_price: nil, price_drop_count: 0, for_sale: nil, status: nil, bump_position: 1029, published_at: "2012-09-22 17:48:13", last_bumped_at: "2012-09-23 17:48:13", deleted_at: nil, created_at: "2012-09-22 17:48:13", updated_at: "2012-10-02 17:48:13">
[2] pry(#<NotificationCreationService>)> record.is_a?(Item)
=> false
[3] pry(#<NotificationCreationService>)> record.class.name
=> "Item"
[4] pry(#<NotificationCreationService>)> record.class
=> Item(id: integer, kind: integer, user_id: integer, community_id: integer, category_id: integer, root_category_id: integer, title: string, description: string, price: decimal, original_price: decimal, lowest_price: decimal, price_drop_count: integer, for_sale: b
@cmer
cmer / application_controller.rb
Created September 13, 2012 19:13 — forked from jamesbebbington/application_controller.rb
Rack middleware and form tag patch to insert csrf tokens into cached pages
class ApplicationController < ActionController::Base
TOKEN_PLACEHOLDER = "__CROSS_SITE_REQUEST_FORGERY_PROTECTION_TOKEN__"
after_filter :inject_csrf_token
private
def inject_csrf_token
if protect_against_forgery? && token = session['_csrf_token']
if body_with_token = response.body.gsub!(TOKEN_PLACEHOLDER, token)
# Set your full path to application.
app_path = "/Users/carl/Dropbox/code/web" # -> changed for development env
# Set unicorn options
worker_processes 20
preload_app true
timeout 180
listen 8080 #"/tmp/.unicorn.sock" -> changed for development env
# Spawn unicorn master worker for user apps (group: apps)
@cmer
cmer / data-benchmark-large-dom.html
Created July 26, 2012 17:33
Benchmarks for data(), attr() and getAttribute() over a large DOM
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>
<ul></ul>
<p data-foo='abc'></p>
<script>
@cmer
cmer / data-benchmark.html
Created July 26, 2012 16:08
Benchmarks for data(), attr() and getAttribute()
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>
<ul></ul>
<p data-foo='abc'></p>
<script>
@cmer
cmer / gist:3157850
Created July 22, 2012 01:16
Spam on Quora
Sam John sent you a message on Quora
Sam John said:
"Greetings to you and your family,
my came is Barr. Samora Johnson. I’m personal Attorney to late (Mr Victor .A. Mercier)a nationality of your country, who bear the same surname with yours. died in heart attack after the death of his wifi and only daughter in a car accident, in Benin Republic West Africa on 21st April 2008. (May their gentle souls rest in perfect peace) without anyone to claim his Fund.USD12.5M deposit in the Security bank.
The Bank has issued me an ultimatum to present the next-of-kin of the deceased to inherit the funds to my late client; I have made several enquiries to your embassy here to locate any of my clients extended relatives in his home country,
I decided to contact you hence I know that you bear the same surname with him.
def foo
# do something here
end
# Is it considered bad practice to assign a variable in a conditional statement?
# Ruby gives me a warning: "warning: found = in conditional, should be =="
if x = foo
puts x.to_s
end