Skip to content

Instantly share code, notes, and snippets.

View 0x8f701's full-sized avatar
🎯
The internet is sick

CJ 0x8f701

🎯
The internet is sick
View GitHub Profile
@0x8f701
0x8f701 / quicksort.c
Created October 25, 2018 12:36 — forked from naezith/quicksort.c
Benchmark of Quicksort implementations
// You need to uncomment and comment some blocks in order to benchmark, it is not full automatic.
#include <sys/time.h>
#include <stdlib.h>
#include <stdio.h>
// Inputs
#define ARRAY_SIZE 1000
#define LOGS_ON 0
@0x8f701
0x8f701 / Git push deployment in 7 easy steps.md
Created October 28, 2018 17:57 — forked from thomasfr/Git push deployment in 7 easy steps.md
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
@0x8f701
0x8f701 / iptables.sh
Created October 28, 2018 18:03 — forked from thomasfr/iptables.sh
iptable rules to allow outgoing DNS lookups, outgoing icmp (ping) requests, outgoing connections to configured package servers, outgoing connections to all ips on port 22, all incoming connections to port 22, 80 and 443 and everything on localhost
#!/bin/bash
IPT="/sbin/iptables"
# Server IP
SERVER_IP="$(ip addr show eth0 | grep 'inet ' | cut -f2 | awk '{ print $2}')"
# Your DNS servers you use: cat /etc/resolv.conf
DNS_SERVER="8.8.4.4 8.8.8.8"
# Allow connections to this package servers
@0x8f701
0x8f701 / autossh.service
Created October 28, 2018 18:03 — forked from thomasfr/autossh.service
Systemd service for autossh
[Unit]
Description=Keeps a tunnel to 'remote.example.com' open
After=network.target
[Service]
User=autossh
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)
@0x8f701
0x8f701 / nginx.conf
Created October 28, 2018 18:04 — forked from thomasfr/nginx.conf
nginx vhost / site config file
upstream node_backend {
server 127.0.0.1:3000;
keepalive 32;
}
server {
root /var/www/testapp/public;
index index.html;
@0x8f701
0x8f701 / daemon.c
Created October 29, 2018 14:14 — forked from copyninja/daemon.c
A sample Daemon program in C
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#define RUNNING_DIR "/tmp"
#define LOCK_FILE "daemond.lock"
#define LOG_FILE "daemond.log"
# FoundationDB server
#
# Run this file, then on one machine run:
# $ sudo /usr/lib/foundationdb/make_public.py
#
# Copy /etc/foundationdb/fdb.cluster to each node and run:
# $ sudo service foundationdb restart
#
set -e
@0x8f701
0x8f701 / client.go
Created October 30, 2018 13:08 — forked from tj/client.go
package main
import "github.com/segmentio/rpc"
import "fmt"
type Args struct {
A int
B int
}
@0x8f701
0x8f701 / generate_big_primes.rs
Created October 30, 2018 22:53 — forked from jsanders/generate_big_primes.rs
Generate big primes in Rust. This works pretty fast now thanks to https://github.com/jsanders/rust-bignum and https://github.com/jsanders/rust-gmp! I'm still implementing my own mod_exp, but the performance is quite tolerable nonetheless.
extern crate bignum;
extern crate time;
use std::rand::task_rng;
use std::iter::{count,range_step_inclusive};
use std::num::{Zero,One};
use bignum::{BigUint,RandBigInt,ToBigUint};
// Find all prime numbers less than n
fn small_primes(bound: uint) -> ~[uint] {
//
// Copyright (c) 2014 Sean Farrell
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//