Skip to content

Instantly share code, notes, and snippets.

View marcotc's full-sized avatar

Marco Costa marcotc

View GitHub Profile
@marcotc
marcotc / GetClassLocation.scala
Created October 13, 2015 21:09
Get class location in Scala
val klass = classOf[java.lang.Object]
val loc = ClassLoader.getSystemClassLoader.getResource(klass.getName().replace('.', '/') + ".class").toString()
@marcotc
marcotc / rsync_over_ssh.sh
Last active February 3, 2016 17:25
rsync over ssh
rsync -azP -e ssh /path/to/local/file remoteuser@remotehost:/remote/dir/
@marcotc
marcotc / ssh_default_user.conf
Last active January 21, 2016 22:50
If you local user is different from you ssh user
Host *
User my_desired_user
#AUTHOR: MARK KHAITMAN
from datetime import datetime, timedelta
from urlparse import urlparse
from csv import reader
fields = ('timestamp','elb','ip','backend:port','req_pt','bpt',
'res_pt','elb_status','backend_status','rec_bytes','sent_bytes',
'req','ua','ssl_cipher','ssl_protocol')
INACTIVITY_WINDOW = 60
@marcotc
marcotc / wombat-mt.itermcolors
Last active April 14, 2016 21:11
Wombat iTerm2 colours, with brighter background
<?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>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.0</real>
<key>Green Component</key>
<real>0.0</real>
@marcotc
marcotc / jenkins.groovy
Created April 22, 2016 20:38
Delete builds older then N on Jenkins
MAX_BUILDS = 10
for (job in Jenkins.instance.items) {
println job.name
def recent = job.builds.limit(MAX_BUILDS)
for (build in job.builds) {
if (!recent.contains(build)) {
println "Preparing to delete: " + build
@marcotc
marcotc / active_record_stdout.rb
Created June 7, 2016 21:51
ActiveRecord to stdout
ActiveRecord::Base.logger = Logger.new(STDOUT)

Keybase proof

I hereby claim:

  • I am marcotc on github.
  • I am marcotc (https://keybase.io/marcotc) on keybase.
  • I have a public key whose fingerprint is 6B1F CA39 AC19 BE19 E647 2978 1A41 253C 9FF0 32BB

To claim this, I am signing this object:

@marcotc
marcotc / nbt_parser.yaml
Last active December 12, 2016 03:01
Parser for Named Binary Tag (NBT), in Kaitai format (http://kaitai.io/)
meta:
id: nbt
file-extension: nbt
endian: be
application: Named Binary Tag (NBT)
seq:
- id: tag_compound
type: tag_compound
types:
tag_byte:
@marcotc
marcotc / query.rb
Last active December 8, 2017 22:59
Run arbitrary query using ActiveRecord
ActiveRecord::Base.connection.exec_query("select * from TABLE")