Skip to content

Instantly share code, notes, and snippets.

View nuxlli's full-sized avatar
🎯
Focusing

Everton Ribeiro nuxlli

🎯
Focusing
View GitHub Profile
@nuxlli
nuxlli / load_dotenv.sh
Last active February 1, 2024 03:39
Loading dotenv files with exports and interpolations without override the current vars
#!/usr/bin/env bash
# This function loads variables from a .env (dotenv format) files without
# override the current variables. It will fix the relative paths.
#
# Example:
#
# $ export ENV=developer
# $ cat dotenvs/.env
# ENV=staging
@nuxlli
nuxlli / pre-push
Created December 1, 2020 15:05
A protection to not push code for main by accident
#!/bin/bash
# Warn before pushing to protected branches
# - Make script executable with
# chmod +x pre-push
# - Bypass with:
# git push --no-verify
# - To add hooks on global configuration
# git config --global core.hooksPath [path for folder with hooks]
# References:
@nuxlli
nuxlli / unix_socket_request.sh
Last active January 25, 2024 04:37
Examples of http request in unix domain socket with shell, using socat, netcat or curl
#!/bin/bash
# References
# http://www.computerhope.com/unix/nc.htm#03
# https://github.com/daniloegea/netcat
# http://unix.stackexchange.com/questions/26715/how-can-i-communicate-with-a-unix-domain-socket-via-the-shell-on-debian-squeeze
# http://unix.stackexchange.com/questions/33924/write-inside-a-socket-open-by-another-process-in-linux/33982#33982
# http://www.linuxjournal.com/content/more-using-bashs-built-devtcp-file-tcpip
# http://www.dest-unreach.org/socat/
# http://stuff.mit.edu/afs/sipb/machine/penguin-lust/src/socat-1.7.1.2/EXAMPLES
@nuxlli
nuxlli / multiples.js
Last active January 17, 2024 20:27
Multiple bars example with npm `progress`.
var ProgressBar = require('progress');
function Multibar(stream) {
this.stream = stream || process.stderr;
this.cursor = 0;
this.bars = [];
this.terminates = 0;
}
Multibar.prototype = {
@nuxlli
nuxlli / mokable_task.ex
Last active October 23, 2023 15:48
A mockable Task module for elixir (with mox)
# lib/my_project/task.ex
defmodule MyProject.Task do
@moduledoc """
TODO: run async task on tests will not work, with unpredictable side effects
"""
@adapter Keyword.get(
Application.compile_env(:my_project, __MODULE__, []),
:adapter,
Task
@nuxlli
nuxlli / localstorage.js
Created November 2, 2011 15:28
Fallback to localStorage in Samsung Smart TV
/**
* Fallback to localStorage
**/
;(function() {
if (typeof localStorage == "undefined" && typeof FileSystem == "function") {
var fileSyObj = new FileSystem();
var fileName = curWidget.id + "_localStorage.db";
var lStorage = {};
var changed = false;
@nuxlli
nuxlli / sublime_text_2_useful_shortcuts.md
Created September 9, 2011 18:51 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods
@nuxlli
nuxlli / auth_context.ex
Created December 3, 2019 21:37
Absinthe middleware for auth with Guardian
# Adaptação de http://www.east5th.co/blog/2017/05/08/graphql-authentication-with-elixir-and-absinthe/
defmodule DemoWeb.AuthContext do
@moduledoc false
@behaviour Plug
import Plug.Conn
alias Guardian.Plug.Pipeline
@nuxlli
nuxlli / console.rb
Created July 10, 2012 17:43
To access url helpers (url_for, etc) from Rails console (Rails 3)
# Example from: http://snipplr.com/view/37063/
include Rails.application.routes.url_helpers
# set host in default_url_options:
default_url_options[:host] = "localhost"
# can then use:
url_for()
@nuxlli
nuxlli / deb2tcz.sh
Last active January 3, 2022 11:55
Convert debian package to tce/tcz package
#!/bin/bash
# Create tce/tcz from Debian package
# Usage: $ scriptname packagename.deb packaganame.tce
# Depends: squashfs-tools, findutils, binutils
# References:
# - http://forum.tinycorelinux.net/index.php/topic,2325.msg12127.html
# - http://pastebin.com/ed5KSPsH
TMP1="`mktemp -d /tmp/tce.1.XXXXXX`"
TMP2="$TMP1"/pkg