Generate asymmetric key using the command below:
cd ~/.ssh
ssh-keygen -t rsa
#!/usr/bin/sh | |
watch -n 0.1 "date +\"%d-%m-%Y %H:%M:%S.%9N\"" |
#!/bin/sh | |
threshold=10 # threshold percentage to trigger alert | |
while :; do | |
capacity=$(cat /sys/class/power_supply/BAT1/capacity) | |
# If battery is discharging with capacity below threshold | |
if [ "${capacity}" -lt ${threshold} ];then | |
# Send a notification that appears for 300000 ms (5 min) |
const socket = new WebSocket("ws://localhost:8080") | |
socket.onopen = function (e) { | |
alert('[open] connection established') | |
alert('sending data to server') | |
socket.send('My name is who am i?'); | |
} | |
socket.onmessage = function (ev) { | |
alert(`[message] data received from srv: ${ev.data}`); |
# Transparent SOCKS proxy | |
# See: http://darkk.net.ru/redsocks/ | |
*nat | |
:PREROUTING ACCEPT [0:0] | |
:INPUT ACCEPT [0:0] | |
:OUTPUT ACCEPT [0:0] | |
:POSTROUTING ACCEPT [0:0] | |
:REDSOCKS - [0:0] |
// sorting alphabet | |
// reference: https://stackoverflow.com/a/64693036/22382954 | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
int main(void) | |
{ | |
srand(time(NULL)); |
const net = require('node:net'); | |
function keepAlive(ephPort, intervalId) { | |
const socket = new net.Socket(); | |
socket.setTimeout(1000); | |
socket.connect(port, process.env.GWROK_IP, () => socket.destroy()); | |
// stop the interval, indicate either the gwrok server no longer accept request | |
// or just bad internet connection and should retry if this is the case. | |
// for now we not perform retry, just stop the interval. | |
socket.on('timeout', () => { |
#!/bin/bash | |
# used for checking grammar, it uses Internal Field Separator | |
# related link: https://stackoverflow.com/questions/454427/string-difference-in-bash | |
# todo: figuring out a better algorithm than checking word by word in a linear fashion | |
# Function to compare two words | |
compare_words() { | |
local word1="$1" | |
local word2="$2" | |
if [[ "$word1" != "$word2" ]]; then |
#include <stdio.h> | |
int main(void) { | |
char buf[10]; | |
fread(buf, 1, 10, stdin); | |
fwrite(buf, 1, 10, stdout); | |
return 0; | |
} |