Skip to content

Instantly share code, notes, and snippets.

Working, one commit at a time.

Leonid Mamchenkov mamchenkov

Working, one commit at a time.
View GitHub Profile
View interface-example.php
interface LoggerInterface {
public function __construct($prefix = null);
public function log($message);
class Log1 implements LoggerInterface {
protected $prefix;
View merge.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 / 0_reuse_code.js
Created Jun 6, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
mamchenkov / monolog.php
Last active Dec 14, 2020
Example use of Monolog logger
View monolog.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;
View Envoy.blade.php
* -A in SSH enables agent forwarding.
* -p 2122 is not needed if you use the default port of 22.
* Replace SSH_USER and 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', 'prod' => '-A -p 2122 -l user'])
@task('install_test', ['on' => ['test']])
cd project
View hashbackup.txt
1. Copy ssh public key to server:
[jim@mb hbdev]$ scp ~/.ssh/
100% 392 0.4KB/s 00:00
2. Create a local HashBackup backup directory:
View test.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 /
Created Oct 24, 2014
Convert JPG product images to PNG, replacing white background with transparent one.
# 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:
mamchenkov / object-iframe-with-fallback.html
Last active Aug 29, 2015 — forked from paulirish/gist:616412
Object tag as an iframe, with fallbacks
View object-iframe-with-fallback.html
<!-- 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 :
mamchenkov / Article.php
Created Aug 26, 2014
Saving Article's draft in CakePHP 2
View Article.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)