Skip to content

Instantly share code, notes, and snippets.

View brianjolly's full-sized avatar

Brian Jolly brianjolly

View GitHub Profile
app.prepare()
.then(() => {
const server = express()
global['Stack'] = Contentstack.Stack({
api_key: config.contentstack.api_key,
access_token: config.contentstack.access_token,
environment: config.contentstack.environment
});
server.get('*', (req, res) => {
<!doctype html>
<html>
<head>
<style>
* {
font-family: Arial;
font-size: 16px;
}
h1 {
@brianjolly
brianjolly / gist:4076102
Created November 15, 2012 01:39
memory logger
#!/usr/local/bin/ruby
log_file = "/var/log/mem_stats"
date = `date`.rstrip
mem_stats = `free -k`.split
output = ""
if Dir[log_file] == []
output << "date,\t total memory,\t used memory,\t free memory\n"
@brianjolly
brianjolly / gist:4076096
Created November 15, 2012 01:39
cpu logger
#!/usr/local/bin/ruby
log_file = "/var/log/cpu_stats"
date = `date`.rstrip
cpu_stats = `uptime`.split
output = ""
if Dir[log_file] == []
output << "date,\t 1min,\t 5min,\t 15min\n"
@brianjolly
brianjolly / letters_counter_spec.rb
Created March 9, 2012 05:50
Number words letter counter
class LettersCounter
def count word
word.gsub(/\s|-/, '').length
end
def sum_from_list words
lengths = words.map { |word| count word }
lengths.inject(:+)
end
end
@brianjolly
brianjolly / gist:1378120
Last active September 28, 2015 03:37
omniture sniffer
#!/usr/bin/env ruby
require 'uri'
require 'cgi'
require 'iconv'
require 'date'
require 'rubygems'
require 'colorize'
device = 'en3'
require 'nokogiri'
doc = Nokogiri::XML(File.open("deploy/data/BundleData.xml")) do |config| config.noblanks end
puts "Default Price:"
doc.xpath("//DefaultPrice/Choice").each { |p| puts "id: #{p['id']} price: #{p.content}" }
puts "ExistingCustPrice Price:"
doc.xpath("//ExistingCustPrice/Choice").each { |p| puts "id: #{p['id']} price: #{p.content}" }
@brianjolly
brianjolly / binary
Created August 22, 2011 21:42
Print 0-50 in binary
for (i=0; i<51; i++) { console.log(i+"\t"+i.toString(2)); }
# Built-in python HTTP Server
python -m SimpleHTTPServer 8888
@brianjolly
brianjolly / vagrant.org
Created July 18, 2011 22:01 — forked from zellyn/vagrant.org
Setting up a CentOS 5.4 base box for Vagrant