Skip to content

Instantly share code, notes, and snippets.

@dehora
dehora / gist:7785510
Last active December 30, 2015 05:49
use grep a b for context
# app id then 500
grep "app_id" error.log | grep "500"
# show some context around the pattern
grep -B 2 -A 10 "FATAL" log.txt
# unique ips for an app_id
grep 'app_id' access.log | cut -d' ' -f1 | sort | uniq
find . | grep "snaps"
find . | grep "*.rb" | grep ..
grep -r require . | less -s # js minify
@dehora
dehora / .pryrc
Created October 24, 2013 12:23
render unicode escapes in pry
Pry.hooks.add_hook :after_read, :hack_utf8 do |str, _|
str.force_encoding('utf-8')
end
public void removeJsonProcessingExceptionMapper(Environment environment) {
Set<Object> singletons = environment.getJerseyResourceConfig().getSingletons();
List<Object> singletonsToRemove = Lists.newArrayList();
for (Object s : singletons) {
if (JsonProcessingExceptionMapper.class.isAssignableFrom(s.getClass())) {
singletonsToRemove.add(s);
}
}
for (Object s : singletonsToRemove) {
singletons.remove(s);
@dehora
dehora / clip.js
Last active December 20, 2015 03:09
clip a page using phantomjs
var page = require('webpage').create();
var system = require('system');
if (system.args.length === 1) {
console.log('Usage: clip.js <url>');
phantom.exit(1);
} else {
address = system.args[1];
page.open(address, function () {
var title = page.evaluate(function () {
@dehora
dehora / disapprove.scala
Last active May 16, 2016 09:24
object ಠ_ಠ
object ಠ_ಠ {
class ಠ_ಠ(m: String) extends Exception(m)
def main(a: Array[String]) = {
throw new ಠ_ಠ("ಠ_ಠ")
}
}
@dehora
dehora / zk_collectd.sh
Created March 16, 2013 20:22
As spotted on the zookeeper-user list from Matt Wise <matt@nextdoor.com>
#!/bin/bash
# Defaults
PORT=2181
HOSTNAME="${COLLECTD_HOSTNAME:-localhost}"
INTERVAL="${COLLECTD_INTERVAL:-5}"
# Generic function for putting a value out there
put_gauge() {
NAME=$1
@dehora
dehora / kafka-server-start
Created February 15, 2013 17:07
non demonised kafka for supervisors
#!/bin/bash
SCALA_VERSION="2.9.2"
desc="Kafka (kafka-server)"
if [ -f /etc/sysconfig/kafka ]; then
. /etc/sysconfig/kafka
fi
$ tree ~/Downloads/elasticsearch-0.20.4
/Users/dehora/Downloads/elasticsearch-0.20.4
├── LICENSE.txt
├── NOTICE.txt
├── README.textile
├── bin
│   ├── elasticsearch
│   ├── elasticsearch.in.sh
│   └── plugin

├── config

@dehora
dehora / brew-scala-2.8.0.sh
Last active December 11, 2015 07:09
Install Scala 2.8.0 via brew
#!/bin/sh
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0