Skip to content

Instantly share code, notes, and snippets.

View yoonghm's full-sized avatar

Yoong Hor Meng yoonghm

  • Ngee Ann Polytechnic
  • Singapore
View GitHub Profile
@carstein
carstein / main.rs
Last active March 28, 2024 01:21
Example code in Rust using fork and ptrace
use nix::sys::ptrace;
use nix::sys::signal::Signal;
use nix::sys::wait::{WaitStatus, wait};
use nix::unistd::{fork, ForkResult, Pid};
use std::collections::HashMap;
use std::ffi::c_void;
use std::os::unix::process::CommandExt;
use std::process::{Command, exit};
@RuolinZheng08
RuolinZheng08 / backtracking_template.py
Last active June 6, 2024 22:47
[Algo] Backtracking Template & N-Queens Solution
def is_valid_state(state):
# check if it is a valid solution
return True
def get_candidates(state):
return []
def search(state, solutions):
if is_valid_state(state):
solutions.append(state.copy())
@petermcd
petermcd / logins.csv
Created February 10, 2019 12:14
A listy of credentials tried when I opened an SSH port to the internet for a week. in the format request ID, username, password, time/date of attempt, request coun try of origin, unique id representing the IP making the connection.
We can't make this file beautiful and searchable because it's too large.
id,username,password,when,country,host_id
21,admin,7ujMko0admin,2019-02-02 10:39:27,China,0
22,pi,jdd,2019-02-02 10:40:09,United Kingdom,1
23,pi,kkk,2019-02-02 10:40:11,United Kingdom,1
24,pi,lk,2019-02-02 10:40:13,United Kingdom,1
25,pi,kk',2019-02-02 10:40:16,United Kingdom,1
26,pi,kjj,2019-02-02 10:40:18,United Kingdom,1
27,pi,fds,2019-02-02 10:42:55,United Kingdom,1
28,pi,eee,2019-02-02 10:42:56,United Kingdom,1
29,pi,fds,2019-02-02 10:42:57,United Kingdom,1
@johncrossland
johncrossland / Sphinx_with_Markdown.rst
Created December 12, 2018 00:28
Sphinx with Markdown - How to use Markdown with Sphinx (including Markdown tables that Sphinx does not handle by default for PDF and HTML output)

Sphinx with Markdown walkthrough for HTML and PDF output

This walkthrough installs Sphinx and configures it to output HTML and PDF from .md. If you install it on a VM, allocate over 25GB storage and multiple processors. You'll need Ubuntu 16.04 LTS, an internet connection, and sudo rights.

import pandas as pd
# docs can be found at http://gspread.readthedocs.io/en/latest/
import gspread
from oauth2client.service_account import ServiceAccountCredentials
def get_googlesheet_worksheet(json_keyfile_name, sheet_name, worksheet_name):
scope = ['https://spreadsheets.google.com/feeds']
creds = ServiceAccountCredentials.from_json_keyfile_name(json_keyfile_name, scope)
@MMesch
MMesch / robust_splines_sklearn.py
Last active July 6, 2023 23:04
Robust Spline Regression with Scikit-Learn
#!/usr/bin/env python
"""
Robust B-Spline regression with scikit-learn
"""
import matplotlib.pyplot as plt
import numpy as np
import scipy.interpolate as si
from sklearn.base import TransformerMixin
from sklearn.pipeline import make_pipeline
@kracekumar
kracekumar / ws_app.py
Last active October 5, 2021 08:52
Simple websocket server with uvloop.
# -*- coding: utf-8 -*-
import asyncio
import uvloop
from aiohttp.web import Application, MsgType, WebSocketResponse
def add_socket(app, socket, user_id):
if user_id in app['connections']:
pass
@wrunk
wrunk / python_multiprocessing_pool_with_queues.py
Last active January 27, 2020 13:08
Python multiprocessing pool with queues
from multiprocessing.pool import ThreadPool as Pool
from multiprocessing import Queue as PQueue
import Queue
my_dict = {
'url1': 'url2',
'url3': 'url4',
}
my_q = PQueue()
@protrolium
protrolium / ffmpeg.md
Last active July 12, 2024 17:37
ffmpeg guide

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

You can get the list of installed codecs with:

@dupuy
dupuy / README.rst
Last active June 25, 2024 15:05
Common markup for Markdown and reStructuredText

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.