Skip to content

Instantly share code, notes, and snippets.

@heaven00
heaven00 / rspec performance test
Created January 31, 2016 18:53 — forked from danbronsema/rspec performance test
Performance testing in Rspec
context 'performance' do
before do
require 'benchmark'
@posts = []
@users = []
8.times do |n|
user = Factory.create(:user)
@users << user
aspect = user.aspects.create(:name => 'people')
connect_users(@user, @aspect0, user, aspect)
@heaven00
heaven00 / cmd.sh
Created February 26, 2016 23:02 — forked from kelvinn/cmd.sh
Example of using Apache Bench (ab) to POST JSON to an API
# post_loc.txt contains the json you want to post
# -p means to POST it
# -H adds an Auth header (could be Basic or Token)
# -T sets the Content-Type
# -c is concurrent clients
# -n is the number of requests to run in the test
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/
@heaven00
heaven00 / web-servers.md
Created February 29, 2016 05:16 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@heaven00
heaven00 / development_profiler.rb
Created March 3, 2016 14:13 — forked from hiltmon/development_profiler.rb
Simple class to wrap a profile run around some code
class DevelopmentProfiler
def self.prof(file_name)
RubyProf.start
yield
results = RubyProf.stop
# Print a flat profile to text
File.open "#{Rails.root}/tmp/performance/#{file_name}-graph.html", 'w' do |file|
#!/usr/bin/env python
import threading, logging, time
from kafka import KafkaConsumer, KafkaProducer
class Producer(threading.Thread):
daemon = True
def run(self):
from kafka import KafkaConsumer
consumer = KafkaConsumer(bootstrap_servers='localhost:9092',
auto_offset_reset='earliest')
while True:
requested_data = consumer.poll()
if len(requested_data) > 0:
print requested_data
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='ad_accounts', durable=True)
def process_ad_accounts(ch, method, properties, body):
print(" [x] Received %r" % body)
print body
print(" [x] Done")
@heaven00
heaven00 / Install NVIDIA Driver and CUDA.md
Created January 24, 2017 20:36 — forked from wangruohui/Install NVIDIA Driver and CUDA.md
Install NVIDIA Driver and CUDA on Ubuntu / CentOS / Fedora
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.