Skip to content

Instantly share code, notes, and snippets.

@sssgun
sssgun / web-servers.md
Created February 14, 2022 07:13 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@sssgun
sssgun / mapread.c
Created May 18, 2018 02:47 — forked from marcetcheverry/mapread.c
mmap and read/write string to file
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
int main(int argc, const char *argv[])
{
@sssgun
sssgun / .bashrc
Created April 5, 2018 03:17
bash utils example
# SET Operations (by ssgun)
## extract file
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 && cd $(basename "$1" .tar.bz2) ;;
*.tar.gz) tar xvzf $1 && cd $(basename "$1" .tar.gz) ;;
*.tar.xz) tar Jxvf $1 && cd $(basename "$1" .tar.xz) ;;
*.bz2) bunzip2 $1 && cd $(basename "$1" /bz2) ;;
*.rar) unrar x $1 && cd $(basename "$1" .rar) ;;
@sssgun
sssgun / bit_test01.go
Created March 30, 2018 02:52
go bit operation example
package main
import (
"fmt"
"reflect"
"github.com/Comcast/gaad/bitreader"
)
func TestReadBit1() {
@sssgun
sssgun / shift.c
Created March 29, 2018 07:16
shift operation example
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
@sssgun
sssgun / unroll_memcpy.c
Created March 29, 2018 07:12
unrolling memcpy example
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
@sssgun
sssgun / sqrt_test.c
Created March 29, 2018 07:08
Compute square root example
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
@sssgun
sssgun / main_futex.c
Created March 29, 2018 07:05
futex test
#ifdef __cplusplus
extern "C" {
#endif
struct simplefu_semaphore {
int avail;
int waiters;
};
typedef struct simplefu_semaphore *simplefu;