Skip to content

Instantly share code, notes, and snippets.

View mamchenkov's full-sized avatar
🇨🇾
Working, one commit at a time.

Leonid Mamchenkov mamchenkov

🇨🇾
Working, one commit at a time.
View GitHub Profile
@mamchenkov
mamchenkov / git-commit-hash
Last active February 13, 2023 18:22
Find current git commit id/hash
$ git log -1 | grep ^commit | cut -d " " -f 2
dab96492ac7d906368ac9c7a17cb0dbd670923d9
$ git log -1 | grep ^commit | awk '{print $2}'
dab96492ac7d906368ac9c7a17cb0dbd670923d9
@mamchenkov
mamchenkov / update_translations.sh
Created September 10, 2012 13:41
gettext translations update
#!/bin/bash
DOMAIN="easyforex"
POT="$DOMAIN.pot"
LANGS="en_US ru_RU"
SOURCES="*.php"
# Create template
echo "Creating POT"
rm -f $POT
@mamchenkov
mamchenkov / monolog.php
Last active January 5, 2022 09:31
Example use of Monolog logger
<?php
// Before: composer require monolog/monolog
// composer autoloader
require_once 'vendor/autoload.php';
// Shortcuts for simpler usage
use \Monolog\Logger;
use \Monolog\Formatter\LineFormatter;
use \Monolog\Handler\StreamHandler;
@mamchenkov
mamchenkov / ini2json
Created August 8, 2013 15:26
Quick converter of INI files to JSON files written in PHP.
#!/usr/bin/php
<?php
$in = empty($argv[1]) ? '' : $argv[1];
$out = empty($argv[2]) ? '' : $argv[2];
if (empty($out)) {
$out = basename($in, '.ini') . '.json';
}
<?php
interface LoggerInterface {
public function __construct($prefix = null);
public function log($message);
}
class Log1 implements LoggerInterface {
protected $prefix;
1. Copy ssh public key to rsync.net server:
[jim@mb hbdev]$ scp ~/.ssh/id_rsa.pub XXXX@usw-s002.rsync.net:.ssh/authorized_keys
Password:
id_rsa.pub
100% 392 0.4KB/s 00:00
2. Create a local HashBackup backup directory:
<?php
/**
* This script shows an example of how merge two arrays,
* where one array contains instances of Products, and the
* second array contains **multiple** instances of Product
* Attributes, and where the records in both arrays are
* linked via some value ($product->id == $attribute->product_id).
*/
/**
@mamchenkov
mamchenkov / 0_reuse_code.js
Created June 6, 2016 22:00
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mamchenkov
mamchenkov / chart_web_requests.sh
Created August 5, 2013 08:20
Chart total number of web requests per hour using Google Charts
#!/bin/bash
# Chart total number of web requests per hour using Google Charts
# Usage: chart_web_request.sh [DATE] [PATH]
#
# If DATE is not given, yesterday is used. Date should be in the format
# that your web server is using in access logs
#
# If PATH is not given /var/log/httpd/*-access_log is used.
#
@mamchenkov
mamchenkov / file-random-access.php
Last active December 19, 2015 21:48
Read file line-by-line from given byte offset. Handy for re-processing large logs files.
<?php
/**
* Read file line-by-line from given byte offset.
* Handy for re-processing large logs files.
*/
// Filename to use for temporary data
define('DATA_FILE', 'data.log');
// Create the data file on the fly