Skip to content

Instantly share code, notes, and snippets.

View easbarba's full-sized avatar
☀️
Praise the sun!

Alexander Barbosa easbarba

☀️
Praise the sun!
View GitHub Profile
@easbarba
easbarba / ultimate-ut-cheat-sheet.md
Created January 15, 2022 05:39 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest
@easbarba
easbarba / 0.md
Created January 10, 2022 07:05 — forked from max-mapper/0.md
JS hoisting by example

JavaScript function hoisting by example

Below are many examples of function hoisting behavior in JavaScript. Ones marked as works successfuly print 'hi!' without errors.

To play around with these examples (recommended) clone them with git and execute them with e.g. node a.js

Notes on hoisting

(I may be using incorrect terms below, please forgive me)

progrium/bashstyle

Bash is the JavaScript of systems programming. Although in some cases it's better to use a systems language like C or Go, Bash is an ideal systems language for smaller POSIX-oriented or command line tasks. Here's three quick reasons why:

  • It's everywhere. Like JavaScript for the web, Bash is already there ready for systems programming.
  • It's neutral. Unlike Ruby, Python, JavaScript, or PHP, Bash offends equally across all communities. ;)
  • It's made to be glue. Write complex parts in C or Go (or whatever!), and glue them together with Bash.

This document is how I write Bash and how I'd like collaborators to write Bash with me in my open source projects. It's based on a lot of experience and time collecting best practices. Most of them come from these two articles, but here integrated, slightly modified, and focusing on the most bang for buck items. Plus some ne

@easbarba
easbarba / setup
Created May 3, 2021 08:54 — forked from ejpcmac/setup
Setup script for Phoenix projects using Nix and PostgreSQL
#!/bin/sh
echo
if [ ! -d "deps" ] || [ ! "$(ls -A deps)" ]; then
printf "\e[32m=> Fetching dependencies and building the application...\e[0m\n\n"
echo "+ mix do deps.get, compile --verbose"
mix do deps.get, compile --verbose
echo
fi
@easbarba
easbarba / config
Created December 9, 2020 04:08
i3wm config
set $mod Mod4
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font pango:monospace 8
# This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango).
#font pango:DejaVu Sans Mono 8
@easbarba
easbarba / config.py
Created December 9, 2020 04:04
Qtile configuration file
#!/usr/bin/env python3
"""Qtile configuration."""
from pathlib import Path
from shutil import which
from dataclasses import dataclass
try:
from typing import List # noqa: F401
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
expand-file-name(nil)
userlock--check-content-unchanged("/dados/Pessoal/lsp-mode/docs/page/lsp-bash.md")
userlock--ask-user-about-supersession-threat("/dados/Pessoal/lsp-mode/docs/page/lsp-bash.md")
write-region(1 116 "/dados/Pessoal/lsp-mode/docs/page/lsp-bash.md" t)
append-to-file(1 116 "/dados/Pessoal/lsp-mode/docs/page/lsp-bash.md")
(progn (insert-file-contents "../template/lsp-client-var.md") (while (re-search-forward "{{\\([][:word:]\\[.-]+\\)}}" nil t) (let* ((key (match-string 1)) (value (lsp-doc--variable->value it key client))) (replace-match value t t))) (append-to-file (point-min) (point-max) file))
(unwind-protect (progn (insert-file-contents "../template/lsp-client-var.md") (while (re-search-forward "{{\\([][:word:]\\[.-]+\\)}}" nil t) (let* ((key (match-string 1)) (value (lsp-doc--variable->value it key client))) (replace-match value t t))) (append-to-file (point-min) (point-max) file)) (and (buffer-name temp-buffer)
using System;
namespace test
{
class Program
{
static void Main()
{
var fruit ="apple";
var flavor = "orange";
{
"name": "emacs",
"url": "https://git.savannah.gnu.org/git/emacs",
"tag": "emacs-27.1-rc1",
"commands": [
["make", "distclean"],
["sh", "autogen.sh"],
["sh", "configure --prefix={ _local } --with-modules --with-xwidgets --with-gif --with-jpeg --with-png --with-rsvg --with-tiff --with-xft --with-xpm --with-x --with-dbus --with-imagemagick --with-mailutils --with-gnutls --with-x-toolkit=gtk3"],
["make", "-j2"],
["make", "install"]
(defun a/_exwm-statusbar-battery ()
"Get laptop battery current capacity."
(let ((bat
(concat
(string-trim
(shell-command-to-string
"cat /sys/class/power_supply/BAT0/capacity"))
"%")))
bat))