Skip to content

Instantly share code, notes, and snippets.

View sergiosdlima's full-sized avatar

Sérgio Lima sergiosdlima

View GitHub Profile
@sergiosdlima
sergiosdlima / simple_request_test.py
Created March 10, 2020 12:55
Simple request test with python
import requests
def test_home():
"GET request to url returns a 200"
url = 'https://public.ebc.com.br/templates/v1/css/print.css'
resp = requests.get(url)
assert resp.status_code == 200
def test_http_to_https_redirect():
@sergiosdlima
sergiosdlima / convert-latin-1-files-to-utf-8.sh
Created July 1, 2019 15:23
Convert all files in folder to utf-8 using iconv
# https://stackoverflow.com/a/31087016
# To convert a complete directory tree recursively from iso-8859-1 to utf-8 including the creation of subdirectories none of the short solutions above worked for me because the directory structure was not created in the target. Based on Dennis Williamsons answer I came up with the following solution:
find . -type f -exec bash -c 't="/tmp/dest"; mkdir -p "$t/`dirname {}`"; iconv -f iso-8859-1 -t utf-8 "{}" > "$t/{}"' \;
# It will create a clone of the current directory subtree in /tmp/dest (adjust to your needs) including all subdirectories and with all iso-8859-1 files converted to utf-8.
@sergiosdlima
sergiosdlima / index.html
Last active December 20, 2016 21:30
Black transparent overlay class
<div class="some-div">
<img class="imgHeading" src="path-to-file.jpg">
</div>
@sergiosdlima
sergiosdlima / Preferences.sublime-settings
Last active October 9, 2016 10:11
My preferences settings of sublime text 3
{
"bold_folder_labels": true,
"caret_style": "wide",
"default_line_ending": "unix",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"fade_fold_buttons": false,
"fallback_encoding": "UTF-8",
"find_selected_text": true,
"font_options":
@sergiosdlima
sergiosdlima / default.vcl
Created August 3, 2016 20:05
Serve robots.txt content through Varnish
backend default {
.host = "127.0.0.1";
.port = "81";
}
sub vcl_recv {
if (req.url ~ "^/robots.txt$") {
error 702 "OK";
}
if (req.url ~ "^/googlef0861ad1078d73db.html$") {
@sergiosdlima
sergiosdlima / lamp-setup.md
Created December 16, 2015 21:10 — forked from mikestecker/lamp-setup.md
This guide shows howto install Apache HTTP Server (httpd) with PHP 5.5.9 and following modules on Fedora 20/19/18/17, CentOS 6.5/6.4/6.3/6.2/6.1/6/5.10 and Red Hat (RHEL) 6.5/6.4/6.3/6.2/6.1/6/5.10 systems.

Install Apache/PHP 5.5.9 on Fedora 20/19, CentOS/RHEL 6.5/5.10

This guide shows howto install Apache HTTP Server (httpd) with PHP 5.5.9 and following modules on Fedora 20/19/18/17, CentOS 6.5/6.4/6.3/6.2/6.1/6/5.10 and Red Hat (RHEL) 6.5/6.4/6.3/6.2/6.1/6/5.10 systems.

  1. Change root user

su -
## OR ##

sudo -i

@sergiosdlima
sergiosdlima / postgres
Last active August 29, 2015 14:16 — forked from mmrwoods/postgres
# dump all databases once every 24 hours
45 4 * * * root nice -n 19 su - postgres -c "pg_dumpall --clean" | gzip -9 > /var/local/backup/postgres/postgres_all.sql.gz
# vacuum all databases every night (full vacuum on Sunday night, lazy vacuum every other night)
45 3 * * 0 root nice -n 19 su - postgres -c "vacuumdb --all --full --analyze"
45 3 * * 1-6 root nice -n 19 su - postgres -c "vacuumdb --all --analyze --quiet"
# re-index all databases once a week
0 3 * * 0 root nice -n 19 su - postgres -c 'psql -t -c "select datname from pg_database order by datname;" | xargs -n 1 -I"{}" -- psql -U postgres {} -c "reindex database {};"'
@sergiosdlima
sergiosdlima / gist:9933607
Last active August 29, 2015 13:58
SQL replace values of a column for PostgreSQL. This example is useful to replace filepath of Drupal modules when the environment changes.
UPDATE drupal_system s1 SET filename =
(
SELECT replace(filename,'_agenciabrasil2013','_sergioabr2013')
FROM drupal_system s2
WHERE s2.name = s1.name
);