Skip to content

Instantly share code, notes, and snippets.

@tuantm8
tuantm8 / get_hw_info.sh
Created December 2, 2016 06:37
Get CPU Model, Number of Network Interface, RAM size, Disks by bash shell
#!/bin/bash
echo "CPU: $(grep 'model name' /proc/cpuinfo | head -1 | awk -F: '{print $2}')"
echo "Network Interfaces: $(ls -d /sys/class/net/eth* | wc -l) port"
echo "RAM: $(grep MemTotal /proc/meminfo | awk -F: '{print $2}' | sed -e 's/^[[:space:]]*//')"
#echo "RAM: $(grep MemTotal /proc/meminfo | awk '{print $2}' | xargs -I {} echo "scale=4; {}/1024^2" | bc) GB"
echo "Total Disk: $(df -h | sed -n 2p | awk '{print $2}')"
echo "Number Disk: $(df -h | grep "/dev/" | wc -l)"
@tuantm8
tuantm8 / rabbitmq-server.monit
Created January 20, 2017 08:19
Monit configuration for rabbitmq-server
check process rabbitmq-server matching "/usr/lib/erlang/erts-6.2/bin/beam"
group rabbitmq
start program = "/etc/init.d/rabbitmq-server start"
stop program = "/etc/init.d/rabbitmq-server stop"
if failed port 5672 type tcp then restart
if 3 restarts within 3 cycles then timeout
@tuantm8
tuantm8 / fpt-ubuntu-sources.list
Created February 4, 2017 14:53
The sources.list of fpt telecom (Vietnam)
deb http://mirror-fpt-telecom.fpt.net/ubuntu/ yakkety main restricted
#
deb http://mirror-fpt-telecom.fpt.net/ubuntu/ yakkety-security main restricted
deb http://mirror-fpt-telecom.fpt.net/ubuntu/ yakkety-security universe
deb http://mirror-fpt-telecom.fpt.net/ubuntu/ yakkety-security multiverse
#
deb http://mirror-fpt-telecom.fpt.net/ubuntu/ yakkety-proposed main restricted
deb http://mirror-fpt-telecom.fpt.net/ubuntu/ yakkety-proposed universe
deb http://mirror-fpt-telecom.fpt.net/ubuntu/ yakkety-proposed multiverse
#
@tuantm8
tuantm8 / split-file-cli.vbs
Last active February 22, 2017 02:56
CmdLine: {this-script} {path to big file} {size in MB} {output}. To use with cli: cscript {this-script} {path to big file} {size in KB} {output}
'--------------------------------
' Split a file into smaller chunks
' Last Update: 20161130
' CmdLine: {this-script} {path to big file} {size in KB} {output}
'--------------------------------
LF = Chr(10)
Dim oFSO, FullName, Path, Name, Size, TargetDir
Set oFSO = CreateObject("Scripting.FileSystemObject")
'Set stdout = oFSO.GetStandardStream (1)
Using Windows Installer
Windows Installer Features
Python 2.5 is distributed as a Microsoft Installer (MSI) file on Windows. Typically, packages are installed by double-clicking them in the file explorer. However, with the msiexec.exe command line utility, additional features are available, like non-interactive installation and administrative installation.
Non-interactive Installation
With the command line
msiexec /i python<version>.msi
installation can be initiated programmatically. Additional parameters can be passed at the end of this command line, like
msiexec /i python-2.5.msi TARGETDIR=r:\python25
Limited user interface
@tuantm8
tuantm8 / create_cron.sh
Last active March 30, 2017 02:57
Create crontab without duplicate (bash shell)
#!/bin/bash
#
#
#
function create_cron(){
new_entry="$1"
if ! crontab -l | fgrep -q "$new_entry"; then
TMP_CRON="/tmp/allcrons"
#write out current crontab
@tuantm8
tuantm8 / gist:547d6fb87eca894a0c6be4c35c33fc57
Last active April 4, 2017 17:24
References for interview
https://news.ycombinator.com/item?id=13823979
https://github.com/donnemartin/system-design-primer
https://github.com/donnemartin/interactive-coding-challenges
@tuantm8
tuantm8 / coin_change.py
Created May 6, 2017 23:54
Coin Change Problem hackerrank
def getWays(n, c):
# Complete this function
m = len(c)
# table will contains "cache"
# table[i, j] ~ change number i by first j coins (coins array should be sorted firstly)
table = [ [0 for j in range(m)] for i in range(n + 1) ]
for i in range(n+1):
for j in range(m):
if i == 0:
@tuantm8
tuantm8 / ctci_ransom_note.py
Created June 13, 2017 07:55
Hackerrank Crack the coding interview Ransom note
def ransom_note(magazine, ransom):
if len(magazine) < len(ransom):
return False
dict_magazine = dict()
dict_ransom = dict()
for word in magazine:
if word not in dict_magazine:
dict_magazine[word] = 1
@tuantm8
tuantm8 / Security Onion installation
Created August 9, 2017 10:08 — forked from cleesmith/Security Onion installation
Security Onion installation in a virtualbox
Security Onion
Aug 2014:
... my purpose for installing this was to:
- learn more about security stuff
- steal the packet captures (pcap) provided so I can replay them using tcpreplay for snort testing,
as it's not so sexy to just test using ICMP ping data or local rules that match anything
see:
http://blog.securityonion.net/