Skip to content

Instantly share code, notes, and snippets.

# frozen_string_literal: true
def wrap_lower?(char, shifted_char, range)
range.include?(char) && !range.include?(shifted_char)
end
def wrap_upper?(char, shifted_char, range)
range.include?(char) && !range.include?(shifted_char)
end
@airicbear
airicbear / reverse.c
Created June 12, 2021 16:55
Reverse a string
#include <stdio.h>
#include <string.h>
char* reverse(char* in);
void swap(char* s, int a, int b);
int main(int argc, char** argv) {
if (argv[1]) {
printf("%s\n", reverse(argv[1]));
} else {
@airicbear
airicbear / android.md
Last active August 17, 2021 21:35
Android Studio setup for M1 Macs

Accepting Android SDK License

With Java 11+, you do not use the sdkmanager from tools. Instead, use cmdline-tools.

Install the command line tools through Android Studio Preferences > Android SDK > SDK Tools and install Android SDK Command-line Tools (latest).

Use Android Studio's packaged JDK.

@airicbear
airicbear / myinvmod.jl
Created March 4, 2021 14:17
Inverse modulo implementation
# Note that Julia has a built-in invmod function already
function myinvmod(A, C)
for B ∈ 0:(C-1)
if mod(A*B, C) == 1
return B
end
end
return A
end
@airicbear
airicbear / isprime.jl
Last active March 21, 2021 00:58
Fermat's little theorem for testing primality
function isprime(N)
if N < 2
return false
end
a = rand(1:(N - 1))
return powermod(a, N - 1, N) == 1
end
@airicbear
airicbear / config.el
Created October 28, 2020 04:10
emacs configuration
(require 'org)
(plist-put org-format-latex-options :scale 3)
(exec-path-from-shell-copy-env "PATH")
(setq web-mode-indent-style 2)
(setq web-mode-code-indent-offset 2)
(setq web-mode-markup-indent-offset 2)
(setq-default css-indent-offset 2)
@airicbear
airicbear / ZorinBlue-Dark.el
Created July 2, 2020 23:04
Emacs Theme for Zorin OS Dark Mode with Blue Tint
(deftheme ZorinBlue-Dark
"Emacs theme for Zorin OS dark mode with blue tint")
(custom-theme-set-faces
'ZorinBlue-Dark
'(cursor ((t (:background "#bde6fb"))))
'(fixed-pitch ((t (:family "Monospace"))))
'(variable-pitch ((((type w32)) (:foundry "outline" :family "Arial")) (t (:family "Sans Serif"))))
'(escape-glyph ((((background dark)) (:foreground "cyan")) (((type pc)) (:foreground "magenta")) (t (:foreground "brown"))))
'(minibuffer-prompt ((t (:foreground "CadetBlue1"))))
# Create directory if it doesn't exist
[ -d ${1:-64} ] || mkdir ${1:-64}
# Put all resized images into the new directory
for file in *.jpg; do
magick "$file" -resize ${1:-64}x${1:-64} "./${1:-64}/${file%.jpg}_${1:-64}.jpg"
done
(defun fizzbuzz (n)
(cond ((eq (mod n 15) 0) 'fizzbuzz)
((eq (mod n 3) 0) 'fizz)
((eq (mod n 5) 0) 'buzz)
(t n)))
(loop for i from 1 to 100
do (print (fizzbuzz i)))