Skip to content

Instantly share code, notes, and snippets.

Avatar
🇨🇾
Working, one commit at a time.

Leonid Mamchenkov mamchenkov

🇨🇾
Working, one commit at a time.
View GitHub Profile
View interface-example.php
<?php
interface LoggerInterface {
public function __construct($prefix = null);
public function log($message);
}
class Log1 implements LoggerInterface {
protected $prefix;
View merge.php
<?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 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
mamchenkov / monolog.php
Last active Dec 14, 2020
Example use of Monolog logger
View monolog.php
<?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 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
View hashbackup.txt
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:
View test.php
<?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 Oct 24, 2014
Convert JPG product images to PNG, replacing white background with transparent one.
View product_clean.sh
#!/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 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 : http://jsfiddle.net/paul/CY2FQ/1/
-->
@mamchenkov
mamchenkov / Article.php
Created Aug 26, 2014
Saving Article's draft in CakePHP 2
View Article.php
<?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)