Skip to content

Instantly share code, notes, and snippets.

Andrew Cholakian andrewvc

Block or report user

Report or block andrewvc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View wsl2net-fix.ps1
# Attempt to fix broken network in WSL2.0
$guest_ip = bash -c "/sbin/ifconfig eth0 | egrep -o 'inet [0-9\.]+' | cut -d ' ' -f2"
Write-Output "Guest IP IS: $guest_ip"
$gateway_ips = Get-NetIPAddress -InterfaceAlias "vEthernet (WSL)" | select IPAddress
$gateway_ip = $gateway_ips[1].IPAddress
Write-Output "Gateway (local WSL adapter) IP is: $gateway_ip"
bash -c "sudo ifconfig eth0 netmask 255.255.240.0"
bash -c "sudo ip route add default via $gateway_ip"
@andrewvc
andrewvc / count-clj-sloc.sh
Created Jul 23, 2012
Counting SLOC in clojure is pretty easy since the syntax is so simple.
View count-clj-sloc.sh
# Count SLOC
export SLF=`mktemp -t cljsloc`; find src test -name "*.clj" | xargs egrep -v "(^[[:space:]]*$|^[[:space:]]*;)" | cut -d: -f1 > $SLF && echo "Files"; uniq -c $SLF; echo "Total" `cat $SLF | wc -l`; rm $SLF
@andrewvc
andrewvc / elasticsearch.conf
Created Oct 3, 2013
Upstart script for elasticsearch on ubuntu.... that actually works. Install the deb, and then run `sudo update-rc.d elasticsearch remove -f` to disable the init script.
View elasticsearch.conf
# ElasticSearch upstart script
description "ElasticSearch service"
start on (net-device-up
and local-filesystems
and runlevel [2345])
stop on runlevel [016]
@andrewvc
andrewvc / iptables_rules
Created May 13, 2010
Simple iptables rules presets
View iptables_rules
*filter
# Internal interfaces
-A INPUT -i lo -j ACCEPT
-A OUTPUT -o lo -j ACCEPT
#Allow all established traffic
-A INPUT -m state --state ESTABLISHED -j ACCEPT
#SSH
@andrewvc
andrewvc / elastic_search_crash_course.md
Last active Jun 6, 2018
Elastic Search Crash Course for LA Hacker News
View elastic_search_crash_course.md

#elasticsearch Crash Course!

By Andrew Cholakian

What is elasticsearch?

  1. A way to search... things
  2. A way to search your data in terms of natural language, and so much more
  3. A distributed version of lucene with a JSON API.
  4. A fancy clustered database
View gist:6b13148b3c94c2832afa7ef90955f5c7
filter {
ruby {
code => "io = StringIO.new(event.get('message')); enum = io.each_line; enum.next; event.set('mydate', enum.next); io.close"
}
}
View logstash-character-hack.conf
input { generator {} }
filter {
ruby {
# Add a \t (tab) by using its ASCII code (9)
code => 'event.set("message", 9.chr + event.get("message"))'
}
ruby {
# Make a new field with the tab removed
code => 'event.set("tabless", event.get("message").gsub(9.chr, ""))'
@andrewvc
andrewvc / jexec.rb
Last active Aug 8, 2017
JRuby method invocations from java performance tests
View jexec.rb
#!/usr/bin/env ruby
require './logstash-core/build/libs/logstash-core-6.0.0-beta1.jar'
ITERATIONS = 50_000_000
class InterfaceTest
include java.lang.Runnable
def initialize
@i = 1
end
View gist:aec2ad986eceb0af9196be59e80c9b24
* Batch block
* Exceptions on add_tag
View mini_filter.rb
define_filter :keymapper do
process do |event|
keys = event.get('[keys]')
vals = event.get('[vals]')
next unless keys && vals && !keys.empty? && !vals.empty?
keys.each.with_index do |key,i|
event.set(key, vals[i])
end
You can’t perform that action at this time.