Skip to content

Instantly share code, notes, and snippets.

View clstokes's full-sized avatar
☁️

Cameron Stokes clstokes

☁️
View GitHub Profile
@clstokes
clstokes / slideshow-javascript.html
Created January 23, 2011 15:51
A solution to the JavaScript problem posed in observation 3 at http://bit.ly/gCmjbR.
<!doctype html>
<head>
<meta charset="utf-8">
<title></title>
</head>
require 'fileutils'
require 'date'
require 'yaml'
require 'rexml/document'
include REXML
doc = Document.new File.new(ARGV[0])
FileUtils.mkdir_p "_posts"
@clstokes
clstokes / vmstat
Created December 8, 2011 00:22
'vmstat -S' from a Solaris 10 machine
kthr memory page disk faults cpu
r b w swap free si so pi po fr de sr m1 m1 m1 m1 in sy cs us sy id
1 0 67 11686688 245176 0 0 1377 3902 3945 1336 8082 0 116 1 15 5827 72630 5721 18 5 78
0 1 67 11684856 220736 0 0 3531 5677 6796 536 24106 2 265 0 2 4390 4206 4743 14 4 82
0 3 67 11686680 228288 0 0 3044 8739 9184 0 17463 2 258 0 1 3805 2725 3550 10 3 87
0 3 67 11686680 241976 0 0 2856 9523 9674 0 8885 7 252 0 1 4064 2857 3630 10 3 87
0 5 67 11686680 244720 0 0 3637 5867 5867 0 7819 4 275 1 0 3563 2097 3229 7 2 91
0 5 67 11684568 241688 0 0 2988 7204 7203 12040 13301 6 232 4 0 4698 24440 4145 14 5 81
0 5 67 11679848 240440 0 0 2925 6453 6371 14984 19331 9 265 3 6 4204 10337 3946 17 6 78
1 2 67 11658904 201352 0 0 2407 6960 8395 8864 42789 11 302 1 1 5045 37979 4538 56 7 37
@clstokes
clstokes / gist:1475022
Created December 14, 2011 02:46
Trying to normalize 'Nøgne Ø' to 'Nogne O'
groovy:000> java.text.Normalizer.normalize('Nøgne Ø', java.text.Normalizer.Form.NFD);
===> Nøgne ?o?
groovy:000> java.text.Normalizer.normalize('Nøgne Ø', java.text.Normalizer.Form.NFC);
===> Nøgne Ø
groovy:000> java.text.Normalizer.normalize('Nøgne Ø', java.text.Normalizer.Form.NFKD);
===> Nøgne ?o?
groovy:000> java.text.Normalizer.normalize('Nøgne Ø', java.text.Normalizer.Form.NFKC);
===> Nøgne Ø
groovy:000>
@clstokes
clstokes / tomcat7
Created September 25, 2012 21:06
Enable JMX in Tomcat 7 on Ubuntu
#
# Since I have to look this up every time...
#
# Add the following in /etc/default/tomcat7
#
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote"
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote.port=9991"
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote.ssl=false"
@clstokes
clstokes / logstash.log
Created October 1, 2012 18:38
Logstash - single log file
input {
file {
type => "akamai"
path => "/mnt/logs/processing/www_182149.esclf_U.201209270000-2400-0"
}
}
filter {
grok {
type => "akamai"
@clstokes
clstokes / gist:3821288
Created October 2, 2012 17:14
watchdog timeout
Skipping capture since it is not a named capture and named_captures_only is true. {"field":"MINUTE","level":"debug","file":"/opt/logstash/logstash-1.1.1-monolithic.jar!/logstash/filters/grok.rb","line":"210","method":"filter"}
Skipping capture since it is not a named capture and named_captures_only is true. {"field":"SECOND","level":"debug","file":"/opt/logstash/logstash-1.1.1-monolithic.jar!/logstash/filters/grok.rb","line":"210","method":"filter"}
Exception in thread "LogStash::Runner" Skipping capture since it is not a named capture and named_captures_only is true. {"field":"URIPATH","level":"debug","file":"/opt/logstash/logstash-1.1.1-monolithic.jar!/logstash/filters/grok.rb","line":"210","method":"filter"}
org.jruby.exceptions.RaiseException: (SystemExit) watchdog timeout
at org.jruby.RubyThread.join(org/jruby/RubyThread.java:509)
at Agent.wait(file:/opt/logstash/logstash-1.1.1-monolithic.jar!/logstash/agent.rb:326)
at logstash.runner.main(logstash/runner.rb:42)
at org.jruby.RubyArray.each(org/jruby/
@clstokes
clstokes / gist:3821723
Created October 2, 2012 17:57
source sequence is illegal/malformed utf-8
["Received new event", {:source=>"tcp://0.0.0.0:1556/client/127.0.0.1:38974", :event=>#<LogStash::Event:0x3b215c11 @data={"@source"=>"tcp://0.0.0.0:1556/client/127.0.0.1:38974", "@type"=>"akamai", "@tags"=>[], "@fields"=>{}, "@timestamp"=>"2012-10-02T17:50:51.812000Z", "@source_host"=>"0.0.0.0", "@source_path"=>"/client/127.0.0.1:38974", "@message"=>"12.53.117.198 - - [26/Sep/2012:23:22:52 +0000] \"GET /www.weather.com/ HTTP/1.1\" 200 96556 \"-\" \"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1\" \"-\"\n"}, @cancelled=false>}] {"level":"debug","file":"/opt/logstash/logstash-1.1.1-monolithic.jar!/logstash/inputs/base.rb","line":"129","method":"to_event"}
JSON::GeneratorError: source sequence is illegal/malformed utf-8
to_json at json/ext/GeneratorMethods.java:71
to_json at file:/opt/logstash/logstash-1.1.1-monolithic.jar!/logstash/event.rb:132
to_json at json/ext/GeneratorMethods.java:71
tty_write at file:/opt/log
@clstokes
clstokes / pom.xml
Created October 24, 2012 14:17 — forked from codahale/pom.xml
Basic maven pom for Java.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- none yet -->
@clstokes
clstokes / gist:4076802
Created November 15, 2012 05:26
md: auto-read-only?
[ec2-user@ip-10-252-77-244 ~]$ cat /proc/mdstat
Personalities : [raid10]
md127 : active (auto-read-only) raid10 xvdg[1] xvdh[2] xvdi[3] xvdf[0]
4192000 blocks super 1.2 128K chunks 2 near-copies [4/4] [UUUU]
unused devices: <none>
[ec2-user@ip-10-252-77-244 ~]$ sudo cp /mnt/ebs-vol1/test1 /mnt/ebs-vol1/test2
[ec2-user@ip-10-252-77-244 ~]$ cat /proc/mdstat
Personalities : [raid10]
md127 : active (auto-read-only) raid10 xvdg[1] xvdh[2] xvdi[3] xvdf[0]