Skip to content

Instantly share code, notes, and snippets.

@sapzxc
sapzxc / base64.js
Created February 5, 2016 10:28
base64.js
var Base64 = {
simbols: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
encode: function (i) {
i = Base64._utf8_encode(i);
var o = [],
l = 0,
c1, c2, c3,
e1, e2, e3, e4,
idx = 0,
len = i.length;
#!/usr/local/bin/php
<?php
$listHandle = popen('postqueue -p','r');
while(!feof($listHandle))
{
$line = trim(fgets($listHandle, 4096));
if(preg_match("/^(?<code>[0-9A-Z]{11})(?<star>\*|)/", $line, $m))
{
printf(">> %s - %s\n",$m['code'],$m['star']);
@sapzxc
sapzxc / slack.php
Last active August 29, 2015 14:22
Slack notifier for zabbix
#!/usr/bin/php
<?php
// place this file to /etc/zabbix/.../alertscripts/
$url='https://hooks.slack.com/services/XXXXX/XXXX/XXXXX';
$username='Zabbix';
if(empty($_SERVER['argv'][1]))
{
printf("Use: %s <sendto> <title> [<message>]\n", $_SERVER['argv'][0]);
@sapzxc
sapzxc / backup-zabbix-history.sh
Created October 25, 2014 22:24
Zabbix partitions
#!/bin/bash
db=zabbix
for f in history history_log history_str history_text history_uint
do
mysqldump --no-create-info --lock-tables $db $f > `date +"%Y-%m-%d"`_$f.sql
done
for f in acknowledges alerts auditlog events service_alarms trends trends_unit
@sapzxc
sapzxc / remove_spare_images.php
Last active August 29, 2015 14:06
remove image files that not listed in css files based on current directory
<?php
/**
* remove image files that not listed in css files based on current directory
*/
$directory = new \RecursiveDirectoryIterator(getcwd());
$iterator = new \RecursiveIteratorIterator($directory);
$files = array();
foreach($iterator as $info) {
@sapzxc
sapzxc / README
Last active August 29, 2015 13:58
Test for aspect ratio issue in "buggedcom/phpvideotoolkit"
Run test.sh
It creates 1.mp4 1.jpg - normal conversion, 2.mp4 2.jpg - rotated video and frame.
see https://github.com/buggedcom/phpvideotoolkit-v2/issues/22 for details