Skip to content

Instantly share code, notes, and snippets.

@caio-nas
caio-nas / rsync_remote_to_local_logging.sh
Last active December 20, 2015 08:29
syncs local dir with remote dir and log the outputs and errors. Always use complete path. The -n flag activates test run (only simulation)
(rsync -n -art -v --delete-after --force -e ssh integrator:/var/www/vhosts/caionascimento.com.br/httpdocs/catalogo_ifba/ /home/consultjr/merge/ 2>&1) | tee rsync_log.txt
#In Bash and zsh you can do this with Brace Expansion. This simply expands a list of items in braces. For example:
# echo {vanilla,chocolate,strawberry}-ice-cream
#vanilla-ice-cream chocolate-ice-cream strawberry-ice-cream
#So you can do your rename as follows:
mv {,new.}original.filename
#as this expands to:
#mv original.filename new.original.filename
select
/* Nomes dos campos ou '*' */
nome,id
/* Tabela de destino */
from setor
/* Filtro (opcional) */
where id = 3;
@caio-nas
caio-nas / rendimentos.html
Last active August 29, 2015 13:58 — forked from anonymous/jsbin.zoqocibi.html
Calculador de rendimentos de investimento em juros compostos
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
</html>
@manager.command
def list_routes():
import urllib
from flask import url_for
output = []
for rule in app.url_map.iter_rules():
options = {}
for arg in rule.arguments:
# Import a module / component using its blueprint handler variable
from blueprints.hello import blueprint as hello
from blueprints.web import blueprint as web
# Register blueprint(s)
app_context.register_blueprint(hello, url_prefix='/hello')
app_context.register_blueprint(web)
from flask import Blueprint
blueprint = Blueprint('web', __name__, template_folder='templates')
from . import routes
#HTTP error handling
@app_context.errorhandler(404)
def not_found(error):
return render_template('404.html'), 404
curl -0 -v -XPOST http://localhost:3000/posts.json \
-H "Expect:" \
-H 'Content-Type: application/json; charset=utf-8' \
-d @- << EOF
{
"post": {
"author_id": "5482696809",
"author_name": "@endireitabelem",
"body": "Diretas já em cuba .\n#bolsonaro2018 \n#bolsonaropresidente \n#ForaPT \n#ForaComunistas \n@Endireitabelem \nAjude a pagina a crescer, divulgue com seus amigos e familiares vamos juntos Endireitar Belém e o Brasil.",
"document_id": "BVADte9Ako7m567891101234",
@caio-nas
caio-nas / binary_gap.rb
Last active July 19, 2017 15:05
Ruby code challenges
=begin
A binary gap within a positive integer N is any maximal sequence of consecutive zeros
that is surrounded by ones at both ends in the binary representation of N.
Write a function:
def solution(n)
that, given a positive integer N, returns the length of its longest binary gap.
The function should return 0 if N doesn't contain a binary gap.