Skip to content

Instantly share code, notes, and snippets.

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

Maciej Brencz macbre

🏠
Working from home
View GitHub Profile
@mportocarrero
mportocarrero / Populating new table - MySql and Python
Last active June 1, 2018 08:26
Populating new table - MySql and Python To insert data into the new table I used MySql. I could have used Python as well as both ways work, but MySql makes it more visual and easier to use.
mysql> LOAD DATA LOCAL INFILE "cycling.csv" INTO TABLE cycling FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r' IGNORE 1 LINES;
Query OK, 5 rows affected, 1 warning (0.00 sec)
Records: 5 Deleted: 0 Skipped: 0 Warnings: 1
mysql> select * from cycling;
+---------------+-----------+-----------+-----------------+-----------+-----------+-----------------+-------------------+
| Borough | Work_2001 | Bike_2001 | Percentage_2001 | Work_2011 | Bike_2011 | Percentage_2011 | Percentage_change |
+---------------+-----------+-----------+-----------------+-----------+-----------+-----------------+-------------------+
| Croydon | 156838 | 1636 | 1.0 | 172987 | 2172 | 1.3 | 0.3 |
| Greenwich | 91575 | 1351 | 1.5 | 117821 | 2738 | 2.3 | 0.8 |
@gstark
gstark / tcpdump.txt
Created April 9, 2014 13:08
Use tcpdump to monitor mysql
Use tcpdump to monitor mysql
# Capture the packets
sudo tcpdump -i eth0 port 3306 -s 65535 -x -n -q -tttt > tcpdump.out
# analyze all the requests from a given host
pt-query-digest --type=tcpdump --filter '($event->{host} || $event->{ip} || "") =~ m/192.168.248.64/' tcpdump.out
@magnetikonline
magnetikonline / README.md
Last active April 23, 2025 12:33
Setting Nginx FastCGI response buffer sizes.
@gavinhungry
gavinhungry / nginx-tls.conf
Last active March 7, 2025 19:38
Nginx SSL/TLS configuration for "A+" Qualys SSL Labs rating
#
# Name: nginx-tls.conf
# Auth: Gavin Lloyd <[email protected]>
# Desc: Nginx SSL/TLS configuration for "A+" Qualys SSL Labs rating
#
# Enables HTTP/2, PFS, HSTS and OCSP stapling. Configuration options not related
# to SSL/TLS are not included here.
#
# Additional tips:
#
@petenelson
petenelson / multiformat-wp-api-response.php
Last active May 30, 2024 11:36
WordPress: Example of returning non-JSON results from the WP-API
<?php
// reference https://github.com/WP-API/WP-API/blob/develop/lib/infrastructure/class-wp-rest-server.php
// serve_request() function
add_filter( 'rest_pre_serve_request', 'multiformat_rest_pre_serve_request', 10, 4 );
function multiformat_rest_pre_serve_request( $served, $result, $request, $server ) {
// assumes 'format' was passed into the intial API route
// example: https://baconipsum.com/wp-json/baconipsum/test-response?format=text
@macbre
macbre / compare.js
Last active February 2, 2019 10:53
Headless browsers comparison
var webpage = require('webpage'),
page = webpage.create(),
fs = require('fs'),
args = require('system').args;
var engine = args[1];
// @see http://phantomjs.org/api/webpage/handler/on-console-message.html
page.onConsoleMessage = function(msg) {
console.log(msg);
@poros
poros / pytest_parametrize_ids.py
Created October 6, 2015 01:38
Parametrized pytest testcase with dictionary of parameters and human readable testcase names
test_params = {
'empty_line': ('', {}),
'get_ok': ('GET 200', {'request': 'GET', 'status': '200'}),
'get_not_found': ('GET 404', {'request': 'GET', 'status': '404'}),
}
@pytest.mark.parametrize('line,expected', test_params.values(), ids=test_params.keys())
def test_decode(self, line, expected):
assert Decoder().decode(line) == expected
@gilbitron
gilbitron / .env.travis
Last active August 12, 2023 08:06
Laravel 5 Travis CI config
APP_ENV=testing
APP_KEY=SomeRandomString
DB_CONNECTION=testing
DB_TEST_USERNAME=root
DB_TEST_PASSWORD=
CACHE_DRIVER=array
SESSION_DRIVER=array
QUEUE_DRIVER=sync

Before you start

Make sure you have python, OpenFace and dlib installed. You can either install them manually or use a preconfigured docker image that has everying already installed:

docker pull bamos/openface
docker run -p 9000:9000 -p 8000:8000 -t -i bamos/openface /bin/bash
cd /root/openface
@macbre
macbre / docker_clean.sh
Created December 18, 2016 13:41
Docker utils
IMAGES=`docker ps -a | grep -E 'Exited|Created' | awk '{print $1}'`
df -h | head -n2
for IMAGE in $IMAGES
do
docker rm $IMAGE
done
df -h | head -n2