Skip to content

Instantly share code, notes, and snippets.

View gzxultra's full-sized avatar
🍎
eating apple

Zhixiang gzxultra

🍎
eating apple
  • Seattle, WA
View GitHub Profile
@thongntit
thongntit / RawPacket.c
Last active March 12, 2019 19:18
Applet using raw socket to send and receive packet with ICMP protocal OUTPUT is packet in hexa format. Can print as %c to see data. IP header is 20bytes. ICMP header is 8bytes. The rest is data
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
#include <sys/socket.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <arpa/inet.h>
@cadl
cadl / atfield.py
Created May 24, 2018 06:30
atfield
# coding: utf-8
import functools
import time
from threading import local
from collections import deque
class ATFieldException(Exception):
pass
@jlblancoc
jlblancoc / Install_gcc7_ubuntu_16.04.md
Last active July 8, 2024 06:37
Installing gcc-7 & g++-7 in Ubuntu 16.04LTS Xenial

Run the following in the terminal:

Install the gcc-7 packages:

sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install g++-7 -y

Set it up so the symbolic links gcc, g++ point to the newer version:

@morefreeze
morefreeze / hql2csv.py
Created January 24, 2018 06:56
Convert hql to csv format
# coding: utf-8
from __future__ import print_function
import subprocess
import sys
import argparse
def main():
parser = argparse.ArgumentParser()
mut_group = parser.add_mutually_exclusive_group()
@kkweon
kkweon / minimax.py
Created January 28, 2017 22:12
Minimax Implementation
"""Implementation of Figure 5.2 in Artificial Intelligence: A Modern Approach
[MINIMAX Algorithm]
AIMA p.164 Ch.5 Adversarial Search
function Minimax(state) returns a value
if terminal-test(state):
return utility(state)
if player(state) == MAX:
return max( Minimax(RESULT(state, action)) for every action in Action(s) )
@binderclip
binderclip / check_if_file_utf_8.py
Created May 11, 2016 14:52
simple python script check if file utf-8 coding
import sys
def main():
if len(sys.argv) < 2:
print 'please enter file path'
file_path = sys.argv[1]
with open(file_path, 'r') as f:
s = f.read()
try:
#!/bin/bash
NAME="blxkill"
function listProcesses(){
ps -A -o pid,user,comm | awk 'NR>1'
}
function findPidByPort(){
lsof -i :${1} -s TCP:LISTEN | awk 'NR == 2 {print $2}'
@mskeving
mskeving / reverse.py
Created April 10, 2015 19:23
Reverse a list in python
# Note, these functions are only for reversing lists in Python.
# In Python, strings are immutable, meaning you can't change their value.
# In other languages, like Ruby, this would be possible.
# If you want to reverse a string, you can use .split(), but that
# returns a list of characters, which means you are no longer doing
# it in place. This gives you O(n) space complexity.
# O(n) space, because the new list could be arbitrarily large
# O(n) time to go through each item in list.
@FlorianWolters
FlorianWolters / CMakeLists.txt
Last active May 21, 2024 17:29
Add Boost C++ Libraries as a dependency with plain CMake
# Copyright (c) 2014-2023 Florian Wolters
# MIT License
cmake_minimum_required(VERSION 3.26.3)
project(
"hello_boost_with_cmake"
VERSION 2.0.0
LANGUAGES CXX)
@nightire
nightire / .vimrc
Last active May 25, 2022 03:14
Vim 基础配置
set nocompatible " use vim defaults
set t_RV= " http://bugs.debian.org/608242
" set runtimepath=$VIMRUNTIME " turn off user scripts, https://github.com/igrigorik/vimgolf/issues/129
syntax on " turn syntax highlighting on by default
filetype on " detect type of file
filetype indent on " load indent file for specific file type
set nobackup " do not keep a backup file
set novisualbell " turn off visual bell