Skip to content

Instantly share code, notes, and snippets.

View rodrigodev's full-sized avatar
🎯
Focusing

Rodrigo Carneiro rodrigodev

🎯
Focusing
View GitHub Profile
@rodrigodev
rodrigodev / iconv-convert-encoding.sh
Created December 8, 2020 21:26
Convert encoding batch for Mac OS
#!/bin/bash
#enter input encoding here
FROM_ENCODING="ISO_8859-1"
#output encoding(UTF-8)
TO_ENCODING="UTF-8"
#convert
CONVERT="iconv -f $FROM_ENCODING -t $TO_ENCODING"
#loop to convert multiple files
for file in ./*.txt; do
encoding=$(file -I "$file" | awk '{print $3}')
@rodrigodev
rodrigodev / git_rewrite.sh
Created March 23, 2020 14:28
Rewrite git history to fix wrong email commit
git filter-branch --env-filter 'if [ "$GIT_AUTHOR_EMAIL" = "wrong@email.com" ]; then
GIT_AUTHOR_EMAIL=new@email.com;
GIT_AUTHOR_NAME="New Name";
GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL;
GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; fi' -- --all
@rodrigodev
rodrigodev / remove_whitespace.go
Created February 12, 2020 12:59
Removes all whites spaces, examples and benchmarks
package main_test
import (
"strings"
"unicode"
"testing"
)
func SpaceMap(str string) string {
return strings.Map(func(r rune) rune {
@rodrigodev
rodrigodev / app.py
Created October 12, 2018 13:54 — forked from codesplicer/app.py
flask-mongoengine in a blueprint
# Flask related imports
from flask import Flask, render_template, jsonify, abort, request, make_response, session, redirect, url_for
# Flask extensions
from flask.ext.mongoengine import MongoEngine
from flask_debugtoolbar import DebugToolbarExtension
# Flask blueprints
import companies
from companies.views import companies
@rodrigodev
rodrigodev / .gitignore
Created September 10, 2018 13:24 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@rodrigodev
rodrigodev / haproxy.conf
Created August 15, 2017 18:42
Haproxy subdomain redirect
frontend http-in
mode http
bind FRONTENDIP:80
default_backend nginx_server_1
acl nginx_1 hdr_end(host) -i www.xyz.com
acl nginx_2 hdr_end(host) -i abc.xyz.com
acl nginx_path path_beg /abc/
# send a fake log to log service
echo "<150>`env LANG=us_US.UTF-8 date "+%b %d %H:%M:%S"` host`date +%s` service: my special message goes here" | nc 192.168.0.1 -u 514 -w 1
@rodrigodev
rodrigodev / smart_group_by_nearest.py
Last active April 7, 2017 17:36
A smart way to group a list of integers given a min distance.
def smart_group_by_nearest(distance, int_list):
int_list.sort()
grouped_list = [[int_list[0]]]
for x in int_list[1:]:
if x - grouped_list[-1][0] <= distance:
grouped_list[-1].append(x)
else:
grouped_list.append([x])
return grouped_list
#remove small groups if wanted
@rodrigodev
rodrigodev / auto_dubstep.rb
Created December 29, 2016 17:50 — forked from xavriley/auto_dubstep.rb
Auto generating dubstep with Sonic Pi
# DUBSTEP
# Combines ideas from my other gists
current_bpm = 140.0
use_bpm current_bpm
# WOBBLE BASS
define :wob do
use_synth :dsaw
lowcut = note(:E1) # ~ 40Hz
highcut = note(:G8) # ~ 3000Hz
@rodrigodev
rodrigodev / functions.php
Last active August 29, 2015 14:08
PHP: debug to front
<?php
function cprint_r($var, $json = false)
{
$output = "<script type='text/javascript'>";
if (is_object($var)) {
$mirror = new \ReflectionClass($var);
$var = $mirror->getProperties();
} elseif (is_array($var)) {