Skip to content

Instantly share code, notes, and snippets.

View habedi's full-sized avatar
🪬

Hassan Abedi habedi

🪬
View GitHub Profile
@habedi
habedi / config.json
Created April 8, 2016 08:11 — forked from hasherezade/12c8c50e996240aaa42d593701d3cae2.json
Cerber ransomware config (1 April 2016) - from the payload: 12c8c50e996240aaa42d593701d3cae2
{
"blacklist": {
"countries": [
"am",
"az",
"by",
"ge",
"kg",
"kz",
"md",
@habedi
habedi / gist:0e0a66d1f7bcdfd35483c65739d3eaca
Created May 16, 2016 12:11 — forked from collina/gist:5521087
Blocking on Transfer with UDP on Arbitrary Ports in #Iran
root@nami:~# tcpdump -r random_traffic_port_8082_udp.pcap | head
reading from file random_traffic_port_8082_udp.pcap, link-type EN10MB (Ethernet)
19:40:58.250303 IP internationalhost.35447 > nami.8082: UDP, length 2048
19:40:58.250640 IP internationalhost.35447 > nami.8082: UDP, length 2048
19:40:58.251200 IP internationalhost.35447 > nami.8082: UDP, length 2048
19:40:58.251358 IP internationalhost.35447 > nami.8082: UDP, length 2048
19:40:58.251566 IP internationalhost.35447 > nami.8082: UDP, length 2048
19:40:58.252529 IP internationalhost.35447 > nami.8082: UDP, length 2048
19:40:58.252711 IP internationalhost.35447 > nami.8082: UDP, length 2048
19:40:58.252975 IP internationalhost.35447 > nami.8082: UDP, length 2048
@habedi
habedi / latency.txt
Created May 27, 2016 08:10 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@habedi
habedi / gist:3a9dd03cec22acaa2bef3e29f32b613e
Created May 29, 2016 08:56
git clone all remote branches locally
#!/bin/bash
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do
git branch --track ${branch#remotes/origin/} $branch
done
@habedi
habedi / simple_server.py
Created June 14, 2016 05:21 — forked from trungly/simple_server.py
A simple Python HTTP server that supports a GET that echoes some request data and a POST that reads a request body, parses it as JSON and reponses with part of the data
from BaseHTTPServer import BaseHTTPRequestHandler
import urlparse, json
class GetHandler(BaseHTTPRequestHandler):
def do_GET(self):
parsed_path = urlparse.urlparse(self.path)
message = '\n'.join([
'CLIENT VALUES:',
'client_address=%s (%s)' % (self.client_address,
(ns echo-server
(:import (java.net InetAddress DatagramPacket DatagramSocket)))
(def udp-server (ref nil))
(def port 12345)
(defn localhost [] (. InetAddress getLocalHost))
(defn message [text]
@habedi
habedi / soakee.rkt
Created June 30, 2016 19:49 — forked from tonyg/soakee.rkt
Soak-testing Racket's UDP
#lang racket
(require racket/udp)
(define count 0)
(define s (udp-open-socket #f #f))
(udp-bind! s #f 12346)
(define buffer (make-bytes 1024))
# coding=utf-8
"""
LICENSE http://www.apache.org/licenses/LICENSE-2.0
"""
import datetime
import sys
import time
import threading
import traceback
import SocketServer
@habedi
habedi / disk-usage.py
Created August 22, 2016 12:29
A python snippet to figure out disk usage
import os
from collections import namedtuple
disk_ntuple = namedtuple('partition', 'device mountpoint fstype')
usage_ntuple = namedtuple('usage', 'total used free percent')
def disk_partitions(all=False):
"""Return all mountd partitions as a nameduple.
If all == False return phyisical partitions only.
"""
@habedi
habedi / web-servers.md
Created November 11, 2016 16:50 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000