Skip to content

Instantly share code, notes, and snippets.

@acook
acook / keypress.rb
Created December 2, 2012 18:42
Read keypresses from user in terminal, including arrow keys using pure Ruby. This has since been folded into a much more robust gem called Remedy. https://rubygems.org/gems/remedy & https://github.com/acook/remedy
require 'io/console'
# Reads keypresses from the user including 2 and 3 escape character sequences.
def read_char
STDIN.echo = false
STDIN.raw!
input = STDIN.getc.chr
if input == "\e" then
input << STDIN.read_nonblock(3) rescue nil
@bcap
bcap / terminal-control.sh
Last active July 31, 2024 17:48
Useful terminal control characters
# Terminal output control (http://www.termsys.demon.co.uk/vtansi.htm)
TC='\e['
CLR_LINE_START="${TC}1K"
CLR_LINE_END="${TC}K"
CLR_LINE="${TC}2K"
# Hope no terminal is greater than 1k columns
RESET_LINE="${CLR_LINE}${TC}1000D"
@jonschlinkert
jonschlinkert / markdown-cheatsheet.md
Last active April 23, 2025 17:58
A better markdown cheatsheet.
@chrisn
chrisn / popen3_test
Last active March 2, 2023 08:48
Ruby example of using Open3.popen3 with a select loop to read a child process's standard output and standard error streams.
#!/usr/bin/env ruby
require 'open3'
# Returns true if all files are EOF
#
def all_eof(files)
files.find { |f| !f.eof }.nil?
end
@ndarville
ndarville / webm.md
Last active March 11, 2025 17:21
4chan’s guide to converting GIF to WebM - https://boards.4chan.org/g/res/41212767

Grab ffmpeg from https://www.ffmpeg.org/download.html

It's a command line tool which means you will have to type things with your keyboard instead of clicking on buttons.

The most trivial operation would be converting gifs:

ffmpeg -i your_gif.gif -c:v libvpx -crf 12 -b:v 500K output.webm
  • -crf values can go from 4 to 63. Lower values mean better quality.
  • -b:v is the maximum allowed bitrate. Higher means better quality.
@PurpleBooth
PurpleBooth / README-Template.md
Last active July 4, 2025 01:46
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@vermorel
vermorel / Half.cs
Last active June 4, 2025 14:25
C# Half-precision data type
/// ================ Half.cs ====================
/// The code is free to use for any reason without any restrictions.
/// Ladislav Lang (2009), Joannes Vermorel (2017)
using System;
using System.Diagnostics;
using System.Globalization;
namespace SystemHalf
{
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active June 28, 2025 20:00
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@fnky
fnky / ANSI.md
Last active July 3, 2025 19:13
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@queengooborg
queengooborg / essentials-worth.yml
Last active June 27, 2025 17:19
A balanced worth.yml file for Bukkit/Spigot servers running 1.13.x+ with EssentialsX
#
# Minecraft Essentials worth.yml - optimized for an ideal balanced Economy!
# https://gist.github.com/queengooborg/92d08120f0d6d25175f6c7a30e3ccac7
#
# Compatible MC Version: 1.13.x+
# Latest MC Version: 1.21.x
#
# Maintained by Vinyl Da.i'gyu-Kazotetsu [https://www.queengoob.org]
# Generated by https://github.com/queengooborg/mc-toolkit
# Initialy created by X00LA: https://github.com/X00LA/Bukkit-Essentials-worth.yml