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
  • 13:52 (UTC -03:00)
View GitHub Profile
@fidelisrafael
fidelisrafael / detect_programmers_day.rb
Last active September 13, 2022 02:28
Programmers Day!
class ProgrammersDay
def initialize
time = Time.now ; prog_day = (time.year % 4).zero? ? 12 : 13 # or prog_day = {true => 12 , false 13}[(Time.now.year % 4).zero?]
return puts "Today isnt programmer's day, return tomorrow =/" if (time.strftime("%d/%m/%Y") != "#{prog_day}/09/#{Time.now.year}")
return puts ((((RbConfig::CONFIG["host_os"] =~ /mswin32/ ? ENV["USERNAME"] : ENV["USER"]).capitalize + ", ") rescue "") + "Happy Programmer's Day")
end
end
ProgrammersDay.new
@fidelisrafael
fidelisrafael / app.js
Last active August 26, 2021 02:15
Easy way to export data to XLS format using Node.js
// clone this gist to a empty folder, the run:
// npm init (and follow steps)
// npm install express --save
// npm install swig --save
// node app.js and open http://localhost:3000
function App() {
var express = require('express');
@fidelisrafael
fidelisrafael / docker-run-redis.md
Created February 16, 2021 00:35 — forked from sskoopa/docker-run-redis.md
Start redis in Docker with a open port at localhost:6379

docker run --name recorder-redis -p 6379:6379 -d redis:alpine

@fidelisrafael
fidelisrafael / web-servers.md
Created April 8, 2020 17:24 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@fidelisrafael
fidelisrafael / enzyme_render_diffs.md
Created April 3, 2020 22:08 — forked from fokusferit/enzyme_render_diffs.md
Difference between Shallow, Mount and render of Enzyme

Shallow

Real unit test (isolation, no children render)

Simple shallow

Calls:

  • constructor
  • render
@fidelisrafael
fidelisrafael / nginx_parser_log.rb
Last active November 17, 2019 08:45
Nginx Logger Parser for Ruby
require 'pry'
require 'json'
require 'uri'
module Application
class NginxLogParser
DEFAULT_FORMAT_REGEXP = /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s?\-\s?-\s?\[(\d{2}\/[a-z]{3}\/\d{4}:\d{2}:\d{2}:\d{2} (\+|\-)\d{4})\]\s?\\?"?(GET|POST|PUT|HEAD|DELETE|OPTIONS)\s?(.*?)\s(HTTP\/\d\.\d)\\?"?\s?(\d{3})\s?(\d+)\s?\\?\"\-\\?\"\s?\\?\"(.*?)\"/i
REQUEST_FORMAT = [
killall ssh-agent; eval `ssh-agent`
// node.js proxy server example for adding CORS headers to any existing http services.
// yes, i know this is super basic, that's why it's here. use this to help understand how http-proxy works with express if you need future routing capabilities
var httpProxy = require('http-proxy'),
express = require('express');
var proxy = new httpProxy.RoutingProxy();
var proxyOptions = {
host: '192.168.3.11',
@fidelisrafael
fidelisrafael / ruby_multi_threading.rb
Last active January 22, 2019 03:18
This gist compares the use of Threaded and non-Threaded Ruby code to perform IO(Read/Write) on a shared file.
gem 'thread' # gem install thread
require 'thread/pool'
@semaphore = Mutex.new
LOOPS_COUNT = (ENV['LOOPS_COUNT'] || 100).to_i
POOL_SIZE = (ENV['POOL_SIZE'] || LOOPS_COUNT).to_i
def with_thread_without_mutex!(num_loops = 100)
@fidelisrafael
fidelisrafael / slideshow.html
Created September 17, 2013 19:09
Simple horizontal slideshow with pure CSS3 Demo : http://codepen.io/fidelisrafael/full/guHlc
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Simple Slideshow with pure CSS3</title>
<style>
/* Document style */
body * {
box-sizing : border-box;
}