Skip to content

Instantly share code, notes, and snippets.

View fidelisrafael's full-sized avatar
🏠
Working from home

Rafael Fidelis fidelisrafael

🏠
Working from home
  • https://web.archive.org/web/20221024062310/http://www.fidelis.work/
  • Brasil
  • 06:51 (UTC -03:00)
View GitHub Profile
@fidelisrafael
fidelisrafael / bash-colors.md
Created September 1, 2018 19:13 — forked from iamnewton/bash-colors.md
The entire table of ANSI color codes.

Regular Colors

Value Color
\e[0;30m Black
\e[0;31m Red
\e[0;32m Green
\e[0;33m Yellow
\e[0;34m Blue
\e[0;35m Purple
@fidelisrafael
fidelisrafael / break.py
Created August 29, 2018 19:39 — forked from obfusk/break.py
python equivalent of ruby's binding.pry
import code; code.interact(local=dict(globals(), **locals()))

Basic

import code; code.interact(local=locals())

Advanced

IPython with embed()

@fidelisrafael
fidelisrafael / thread-pool.rb
Created February 14, 2018 05:23 — forked from rosenfeld/thread-pool.rb
Simple thread pool implementation in Ruby
require 'thread' # for Mutex: Ruby doesn't provide out of the box thread-safe arrays
class ThreadPool
def initialize(max_threads = 10)
@pool = SizedQueue.new(max_threads)
max_threads.times{ @pool << 1 }
@mutex = Mutex.new
@running_threads = []
end
@fidelisrafael
fidelisrafael / human-numbers.cpp
Created February 1, 2018 18:41 — forked from cslarsen/human-numbers.cpp
Convert big number to human readable format
/*
* A simple way to format numbers as human readable strings.
* E.g., 123456789 ==> 123 million
*
* Written by Christian Stigen Larsen
* http://csl.sublevel3.org
*
* Placed in the public domain by the author, 2012
*/
@fidelisrafael
fidelisrafael / feeds.py
Created December 4, 2017 18:04 — forked from ksamuel/feeds.py
RSS/Atom link auto detection. Use feedparser and beautifulsoup
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: ai ts=4 sts=4 et sw=4
"""
Tools to extract feed links, test if they are valid and parse them
with feedparser, returning content or a proper error.
"""
@fidelisrafael
fidelisrafael / switch_touchscreen.sh
Last active November 20, 2017 23:41
Disable touchscreen on OpenSuse Leap 42.2 and others linux distros (ATTENTION: You must install `xinput` package for your distro) Original: https://ubuntuforums.org/showthread.php?t=2100744
#! /bin/bash
# switch_touchscreen.sh
# https://ubuntuforums.org/showthread.php?t=2100744
# Use `xinput --list` to list all devices and find your touchscreen
# sudo chmod a+x switch_touchscreen.sh
DEVICE="Atmel Atmel maXTouch Digitizer"
STATUS=`xinput list-props "$DEVICE" | grep 'Device Enabled' | sed 's/.*\([0-9]\)$/\1/'`
if [ "$STATUS" = "1" ]
@fidelisrafael
fidelisrafael / switch_touchscreen.sh
Created November 20, 2017 23:40
Disable touchscreen on OpenSuse Leap 42.2 and others linux distros (ATTENTION: You must install `xinput` package for your distro)
#! /bin/bash
# switch_touchscreen.sh
# https://ubuntuforums.org/showthread.php?t=2100744
# sudo chmod a+x switch_touchscreen.sh
DEVICE="Atmel Atmel maXTouch Digitizer"
STATUS=`xinput list-props "$DEVICE" | grep 'Device Enabled' | sed 's/.*\([0-9]\)$/\1/'`
if [ "$STATUS" = "1" ]
then
@fidelisrafael
fidelisrafael / game.rb
Last active September 15, 2017 08:47
A very simple and multi language "Rock-Paper-Scissor" (and "Rock-Paper-Scissor-Spock-Lizard") game written in plain Ruby only for fun ;) https://www.wikiwand.com/en/Rock%E2%80%93paper%E2%80%93scissors
require 'ostruct'
require 'irb'
# Some monkey patch to add colorized output in console
class String
COLORS_CODE = {
red: 31,
green: 32,
yellow: 33,
blue: 34,
@fidelisrafael
fidelisrafael / yield.js
Created February 2, 2017 16:22
Javascript Yield
function* process() {
console.log('Start process 1');
console.log('Pause process2 until call next()');
yield;
console.log('Resumed process2');
console.log('Pause process3 until call next()');
yield;