Skip to content

Instantly share code, notes, and snippets.

View newnewcoder's full-sized avatar
🐌
On vacation

newnewcoder newnewcoder

🐌
On vacation
  • Taiwan Taipei
View GitHub Profile
@newnewcoder
newnewcoder / centos_firewall.sh
Created January 10, 2023 02:41 — forked from mortenbra/centos_firewall.sh
Basic firewall (iptables) script for CentOS with openings for SSH, HTTP and HTTPS
#!/bin/bash
# see http://oracle-base.com/articles/linux/linux-firewall.php
# Set the default policies to allow everything while we set up new rules
# Prevents cutting yourself off when running from remote SSH
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
@newnewcoder
newnewcoder / SSLPoke.java
Created February 9, 2022 04:53 — forked from MatthewJDavis/SSLPoke.java
Java SSL poke from atlassian
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import java.io.*;
/** Establish a SSL connection to a host and port, writes a byte and
* prints the response. See
* http://confluence.atlassian.com/display/JIRA/Connecting+to+SSL+services
*/
public class SSLPoke {
public static void main(String[] args) {
@newnewcoder
newnewcoder / stream_to_youtube.sh
Created June 4, 2020 07:08 — forked from olasd/stream_to_youtube.sh
Stream video to youtube via ffmpeg
#! /bin/bash
#
# Diffusion youtube avec ffmpeg
# Configurer youtube avec une résolution 720p. La vidéo n'est pas scalée.
VBR="2500k" # Bitrate de la vidéo en sortie
FPS="30" # FPS de la vidéo en sortie
QUAL="medium" # Preset de qualité FFMPEG
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" # URL de base RTMP youtube

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@newnewcoder
newnewcoder / tmux-cheatsheet.markdown
Created May 15, 2020 02:12 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@newnewcoder
newnewcoder / httpd.py
Created April 12, 2020 03:23 — forked from daimatz/httpd.py
SimpleHTTPServer with custom headers
#!/usr/bin/env python
import SimpleHTTPServer
import BaseHTTPServer
import sys
"""
Usage:
python httpd.py [port] [additional headers ...]
find $(pwd) -name "*.sql" -type f -mtime +30 -exec rm -f {} \;
<!DOCTYPE html>
<html>
<body>
<div id="container"></div>
<script>
var node1 = document.createElement("p");
var txt1 = document.createTextNode("This is 1 ");
node1.appendChild(txt1);
@newnewcoder
newnewcoder / ipython_notebook_in_git.md
Created January 16, 2019 07:03 — forked from pbugnion/ ipython_notebook_in_git.md
Keeping IPython notebooks under Git version control

This gist lets you keep IPython notebooks in git repositories. It tells git to ignore prompt numbers and program outputs when checking that a file has changed.

To use the script, follow the instructions given in the script's docstring.

For further details, read this blogpost.

The procedure outlined here is inspired by this answer on Stack Overflow.

@newnewcoder
newnewcoder / learn_simple_lru.md
Created December 9, 2018 09:28
learn simple LRU

LRU Cache 學習

LRU是在一個有限大小的快取空間,保持最近使用過的資料的一種快取機制,可以透過getter、setter方法搭配一個有序字典物件來實現

import collections


class LRUCache(object):
 """ Simple LRU Cache