Skip to content

Instantly share code, notes, and snippets.

View chuajiesheng's full-sized avatar
🙈

Chua Jie Sheng chuajiesheng

🙈
  • Singapore
View GitHub Profile
@chuajiesheng
chuajiesheng / break.py
Created June 27, 2022 05:56 — forked from obfusk/break.py
python "breakpoint" (more or less equivalent to ruby's binding.pry); for a proper debugger, use https://docs.python.org/3/library/pdb.html
import code; code.interact(local=dict(globals(), **locals()))
@chuajiesheng
chuajiesheng / port_forwarding.sh
Last active November 9, 2017 08:12
Forwarding Incoming Connections from host machine to VMs on KVM for Redhat (from http://wiki.libvirt.org/page/Networking#Forwarding_Incoming_Connections)
#!/bin/bash
# IMPORTANT: Change the "VM NAME" string to match your actual VM Name.
# In order to create rules to other VMs, just duplicate the below block and configure
# it accordingly.
if [ "${1}" = "VM NAME" ]; then
# Update the following variables to fit your setup
GUEST_IP=
GUEST_PORT=
def parts(str, current, elements):
if len(str) < 1:
return elements + [current]
if current == '' or current.startswith(str[0]):
return parts(str[1:], current + str[0], elements)
return parts(str[1:], str[0], elements + [current])
''.join(list(map(lambda x: x[0] + str(len(x)), parts('aaabbcccddd', '', []))))
# simulate
final_tweets_ids = range(2682988)
# code
from numpy.random import RandomState
seed = 18092016
rand = RandomState(seed)
dev_tweets = rand.choice(final_tweets_ids, size=3000, replace=False)
assert len(set(dev_tweets)) == 3000
# Bourne Again SHell init file.
# This file is sourced whenever you invoke a non-login interactive bash.
# Please do not remove the following command,
# which sources the system-wide Bourne Again SHell init file.
if [ -f /usr/local/etc/bash.bashrc ]; then
source /usr/local/etc/bash.bashrc
fi
# Place your own commands below.

Keybase proof

I hereby claim:

  • I am chuajiesheng on github.
  • I am jschua (https://keybase.io/jschua) on keybase.
  • I have a public key whose fingerprint is 23F6 0F7E 8C95 D52A E6F6 94CC 30E4 E193 946F F49C

To claim this, I am signing this object: