Skip to content

Instantly share code, notes, and snippets.

View p0vidl0's full-sized avatar
💭
🖥️ Working 💻

Alexander p0vidl0

💭
🖥️ Working 💻
View GitHub Profile
  • What do Etcd, Consul, and Zookeeper do?
    • Service Registration:
      • Host, port number, and sometimes authentication credentials, protocols, versions numbers, and/or environment details.
    • Service Discovery:
      • Ability for client application to query the central registry to learn of service location.
    • Consistent and durable general-purpose K/V store across distributed system.
      • Some solutions support this better than others.
      • Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state.
  • Centralized locking can be based on this K/V store.
@p0vidl0
p0vidl0 / zabbix_cleanup.sql
Last active September 22, 2018 03:15 — forked from edtjones/zabbix_cleanup.sql
Clean up zabbix database
SET @history_interval = 3;
SET @trends_interval = 90;
DELETE FROM alerts WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60);
ALTER TABLE alerts ENGINE=INNODB;
DELETE FROM acknowledges WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60);
ALTER TABLE acknowledges ENGINE=INNODB;
DELETE FROM events WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60);
ALTER TABLE events ENGINE=INNODB;
@p0vidl0
p0vidl0 / LINKS.md
Created June 23, 2016 02:13 — forked from fesor/LINKS.md
Годное чтиво
<?php
class DefaultMyStuffMaker implements MyStuffMaker
{
private $dependency;
public function __construct(SomeDependency $dependency)
{
$this->dependency = $dependency;
}
@p0vidl0
p0vidl0 / github_post_recieve.php
Created May 7, 2016 03:59 — forked from cowboy/github_post_recieve.php
GitHub PHP webhook to auto-pull on repo push
<?php
// Use in the "Post-Receive URLs" section of your GitHub repo.
if ( $_POST['payload'] ) {
shell_exec( 'cd /srv/www/git-repo/ && git reset --hard HEAD && git pull' );
}
?>hi
@p0vidl0
p0vidl0 / gh_hook.php
Created May 7, 2016 03:59 — forked from webjay/gh_hook.php
Php hook script that can git pull, apc_clear_cache() etc
<?php
ignore_user_abort(true);
function syscall ($cmd, $cwd) {
$descriptorspec = array(
1 => array('pipe', 'w'), // stdout is a pipe that the child will write to
2 => array('pipe', 'w') // stderr
@p0vidl0
p0vidl0 / apache ssh keys
Created May 7, 2016 03:59 — forked from phedoreanu/apache ssh keys
git PHP webhook
sudo mkdir -m 0700 /var/www/.ssh
sudo chown -R apache:apache /var/www/.ssh
sudo -u apache ssh-keygen (empty passphrase)
paste public key into repo manager
(git-repo) sudo -u apache git pull origin branch (this will create /var/www/.ssh/known_hosts)
call git_hook.php?branch=xxx
@p0vidl0
p0vidl0 / gist:29b46a967f16b6d0481b
Created March 12, 2016 03:20
Using MailChimp API to send email campaigns to a dynamic set of email addresses
# Sample code for sending MailChimp Email Campaigns from a Rails App using Gibbon API wrapper v0.3.5
# All recipients must already be on the associated MailChimp list (list_id), for this app we add those via another
# API call every few minutes.
#
# Member function of EmailCampaign.rb model
# See http://labs.saidigital.co/using-mailchimp-api-to-send-email-campaigns-to-a-dynamic-set-of-email-addresses-425/
# for explanation.
def send_campaign(api_key, gb, list_id, template_id, from_name, from_email)
self.reset_unique_id
segment_id = gb.list_static_segment_add(:id => list_id, :name => self.safe_name)
@p0vidl0
p0vidl0 / SoftDelete.php
Created January 19, 2016 03:48 — forked from uaoleg/SoftDelete.php
Yii2 ActiveRecord Soft Delete behavior
<?php
namespace common\traits;
/**
* Soft delete behavior for Yii2 ActiveRecord
*
* @copyright (c) 2015, Oleg Poludnenko
* @license https://opensource.org/licenses/MIT MIT
*