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
<?php
interface LoggerInterface {
public function __construct($prefix = null);
public function log($message);
}
class Log1 implements LoggerInterface {
protected $prefix;
<?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 / 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;
* -A in SSH enables agent forwarding.
* -p 2122 is not needed if you use the default port of 22.
* Replace SSH_USER and example.com with your own values.
* Example run: $ envoy run deploy_demo
* --no-scripts because Laravel composer.json's post-install-cmd includes optimize, which is already done by php artisan dump-autoload
@servers(['test' => '-A -p 2122 -l user test.example.com', 'prod' => '-A -p 2122 -l user example.com'])
@task('install_test', ['on' => ['test']])
cd project
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
// Sample data from data.csv
//line 1, product 1, feature 1
//line 2, product 1, feature 2
//line 3, product 1, feature 3
//line 4, product 2, feature 1
//line 5, product 3, feature 1
class Product {
// Product lines until we save
@mamchenkov
mamchenkov / product_clean.sh
Created October 24, 2014 08:49
Convert JPG product images to PNG, replacing white background with transparent one.
#!/bin/bash
# Cleanup product images
#
# This will convert images from JPG to PNG and replace the white
# background with transparent one.
#
# This is almost verbatim copy of the script from:
# http://tech.natemurray.com/2007/12/convert-white-to-transparent.html
@mamchenkov
mamchenkov / object-iframe-with-fallback.html
Last active August 29, 2015 14:07 — forked from paulirish/gist:616412
Object tag as an iframe, with fallbacks
<!-- so it turns out that the object tag can act like an iframe
but the cool thing is you can nest object tags inside eachother for a fallback path.
what this means is you can "objectframe" a site.. and if it fails.. (site down, offline, whatever).. it'll use the next one.
so you can objectframe the live site and fallback to a screenshot.
or something.
demo at : http://jsfiddle.net/paul/CY2FQ/1/
-->
@mamchenkov
mamchenkov / Article.php
Created August 26, 2014 06:51
Saving Article's draft in CakePHP 2
<?php
/* For this whole thing to work, you'll need at least these fields in your
* articles table:
*
* - id (article id)
* - parent_id (to link drafts to parent article)
* - slug (for friendly URLs usually)
* - title (obviously)
* - content (obviously)