Skip to content

Instantly share code, notes, and snippets.

@XrXr
XrXr / ANSI.md
Created April 6, 2023 00:39 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@XrXr
XrXr / invisible-trends.css
Created March 2, 2022 15:32
Chrome extension to hide trending topics on Twitter. Sometimes you don't want to look at news.
// Borrowing 101. Easy to see that the borrows don't overlap
// because everything is explicit and has a mapping to a
// lexical range in the source.
#[derive(Debug)]
struct NotCopy;
fn main() {
// owner (can move the value if it wants, responsible for calling destructor)
let mut obj = NotCopy {};
@XrXr
XrXr / gist:bf5f5674fec7a4ecde4ba172192f3025
Last active July 11, 2020 22:30
Select the Japanese variant of characters with Unicode IVD selector
綾󠄀
天 <- without selector
㆝󠄀
角 <- without selector
角󠄀
def foo
-2.itself ** 2
end
def foo2
(-2.itself) ** 2
end
def bar
-2 ** 2
@XrXr
XrXr / fudge-tabs.rb
Last active June 18, 2020 20:21
Expand tabs and remove changes that only expand tabs for use in https://github.com/ruby/ruby
#!/bin/env ruby
# Copyright (c) 2020 Alan Wu
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
@XrXr
XrXr / less-config
Created July 22, 2019 18:29
Less config. Run lesskey on this file and it sets things up automatically.
#command
k forw-line
l back-line
# bad: [374e7c79eaae2dd53e2038c7f5a737653ca5e214] * 2018-01-01
# good: [5659843d6e74e321c2af58e1f3f5f73514509282] * 2017-01-01
git bisect start '374e7c79eaae2dd53e2038c7f5a737653ca5e214' '5659843d6e74e321c2af58e1f3f5f73514509282'
# bad: [dc7f2cd58615afb193f46b2bec1285186f5bf5bd] Add initial test for lldb extension
git bisect bad dc7f2cd58615afb193f46b2bec1285186f5bf5bd
# good: [fe378f03f7ff18abecb8dc9e1daf957de816e39f] test/test_prime.rb: update method name in comment
git bisect good fe378f03f7ff18abecb8dc9e1daf957de816e39f
# good: [abbfc048c5890e8017360bbc845062ea1585e155] suppress warning: ambiguous first argument; put parentheses or a space even after `-' operator
git bisect good abbfc048c5890e8017360bbc845062ea1585e155
# bad: [5522d79803766d715c37a7826e079b1c05c11e59] downloader.rb: get rid of symlinks
@XrXr
XrXr / block-pass.rb
Created May 16, 2019 21:45
Block-pass benchmark
require 'bundler/inline'
require 'benchmark/ips'
N = 10_000
def without
yield
end
def with_dot_call(&block)
@XrXr
XrXr / watch-for-puts.rb
Last active April 10, 2019 04:09
A way to catch calls to Kernel#puts
module Kernel
original_puts = instance_method(:puts)
define_method(:puts) do |*args|
$stdout.puts("how are you doing")
# binding.pry
original_puts.bind(self).call(*args)
end
end
puts "I'm doing fine thanks"