Skip to content

Instantly share code, notes, and snippets.

View arashbm's full-sized avatar

Arash Badie-Modiri arashbm

View GitHub Profile
@arashbm
arashbm / README.markdown
Last active August 29, 2015 14:12
Heram (Pyramid Scheme)

Heram Simulator

This is a quick attempt to participate in Jadi's contest. If this gist doesn't make any sense to you, just ignore it :)

Usage example: ruby heram.rb 1 2 6 6 70_000_000 4 for instructions, run without arguments (ruby heram) or just read the source!

human readable results will be printed on STDERR, Comma Separated Value (CSV) format will be printed to STDOUT, so you can ruby heram.rb 1 2 6 6 70_000_000 4 > results.csv and maybe xdg-open results.csv to plot it with your program of choice :)

With Gnuplot installed you can do something like this: ruby heram.rb 1 2 6 6 70_000_000 4 | gnuplot "plot.gp" > test.png && xdg-open test.png to generate a plot with Gnuplot file (plot.gp) provided here.

@arashbm
arashbm / all.rb
Created July 18, 2012 05:00
Download all railscasts.com videos
require 'nokogiri'
require 'open-uri'
# Downloads all free railscasts.com screencasts in current directory
# just `ruby all.rb` and you're done
# if you want another format change it from m4v at the end of line 11
(202..360).each do |i|
puts i
doc = Nokogiri::HTML(open("http://railscasts.com/episodes/#{i}"))
doc.css('//a').each do |a|
@arashbm
arashbm / master.rb
Created October 14, 2012 09:39
MapReduce Concept With Ruby
# This is our given particle
given_particle = { :x => 0.0, :y => 0.0, :m => 1}
# Generating random data
particles = Array.new
50.times do
# rand is a function that generates random number between 0 and 1
x = (rand - 0.5) * 1000
y= (rand - 0.5) * 1000
require 'json'
JSON.parse(ARGF.read).map do |package, value|
package_name = package.split('@')[-2]
puts "\n"
if value["url"]
puts "[#{package_name}](#{value["url"]})"
puts "="*(package_name.length + value["url"].length + 4)
@arashbm
arashbm / keybase.md
Created February 2, 2018 10:54
Keybase new proof

Keybase proof

I hereby claim:

  • I am arashbm on github.
  • I am arashbm (https://keybase.io/arashbm) on keybase.
  • I have a public key ASBhL23mmknHxFNqG606hQ-wLozWyPVU0cTQgFKgwax6MAo

To claim this, I am signing this object:

@arashbm
arashbm / PCAP-JSON.md
Last active October 30, 2018 19:37
PCAP JSON Packet and Flows

Use these scripts to turn tshark JSON file (tshark -r blaah.pcap -T json > packets.json) to packet and flow csv files.

Usage

parse_pcap_json.py produces a space-seperated file with one packet per row.

python3 parse_pcap_json.py packets.json > packets.csv