Skip to content

Instantly share code, notes, and snippets.

View marcelocra's full-sized avatar
🤯
Think before coding.

Marcelo Almeida marcelocra

🤯
Think before coding.
View GitHub Profile
@marcelocra
marcelocra / gallery.cljs
Created March 30, 2024 17:36 — forked from borkdude/gallery.cljs
script to download walpapers from windowsonearth.org, adapted for nbb
@marcelocra
marcelocra / gallery.cljs
Created March 30, 2024 17:36 — forked from yogthos/gallery.cljs
script to download walpapers from windowsonearth.org
@marcelocra
marcelocra / Dockerfile
Created March 12, 2023 15:14
Run Portacle (for Common Lisp development) from a Docker container
# syntax=docker/dockerfile:1
FROM ubuntu:22.04
# Update and install essentials.
RUN apt-get update
RUN apt-get install -y wget git tmux ripgrep curl unzip neovim less xz-utils fontconfig
RUN fc-cache -f -v
# Portacle.
WORKDIR /home/linus
@marcelocra
marcelocra / error.txt
Created April 29, 2022 23:59
Rails 7 - libvips error
/usr/local/bundle/gems/ffi-1.15.5/lib/ffi/library.rb:145:in `block in ffi_lib':
Could not open library 'vips.so.42': vips.so.42: cannot open shared object file: No such file or directory. (LoadError)
Could not open library 'libvips.so.42': libvips.so.42: cannot open shared object file: No such file or directory
@marcelocra
marcelocra / core.cljs
Last active August 16, 2020 01:43
How to use goog.style/installSafeStyleSheet in Clojure, with garden.
(ns ^:figwheel-hooks dynamic-css.core
(:require
[goog.dom :as gdom]
[goog.style :as gstyle]
[reagent.core :as r]
[reagent.dom :as rdom]
[garden.core :refer [css]])
(:import [goog.html SafeStyleSheet]
[goog.string Const]))
@marcelocra
marcelocra / detect_keyboard_events.cljs
Last active August 6, 2022 03:18
ClojureScript goog keyboard events to create shortcuts (goog.ui.KeyboardShortcutHandler)
;; Using goog.ui.KeyboardShortcutHandler with ClojureScript to support keyboard input events (for example, to create shortcuts).
;; Documentation about goog.ui.KeyboardShortcutHandler:
;; https://github.com/google/closure-library/blob/master/closure/goog/demos/keyboardshortcuts.html
(ns example.detect-keyboard-effects
(:require [goog.events :as events])
(:import [goog.ui KeyboardShortcutHandler]))
(defn setup-keyboard-shortcuts []
(let [shortcuts (KeyboardShortcutHandler. js/document)]
@marcelocra
marcelocra / ImageViewInPicasso.java
Last active September 24, 2015 01:40
Access ImageView info when using Picasso library
// This can be used to load images when you don't know their sizes beforehand.
imageView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// Need to remove the listener, otherwise weird things will happen.
if (Build.VERSION.SDK_INT < 16) {
imageView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
} else {
imageView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
@marcelocra
marcelocra / my-improved-prompt.sh
Last active August 29, 2015 14:20
Bash shell prompt with return code, git branch name and status
# This improved version of the prompt shows the return value of the last command,
# what time the command was run, the git branch name and status if in a repo folder
# and the working directory as usual.
# Source the ANSI color codes before sourcing this file, otherwise it won't work.
get_git_branch() {
local branch
if branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null); then
if [[ "$branch" == "HEAD" ]]; then
@marcelocra
marcelocra / .tmux.conf
Created March 30, 2015 01:33
Tmux basic configuration
# Set Ctrl-a as the default prefix key combination and unbind Ctrl-b.
set -g prefix C-a
unbind C-b
# Change default delay time.
set -sg escape-time 1
# Change base index to 1 (in status bar and panes).
set -g base-index 1
setw -g pane-base-index 1
@marcelocra
marcelocra / ansi-color-codes.sh
Last active August 29, 2015 14:17
ANSI Color Codes
# ANSI color codes
RS="\[\033[0m\]" # reset
HC="\[\033[1m\]" # hicolor
UL="\[\033[4m\]" # underline
INV="\[\033[7m\]" # inverse background and foreground
FBLK="\[\033[30m\]" # foreground black
FRED="\[\033[31m\]" # foreground red
FGRN="\[\033[32m\]" # foreground green
FYEL="\[\033[33m\]" # foreground yellow
FBLE="\[\033[34m\]" # foreground blue