Skip to content

Instantly share code, notes, and snippets.

@riicchhaarrd
riicchhaarrd / select-all.el
Created March 26, 2022 18:10
emacs CTRL-A select all and cursor keys
(defun custom-select-all ()
(interactive)
;; (message "test %s" (key-description (string (read-event nil nil 2))))
(mark-whole-buffer)
(setq tmp (read-event nil nil 0.3))
(if tmp
(progn
(when (string= "left" tmp)
(deactivate-mark)
)
iptables -t nat -I PREROUTING -p tcp -d 1.2.3.4 --dport 80 -j DNAT --to-destination 10.0.0.1:80
iptables -t nat -I PREROUTING -p tcp -d 1.2.3.4 --dport 22 -j DNAT --to-destination 10.0.0.2:22
iptables -I FORWARD -m state -d 10.0.0.0/24 --state NEW,RELATED,ESTABLISHED -j ACCEPT
@riicchhaarrd
riicchhaarrd / .emacs
Last active June 17, 2022 08:13
emacs config
;; __ __ __ _ _ _
;; | \/ |_ _ ___ _ __ ___ __ _ ___ ___ ___ ___ _ __ / _(_) __ _ _ _ _ __ __ _| |_(_) ___ _ __
;; | |\/| | | | | / _ \ '_ ` _ \ / _` |/ __/ __| / __/ _ \| '_ \| |_| |/ _` | | | | '__/ _` | __| |/ _ \| '_ \
;; | | | | |_| | | __/ | | | | | (_| | (__\__ \ | (_| (_) | | | | _| | (_| | |_| | | | (_| | |_| | (_) | | | |
;; |_| |_|\__, | \___|_| |_| |_|\__,_|\___|___/ \___\___/|_| |_|_| |_|\__, |\__,_|_| \__,_|\__|_|\___/|_| |_|
;; |___/ |___/
;;
;;-----------------------------------------------------------------------------------
;; Custom variables set by Emacs
;;-----------------------------------------------------------------------------------
@riicchhaarrd
riicchhaarrd / base64_decode.c
Last active January 29, 2022 13:25
decoding base64
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
typedef unsigned char u8;
static const char *base64_table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
int base64_lookup_character(int ch)
@riicchhaarrd
riicchhaarrd / sin.js
Created December 31, 2021 06:59
taylor expansion sin & factorial javascript
factorial = (x) =>
{
let total = 1;
for(let i = 1; i <= x; i+=2)
{
if(i + 1 > x)
total *= i;
else
total *= (i * (i + 1));
}
/*
Change the number between the parentheses after APP_ID to the game you want to idle.
Then run the program and when you're done idling press a key.
*/
//730 is the AppID for CSGO
//480 for Spacewar
#define APP_ID (730)
//Imported functions from libraries that are needed.
@riicchhaarrd
riicchhaarrd / to_float.c
Last active August 18, 2021 21:20
convert integer to single float IEEE 754
#include <stdio.h>
#include <stdlib.h>
int to_float( int number )
{
int flt = 0;
if ( number < 0 )
{
number = -number;
@riicchhaarrd
riicchhaarrd / flt.c
Last active August 18, 2021 21:50
c print single precision floating point IEEE 754 little endian
#include <stdio.h>
unsigned int u32pow( unsigned int x, unsigned int y )
{
if(y == 0)
return 1;
for ( unsigned int i = 1; i < y; ++i )
x += x;
return x;
}
@riicchhaarrd
riicchhaarrd / decimal.asm
Last active June 20, 2021 04:10
linux x86 nasm assembly print out decimal
global _start
BITS 32
section .data
string: db "Value is ", 0
newline_string: db 10, 0
section .text
strlen:
push ebp
mov ebp, esp
@riicchhaarrd
riicchhaarrd / document.txt
Created May 28, 2021 04:13
Example of a document using Org-mode
#+LaTeX_CLASS: article
#+LATEX_HEADER: \usepackage[superscript,biblabel]{cite}
#+TITLE: Example document
#+DESCRIPTION: Description
#+AUTHOR: Author
* Chapter 1
Example of a list: