Skip to content

Instantly share code, notes, and snippets.

View unique-EJ's full-sized avatar
😕
Status: I'm living, with psychological problems.

Edward Jho-nse unique-EJ

😕
Status: I'm living, with psychological problems.
View GitHub Profile
@unique-EJ
unique-EJ / bash-shell-init-snippets.sh
Last active March 10, 2025 17:44
Bash edit file, local file server commands (command interpreter shell initialization snippets).
#!/usr/bin/env bash
# Download: raw file is in https://gist.github.com/unique-EJ/64b2f43dfb5489a52a020114b374ffdc
# curl can download the URL.
# Usage: no options, puts command snippets into the Bash initialization file.
declare edit_file="$(cat <<"EOF"
# Edit a file. Line numbers - Meta key (Alt, Cmd, or Esc), N.
function edit_file () {
[[ ! -f "$1" || ! -w "$1" ]] && return 1;
@unique-EJ
unique-EJ / decimal-to-hexadecimal-command
Created December 27, 2024 20:27
Linux command-line to convert decimal values to hexadecimal.
# Linux command-line - AWK text processing language program.
awk $'BEGIN { print "Type decimal (input) values to have the converted hexadecimal value output. CTRL-d to end." }\n{ printf "%s%x\\n", "Hex: ", $0 }'
#!/bin/bash
# Send text to Android device using ADB, emulating keyboard input.
# Based on a script from https://android.stackexchange.com/a/105881/223695
# and extended to support special characters.
# CC BY-SA 3.0 - Share under same license, attribute the creator, indicate changes.
# From Matthijs Kooijman's answer, https://android.stackexchange.com/a/176590/359828
if [[ "$1" != "" ]]
then
TEXT="$1"
@unique-EJ
unique-EJ / Xserver.sh
Last active August 16, 2024 05:18
Start application, and X server, on a remote machine (SSH).
# Start application, and X server, on a remote machine (SSH).
# ". Xserver.sh [app name]", "pgrep [app name]"
if [ $# -ge 1 ]; then
app="$@" # The positional parameters (app).
session="startlxde-pi"
commands="\
cd /tmp/; mkfifo -m 607 .command;
env echo -e \"declare DISPLAY=:0; \$(which ${session}) &
${app}\" > .command &
@unique-EJ
unique-EJ / Crops.kt
Created November 17, 2021 17:15 — forked from codecademydev/Crops.kt
Codecademy export
fun main() {
var season = "!"
// Write your code below
when (season) {
"Winter" -> println("Grow kale.")
"Spring" -> println("Grow lettuce.")
"Summer" -> println("Grow corn.")
"Fall" -> println("Grow pumpkins.")
else -> println("Not a valid season.")
}