Skip to content

Instantly share code, notes, and snippets.

View reedho's full-sized avatar

Muhammad Ridho reedho

View GitHub Profile
# derived from:
# https://github.com/mike01/pypacker/blob/master/examples/examples.py
from pypacker import ppcap
from pypacker.layer12 import ethernet
from pypacker.layer3 import ip, icmp, ip6
from pypacker.layer4 import udp, tcp
with open("/tmp/test.cap", mode='rb') as f:
pcap = ppcap.Reader(f)
@reedho
reedho / clj-net-pcap basic demo
Created March 21, 2015 01:22
Reading & parsing pcap file with Clojure clj-net-pcap
(ns pcap.core
(:require
[clj-net-pcap.core :as pcore]
[taoensso.timbre :as timbre])
(:import
org.jnetpcap.packet.PcapPacket
org.jnetpcap.protocol.JProtocol
[org.jnetpcap.protocol.lan
Ethernet]
[org.jnetpcap.protocol.network
@reedho
reedho / user.clj
Last active September 27, 2018 04:19
Clojure Ring Basic, Etcetera...
;; Ring handler is just, just plain old function
(defn always-ok-handler [request]
"OK")
;; Attach one single handler per http-server instance
;; This http-server will always response with "OK" no matter what
;; request it was given.
@reedho
reedho / om-tutorial.core.cljs
Created February 17, 2016 03:58
Om Next - Master Detail props reads
;; Demonstrating how to deliver props from Root to 3rd level children with om.next
;; [Root] 1---M [Org] 1---M [Group] 1---M [User]
(ns om-tutorial.core
(:require [goog.dom :as gdom]
[om.next :as om :refer-macros [defui]]
[om.dom :as dom]
[cljs.pprint :refer [pprint]]))
(enable-console-print!)
@reedho
reedho / om-next-know-how.md
Last active February 17, 2016 09:04
Om Next -- The Basic we need to know
  • In the root component render, the props (which we can get with (om/props this)) is result of (parser {:state db} query). db is the result of normalization process of our initdata.

  • Delivering root component props to sub component is left to us, no automatic procession that is done by om/add-root!, e.g. no parser involvment, normalization, etc.

  • Thinks that normalization process is only matters to simplify change/update process.

@reedho
reedho / clojure101.clj
Created July 26, 2016 03:06
Clojure 101
;; Add dependencies live on lein repl
;; ------------------------------
; in project.clj, add to dependencies vector: [com.cemerick/pomegranate "0.3.0"]
[com.cemerick/pomegranate "0.3.1"]
; example adding deps via repl
(cemerick.pomegranate/add-dependencies
:coordinates '[[midje "1.8.2"]]
:repositories (merge cemerick.pomegranate.aether/maven-central
@reedho
reedho / openstack-ip-source-check.txt
Created August 10, 2016 03:33
Regarding how to disable source-check ala AWS instance on openstack
Asked and answered here:
https://ask.openstack.org/en/question/51392/neutron-openvswitch-port-how-to-disable-source-ip-address-checking/
In short, there are "allowed-address-pairs" that can alternatively used to solve such a problem.
Some scenario like:
- An instance has two ports in two different subnet, one belong in e.g. 10.1.1.123 (eth0)
and the other one in 10.1.2.223 (eth1).
@reedho
reedho / .babelrc
Created August 31, 2016 07:36
Debugging node app for human
{
"plugins": ["transform-es2015-destructuring",
"transform-object-rest-spread"],
"presets": ["es2015"]
}
@reedho
reedho / context-demo-2.js
Last active September 2, 2016 07:33
React Context
/*
This is the equivalent minimal demo of the above using ES6 class to define React component
*/
// Parent
class Parent extends React.Component {
@reedho
reedho / user.clj
Last active November 3, 2017 10:42
Converting tiff image to png with jai-imageio
;; Why?
;; Because tiff2png fail with warnings & error like below:
;; TIFFReadDirectory: Warning, Unknown field with tag 37724 (0x935c) encountered.
;; TIFFFetchNormalTag: Warning, Incompatible type for "RichTIFFIPTC"; tag ignored.
;; tiff2png error: don't know how to handle PHOTOMETRIC_SEPARATED (001.tif)
;; Below are somewwat dirty way to do conversion with JAI classes