Skip to content

Instantly share code, notes, and snippets.

@pierric
pierric / reset-iptables.sh
Created February 15, 2018 14:41
reset iptables' rules.
iptables --policy INPUT ACCEPT;
iptables --policy OUTPUT ACCEPT;
iptables --policy FORWARD ACCEPT;
iptables -Z; # zero counters
iptables -F; # flush (delete) rules
iptables -X; # delete all extra chains
systemctl restart docker;
@pierric
pierric / foreign.chs
Last active February 14, 2018 16:38
An example of ForeignPtr with C2HS
module Foreign where
import Control.Monad
import Foreign.Marshal.Alloc
import Foreign.Storable
{#pointer NDArrayHandle foreign finalizer MXNDArrayFree as mxNDArrayFree newtype #}
--
-- Note that, peek take actually a ptr to ptr, where the inner is exactly the foreignptr, while the outter is
@pierric
pierric / BM.ipynb
Created November 5, 2017 13:29
Boltzmann Machine and Ristricted Boltzmann Machine
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pierric
pierric / simple-nn.ipynb
Last active October 7, 2017 20:32
Some math derivation of a simple neural network
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pierric
pierric / averaging methods.ipynb
Last active September 30, 2017 19:02
A comparison of various averaging methods
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pierric
pierric / GrowLogicalVolume.md
Last active September 25, 2017 13:41
A online method to extend the VM disk
  • VBoxmanage modifyhd MyLinux.vdi --resize 200000 resize the disk to 200G

  • in VM, parted, print free

  Number  Start   End     Size    Type     File system  Flags
        32.3kB  1049kB  1016kB           Free Space
 1      1049kB  1075MB  1074MB  primary  xfs          boot
 2      1075MB  ...GB    30GB   primary               lvm
 .      ......  .....   179GB            Free Space
@pierric
pierric / Structured Streaming.ipynb
Last active September 21, 2017 15:47
A random numbers generating server. It can be used as the source for playing with Spark Stream
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pierric
pierric / mxnet-ops.c
Created September 21, 2017 15:40
List Op information in the MXNet
#include "mxnet/c_api.h"
#include "nnvm/c_api.h"
#include <stdio.h>
int cnt;
char **buffer;
int main() {
int rc;
rc = MXListAllOpNames(&cnt, &buffer);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pierric
pierric / jq_insert.sh
Created September 4, 2017 10:47
Use jq to insert an new field in json
CONF=$ZEPPELIN_HOME/conf/interpreter.json
ICMD=$(echo '.interpreterSettings |= with_entries(if .value.name == "spark" then .value.properties = .value.properties + {"spark.driver.host":"'$1'"} else . end)')
jq "$ICMD" $CONF | sponge $CONF