Skip to content

Instantly share code, notes, and snippets.

@zetas
zetas / backup_db_incremental.php
Last active March 8, 2022 19:50
Incremental DB Backup Scripts
<?php
/**
* Incremental DB Backup Script.
*
* Requires: innobackupex percona script.
*
* Meant to run via cron, every 8 hours. It assumes during the fourth
* invocation a day has gone by.
*
* @author Kingcat <kingcat@nzb.cat>
<?php
namespace app\extensions\data\behavior;
use nzedb\Users;
use lithium\aop\Filters;
class Vip extends \li3_behaviors\data\model\Behavior
{
@zetas
zetas / default.json
Created June 13, 2018 06:00
iTerm2 Byobu Keybind Profile.
{
"Ansi 5 Color" : {
"Green Component" : 0.4117647111415863,
"Blue Component" : 0.78823530673980713,
"Red Component" : 0.55686277151107788
},
"Working Directory" : "\/Users\/david",
"Prompt Before Closing 2" : 0,
"Selected Text Color" : {
"Green Component" : 0.729411780834198,
@zetas
zetas / views.py
Last active January 31, 2018 17:18
CheckoutView implementing Stripe Subscriptions from a recent Django project
class CheckoutView(View):
form_class = CheckoutForm
template = 'account/checkout.html'
email_template_name = 'account.checkout_success'
def create_sub(self, user, customer, plan, quantity):
subscription = customer.subscriptions.create(plan=plan, quantity=quantity)
user.stripe_subscription_id = subscription.id
user.save()
@zetas
zetas / expanded-default.conf
Created August 29, 2017 02:06
NGINX SSL Termination Config
# configuration file /etc/nginx/nginx.conf:
# Configuration File - Nginx Server Configs
# http://nginx.org/en/docs/dirindex.html
# Run as a unique, less privileged user for security reasons.
# Default: nobody nobody
user www-data www-data;
# Sets the worker threads to the number of CPU cores available in the system for best performance.
# Should be > the number of CPU cores.
@zetas
zetas / webhook.php
Created July 30, 2017 06:14
output variables to a logfile
<?php
$log = fopen('/tmp/webhook.log', 'a+');
ob_start();
var_dump($_SERVER);
$content = ob_get_clean();
fwrite($log, $content);
fclose($log);
@zetas
zetas / Blockchain.php
Created July 7, 2017 09:36
Super simple blockchain api wrapper
<?php
namespace nzedb\frontend\donation\Blockchain;
/**
* Super simple Blockchain.info V2 Receive API implementation.
*
* Also some usecase-specific conversion methods.
* @package nzedb\frontend\donation\Blockchain
*/
class Blockchain
location /sabnzbd {
client_max_body_size 10m;
client_body_buffer_size 128k;
#Timeout if the real server is dead
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
# Advanced Proxy Config
send_timeout 5m;
proxy_read_timeout 240;
<?php
protected static function _filters($model, $behavior)
{
Filters::apply($model, 'save', function ($params, $next) use ($behavior) {
foreach ($behavior->config('fields') as $field) {
$params['data'][$field] = static::_btcToSatoshi($behavior, $params['entity'], $field);
}
return $next($params);
@zetas
zetas / app.coffee
Created January 23, 2014 08:56
My first javascript app (in coffeescript ofcourse lol)
fluffPhraseList = ['actually', 'in-all-actuality', 'how about that', 'however then', 'however because of that', 'and also', 'and/or', 'as to whether', 'basically', 'essentially', 'technically', 'totally', 'for sure', 'being that ', 'being as', 'on account of that', 'on account of ', 'on account of this', 'point in time', 'that time', 'this time', 'quite', 'really', 'so as to', 'sort of', 'try and', 'very', 'well then', 'even then', 'so then', 'really then', 'although then', 'however then', 'also then', 'then also', 'as then', 'if then', 'therefore then', 'overall then', 'and though', 'and because of this', 'and because of that', 'and furthermore', 'and however', 'and this is because', 'and overall', 'and now', 'because ', 'because of this', 'because of that', 'because this is', 'this is because', 'because that is', 'because i am', 'because you are', 'furthermore because of that', 'because furthermore', 'overall because of that', 'because overall', 'because now', 'because that', 'that is because', 'because how