Skip to content

Instantly share code, notes, and snippets.

View simonmorley's full-sized avatar

Simon Morley simonmorley

  • London
View GitHub Profile
bavan@ubuntu:~$ mtr --report -n -c 10 mywifi.polkaspots.com
HOST: ubuntu Loss% Snt Last Avg Best Wrst StDev
1.|-- 10.0.1.1 0.0% 10 1.4 1.8 1.3 4.0 0.8
2.|-- 10.0.4.1 0.0% 10 2.7 2.2 1.7 2.7 0.4
3.|-- 46.37.56.1 0.0% 10 41.9 28.2 23.0 41.9 5.9
4.|-- 46.37.32.234 0.0% 10 23.5 25.6 22.9 33.7 3.8
5.|-- 93.89.94.149 10.0% 10 23.3 41.5 23.3 70.9 18.3
6.|-- 93.89.91.14 0.0% 10 25.4 31.4 22.7 62.5 12.8
7.|-- 212.187.200.101 20.0% 10 57.8 34.2 23.4 57.8 13.4
8.|-- 4.69.139.120 0.0% 10 30.5 32.2 23.1 50.9 10.5
@simonmorley
simonmorley / Chef Handy Reference
Last active December 21, 2015 08:59
My Chef shortcuts and command reminders
** Node Operations **
knife node list
knife node delete name_of_server
knife node bulk delete name_of_server
knife node run_list add name_of_server 'recipe[nginx]'
knife node run_list remove name_of_server 'role[iptables]'
** Deploy **
#!/bin/sh
USER=deploy
APP_ROOT="/var/www/html/deploy/production/current"
ENV=production
GEM_HOME="/home/deploy/.rvm/gems/ruby-2.0.0-p247"
UNICORN_OPTS="-c /config/unicorn_production.rb"
SET_PATH="cd $APP_ROOT; export GEM_HOME=$GEM_HOME"
CMD="$SET_PATH; $GEM_HOME/bin/unicorn $UNICORN_OPTS"
@simonmorley
simonmorley / gist:6911186
Created October 10, 2013 00:45
A bulk indexer for tire and elasticsearch. Based on Karmi's version with a couple of additions.
task :reindex => :environment do
require 'ansi/progressbar'
params = {}
@date = Time.now.strftime '%Y%m%d%H%M%S'
def delete_index(index)
puts "[IMPORT] Deleting index '#{index.name}'"
index.delete
end
@simonmorley
simonmorley / gist:7224897
Last active June 4, 2017 16:44
Nginx configuration for a secure kibana, elasticsearch setup. Version 1, no way finished.
server {
listen 8443 default ssl;
server_name www.yourdomain.com;
ssl on;
ssl_certificate /etc/nginx/conf.d/cert.pem;
ssl_certificate_key /etc/nginx/conf.d/cert.key;
client_max_body_size 50M;
error_log /var/log/nginx/elasticsearch-errors.log;
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
> curl https://api.stripe.com/v1/customers \
-u [apikey]: \
-d "card[number]=4000000000000002" \
-d "card[exp_month]=12" \
-d "card[exp_year]=2015" \
-d "card[cvc]=123" \
> -d validate=false
{
"object": "customer",
"created": 1388967139,
describe "elastic search" do
let (:fw) {create :firmware}
before(:all) do ## SOMETIMES BEFORE EACH ##
Nas.index.delete
Nas.create_elasticsearch_index
end
it "should output nice json for nas session search" do
language: ruby
cache:
bundler: true
apt: true
rvm:
- 2.0.0
env:
# - TESTFOLDER=spec/models
# - TESTFOLDER=spec/controllers
# - TESTFOLDER=spec/routing
require "amqp"
error_handler = Proc.new do |settings|
puts "Failed to connect."
EM.stop
end
Thread.new { AMQP.start(
:port => 5672,
:vhost => '/',