Skip to content

Instantly share code, notes, and snippets.

@khoan
khoan / gc_runs.txt
Last active November 6, 2017 04:09
profile earnings.json
Measure Mode: gc_runs
Thread ID: 70135302060020
Fiber ID: 70135306430860
Total: 7.000000
Sort by: self_time
%self total self wait child calls name
42.86 3.000 3.000 0.000 0.000 20496 String#slice!
42.86 3.000 3.000 0.000 0.000 5035 JSON::Ext::Parser#parse
14.29 1.000 1.000 0.000 0.000 514 *Kernel#loop
{"values":[{"x":1483231012000,"y":0.08938},{"x":1483317379000,"y":0.09095},{"x":1483403862000,"y":0.08631},{"x":1483490305000,"y":0.08423},{"x":1483576825000,"y":0.0848},{"x":1483663485000,"y":0.08723},{"x":1483749849000,"y":0.08528},{"x":1483836294000,"y":0.07289},{"x":1483922669000,"y":0.07739},{"x":1484009008000,"y":0.06651},{"x":1484095303000,"y":0.05865},{"x":1484181856000,"y":0.05024},{"x":1484268188000,"y":0.04546},{"x":1484354712000,"y":0.04551},{"x":1484440796000,"y":0.04409},{"x":1484527103000,"y":0.04286},{"x":1484613407000,"y":0.04107},{"x":1484699897000,"y":0.03773},{"x":1484786197000,"y":0.03723},{"x":1484872672000,"y":0.03844},{"x":1484959006000,"y":0.03874},{"x":1485045413000,"y":0.03582},{"x":1485131818000,"y":0.03339},{"x":1485218159000,"y":0.03195},{"x":1485304828000,"y":0.03254},{"x":1485391218000,"y":0.03726},{"x":1485477600000,"y":0.03769},{"x":1485563986000,"y":0.03685},{"x":1485650172000,"y":0.03506},{"x":1485736543000,"y":0.03311},{"x":1485822916000,"y":0.03177},{"x":1485909303000,"y"
@khoan
khoan / gist:5740d7ad08beb87641b5b2fc6320cc7a
Created September 11, 2017 12:05
mongoDB compromised
$ ssh abc@abc.com
(stage) $ mongo
> show dbs
DATA_HAS_BEEN_BACKED_UP 0.078GB
admin (empty)
bam 0.953GB
> use DATA_HAS_BEEN_BACKED_UP
> db.getCollectionNames()
[ "README_PLS", "system.indexes" ]
> db.README_PLS.find()
@khoan
khoan / parent-child-filter-aggregation-query
Last active February 22, 2017 05:32
http://localhost:5601/app/sense
POST bam
{
"mappings": {
"events": {
"_parent": {
"type": "users"
},
"properties": {
"created_at": {
"type": "date",
@khoan
khoan / url_for_patch.rb
Created April 21, 2016 06:24
forcing name route helpers to add trailing slash
# config/initializers/url_for_patch.rb
module ActionDispatch::Http::URL
class << self
alias_method :original_url_for, :url_for
def url_for options={}
options[:trailing_slash] = true
original_url_for options
end
[2015-12-10T00:44:07+00:00] INFO: AWS OpsWorks instance , Agent version 4004-20151203081517
[2015-12-10T00:44:08+00:00] INFO: Started chef-zero at chefzero://localhost:8889 with repository at /opt/aws/opsworks/current
One version per cookbook
data_bags at /var/lib/aws/opsworks/data.internal/data_bags
nodes at /var/lib/aws/opsworks/data.internal/nodes
[2015-12-10T00:44:08+00:00] INFO: Forking chef instance to converge...
[2015-12-10T00:44:08+00:00] INFO: *** Chef 12.4.1 ***
[2015-12-10T00:44:08+00:00] INFO: Chef-client pid: 1177
[2015-12-10T00:44:09+00:00] INFO: HTTP Request Returned 404 Not Found: Object not found: chefzero://localhost:8889/nodes/croissant.localdomain
$ cat ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>homebrew.mxcl.elasticsearch</string>
<key>ProgramArguments</key>
@khoan
khoan / smc fan control
Last active August 29, 2015 14:24
start smc fan control for all users
$ cat /Library/LaunchAgents/com.maxfanadjustment.smcfancontrol
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.smcFanControl</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/smcfancontrol.app/Contents/Resources/smc</string>