Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
pending validation

Matt Darby mdarby

💭
pending validation
View GitHub Profile
View gist:1f7df94b8b5d60e847b75235bde0c4d7
# latitude and longitude as strings is not ideal
View update.rb
# frozen_string_literal: true
class ListingDescriptionUpdater
class << self
def update
file = ''
# Commented out the array of Place, Event, Job because Events and Jobs are required to have descriptions at point of creation so there should not be anything needed to be scraped from a site.
# If in the future the description field is no longer a required field they can be added back as shown below.
# [Place, Event, Job].each do |klass|
[Place].each do |klass|
@mdarby
mdarby / config_puma.rb
Created Aug 15, 2016 — forked from acrookston/config_puma.rb
puma config for rvm, capistrano 3 and upstart. Tested on Ubuntu 12.04 LTS and 14.04 LTS
View config_puma.rb
#!/usr/bin/env puma
app_path = '/var/www/YOUR_APP_NAME/current'
directory app_path
environment 'production'
daemonize true
pidfile "#{app_path}/tmp/pids/puma.pid"
state_path "#{app_path}/tmp/pids/puma.state"
stdout_redirect "#{app_path}/log/puma_error.log", "#{app_path}/log/puma_access.log", true
threads 0,16
View openstack-sdk-test-env-setup.md
  1. On Rackspace Public Cloud, create an 8GB General Server with Ubuntu 14.04 PVHM.
  2. SSH in as root. If you are really cool, use tmux at this time.
  3. Install OpenStack Liberty
    bash <(curl -s https://raw.githubusercontent.com/openstack/openstack-ansible/liberty/scripts/run-aio-build.sh)
    
  4. Once complete, you can find the admin password in /root/openrc. Save it for later to log into Horizon.
  5. Fix the neutron endpoint to work with the SDK:
  6. lxc-ls | grep utility.
  7. lxc-attach -n aio1_utility_container-XXX. Replace XXX with the name you found in the last step.
View gist:552f38c1f46917159a83
sudo apt-get update
sudo apt-get install libffi-dev libssl-dev git vim build-essential python -y
git clone https://github.com/openstack-dev/devstack.git
sudo ./devstack/tools/create-stack-user.sh
sudo mv devstack/ /opt/stack/
rm -rf barbican/
chown -R stack:stack /opt/stack/devstack/
su - stack
cd /opt/stack/devstack/
View whoa.ex
jobs
|> Enum.map(fn(x) -> x.name end)
|> Enum.sort
|> Enum.chunk(5)
|> Enum.map(fn(x) -> Enum.shuffle(x) end)
# (A) is != to (B)
names = Enum.map(jobs, fn(x) -> x.name end)
sorted_names = Enum.sort(names)
View gist:538dd1d451d09df43c82
Server Software:
Server Hostname: localhost
Server Port: 4001
Document Path: /api/contacts
Document Length: 2 bytes
Concurrency Level: 100
Time taken for tests: 5.029 seconds
Complete requests: 10000
View gist:b330704e4902aac63d99
# They do different things. exec replaces the current process with the new process.
# system invokes another process and returns its exit value to the current process.
# backticks invokes another process and returns the output of that process to the current process.
while true
puts `bundle exec rspec 'spec/dev_free_ipad_idempotent_spec.rb'`
end
@mdarby
mdarby / gist:1acc75cbc2d23d6c97b5
Created Sep 21, 2014
POST to localhost:8080/change with {given: 1000, owed: 450} and receive a JSON response of the change due in standard US currency. Some DRYing should occur around the Denominations.
View gist:1acc75cbc2d23d6c97b5
package main
import (
"encoding/json"
"io"
"log"
"net/http"
"strconv"
)
View gist:e4136832e7c428014802
package main
import (
"errors"
"html/template"
"io/ioutil"
"net/http"
"regexp"
)