Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@astroza
astroza / sniffer
Created March 20, 2015 20:44
FOTM sniffer
require 'packetfu'
include PacketFu
iface = ARGV[0] || "en1"
def sniff(iface)
cap = Capture.new(:iface => iface, :start => true)
cap.stream.each do |p|
pkt = Packet.parse p
if pkt.is_tcp?
require 'git'
require 'fileutils'
require 'yaml'
class Key < ActiveRecord::Base
def self.authorized_keys_content
Key.all.each.reduce('') do |ac, key|
ac << "#{key.public_key}\n"
end
end
@astroza
astroza / singleton.rb
Last active October 3, 2018 19:55
Nicer Ruby Singleton
class SingletonTest
def data
@data
end
def data=(n)
@data = n
end
@old_new_method = self.method(:new)
@astroza
astroza / inspector.rb
Created January 22, 2016 15:47
lib/inspector.rb
class Inspector
def inspect_objects_space
count = Hash.new(0)
ObjectSpace.each_object(Object) {|o| count[o.class] += 1 }
server = TCPSocket.new 'localhost', 51313
max = count.reduce do |a, v| a[1] > v[1] ? a : v end
server.puts max.to_s
server.close
end
end
@astroza
astroza / dj_inspector.rb
Created January 22, 2016 15:47
bin/dj_inspector.rb
#!/usr/bin/env ruby
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
Thread.start(TCPServer.new(51313)) do |server|
loop do
puts "listening"
client = server.accept
puts "new client"
while line = client.gets
var cp = require('child_process');
function *doKill(process, initial_delay)
{
yield process.kill('SIGTERM');
yield process.kill('SIGKILL');
}
function niceKill(process, onExit, initial_delay)
{
// fastroza (TM)
// Comments about https://mobile.twitter.com/lukaseder/status/867080556470730752
var js_behavior = false
function add(_x, _y) { // (x) + (b)
// Normalization to Number
var x = +_x
var y = +_y
if(!js_behavior)
// ==UserScript==
// @name Autoclip
// @namespace http://nedmedia.io
// @version 0.1
// @description try to take over the world!
// @author F
// @update https://gist.github.com/astroza/ff89cc940b33ad9319bf3ae8ae6da641/raw/17f3e11fda0f4c7831bc232870c4971165f9bf42/autoclip-wordpress.user.js
// @match http://*/wp/wp-admin/post.php?post=*
// @grant none
// ==/UserScript==
@astroza
astroza / check_frames.js
Created February 26, 2018 19:10
Tool to analyse segments
/* fastroza@ned.cl
*/
const spawn = require('child_process').spawn;
const frame_regex = /\[FRAME\]\n([\/\w=\n\.:\d\-_\s]*)\[\/FRAME\]\n/g;
const value_regex = /([\w_]*)=([\/\d\.\w_:]*)/g;
function digest_frame(str)
{
ret = {};
@astroza
astroza / deep_hash.rb
Created March 6, 2018 17:35
Deep hash
def index_path(deep_hash, path)
sp = path.split("/")
d = 0
while d < sp.length
hk = sp.slice(sp.length - d - 1, sp.length)
if deep_hash[d] == nil
deep_hash[d] = {}
end
l = deep_hash[d][hk]
if l == nil