Skip to content

Instantly share code, notes, and snippets.

@juanibiapina
juanibiapina / player.gd
Last active November 1, 2024 16:11
Platformer Controller
extends CharacterBody2D
const floor_move_speed_max: float = 400.0
const floor_move_acceleration: float = 2000
const floor_friction: float = 2000
const jump_min_height: float = 50
const jump_max_height: float = 200
const jump_time_to_apex: float = 0.5
const air_move_speed_max: float = 400.0
@juanibiapina
juanibiapina / update-mirrors.sh
Created April 23, 2020 17:32
Update pacman mirrors
curl -s "https://www.archlinux.org/mirrorlist/?country=DE&protocol=https&ip_version=4&use_mirror_status=on" | sed -e 's/^#Server/Server/' -e '/^#/d' > /etc/pacman.d/mirrorlist
@juanibiapina
juanibiapina / file.rb
Created February 6, 2020 16:23
LambCI Image bug
def func(event:, context:)
nil[]
end
@juanibiapina
juanibiapina / hi
Created November 19, 2019 22:48
Send a notification after some minutes
#!/usr/bin/env bash
set -e
time="$1"
(sleep "$((time * 60))" && terminal-notifier -message "There you go." -title "Hi") &
@juanibiapina
juanibiapina / profile-prompt.sh
Created May 18, 2018 15:42
Measure time to render zsh prompt
typeset -F SECONDS start
precmd () {
start=$SECONDS
}
zle-line-init () {
PREDISPLAY="[$(( $SECONDS - $start ))] "
}
zle -N zle-line-init
@juanibiapina
juanibiapina / confirm
Created February 21, 2018 11:29
Helper command to ask for confirmation before running another command (with pipe support)
#!/usr/bin/env bash
cr=`echo $'\n.'`
cr=${cr%.}
read -p "Do you want to run $*? [N/y]${cr}${cr}" -s -N 1 REPLY
if test "$REPLY" = "y" -o "$REPLY" = "Y"; then
exec "$@"
else
#!/usr/bin/env bash
#
# Download an index of posts from a blogger blog
#
# Example usage: ./blogger-index techblog.netflix.com
#
# Dependencies: xml2json, jq
set -e
@juanibiapina
juanibiapina / printf.rkt
Created November 25, 2014 02:16
Functional printf
#lang racket
(define (to-function format acc)
(match format
[(list #\% #\d rest ...) (lambda (i) (to-function rest (string-append acc (number->string i))))]
[(list #\% #\s rest ...) (lambda (s) (to-function rest (string-append acc s)))]
[(cons c rest) (to-function rest (string-append acc (string c)))]
[null acc]))
(define (printf format)
(def :f (function [:x] { (some-other-function x) } ))
(def :collatz (function [:n] { (if (= n 1)
{ (cons 1 nil) }
{ (cons n
(if (even? n)
{ (collatz (/ n 2)) }
{ (collatz (+ (* 3 n) 1)) } )) } )
} ))
@juanibiapina
juanibiapina / test.rkt
Created November 27, 2013 17:10
Name conflict with Racket's require
(define check-equal? 1)
(require rackunit)