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
@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
@gavinhungry
gavinhungry / nginx-tls.conf
Last active March 11, 2024 14:51
Nginx SSL/TLS configuration for "A+" Qualys SSL Labs rating
#
# Name: nginx-tls.conf
# Auth: Gavin Lloyd <gavinhungry@gmail.com>
# 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:
#
@magnetikonline
magnetikonline / README.md
Last active April 30, 2024 00:45
Setting Nginx FastCGI response buffer sizes.
@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
@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 |
@matt448
matt448 / slack_nagios.sh
Last active February 13, 2023 15:38
Script to post Nagios notifications into a Slack channel
#!/bin/bash
# This script is used by Nagios to post alerts into a Slack channel
# using the Incoming WebHooks integration. Create the channel, botname
# and integration first and then add this notification script in your
# Nagios configuration.
#
# All variables that start with NAGIOS_ are provided by Nagios as
# environment variables when an notification is generated.
# A list of the env variables is available here:
@SpOOnman
SpOOnman / graphite-local-install.sh
Created July 9, 2013 14:02
How to install Graphite as a user on CentOS 5.5
#!/bin/bash
# How to install Graphite as a user on CentOS 5.5 (with neither internet access and root account)
# --------------------------------------------------------------------------------
# Tomasz Kalkosiński - refaktor.blogspot.com
#
# Graphite is a Scalable Realtime Graphing (http://graphite.wikidot.com/)
# This script is based on two excellent tutorials:
# http://community.webfaction.com/questions/10038/how-to-install-pycairo-in-python27-thanks
@XueshiQiao
XueshiQiao / gource.sh
Last active November 10, 2019 15:56 — forked from cgoldberg/gource.sh
Generate a MP4 Video for your Git project commits using Gource!
# 1.install gource using HomeBrew
$ brew install gource
# 2.install avconv
git clone git://git.libav.org/libav.git
cd libav
# it will take 3-5 minutes to complie, be patient.
./configure --disable-yasm
make && make install
@andrequeiroz
andrequeiroz / holtwinters.py
Last active July 5, 2023 07:50
Implementation of Holt-Winters algorithms in Python 2
#The MIT License (MIT)
#
#Copyright (c) 2015 Andre Queiroz
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
@willurd
willurd / web-servers.md
Last active May 30, 2024 02:54
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