Skip to content

Instantly share code, notes, and snippets.

View AlexGx's full-sized avatar

Alexander Gubarev AlexGx

View GitHub Profile
@samdark
samdark / render_leveled_list_as_ul.php
Created June 29, 2012 08:31
Render leveled list as unordered list
<?php
function render_level_list($items)
{
$level=0;
foreach($items as $item)
{
if($item->level==$level) {
echo "</li>\n";
}
@marnix
marnix / createiso-demo.ps1
Last active July 20, 2024 19:10
Demo for PowerShell script to create ISO using IMAPI COM component, as a simplification for StackOverflow answer http://stackoverflow.com/a/8325316/223837
# Inspiration from
#
# http://blogs.msdn.com/b/opticalstorage/archive/2010/08/13/writing-optical-discs-using-imapi-2-in-powershell.aspx
#
# and
#
# http://tools.start-automating.com/Install-ExportISOCommand/
#
# with help from
#
@r-sal
r-sal / PHPExcel_Basics.md
Last active May 8, 2024 06:29
PHPExcel Notes and code snippets

Basics

Creating a new PHPExcel Object.

    $this->PHPExcel = new PHPExcel();

Working with sheets

Creating a new sheet:

@bmarston
bmarston / InitialDbMigrationCommand.php
Created May 8, 2013 16:23
Let's say you're starting a new Yii project and you've already created the database schema for it using something like phpMyAdmin or MySQL Workbench. Now you want to create an initial database migration so you can put the schema under version control, but you don't want to manually write the Yii code to create the tables, indexes, and foreign ke…
<?php
class InitialDbMigrationCommand extends CConsoleCommand
{
public function run($args) {
$schema = $args[0];
$tables = Yii::app()->db->schema->getTables($schema);
$addForeignKeys = '';
$dropForeignKeys = '';
#!/bin/bash
PROGNAME=${0##*/}
INPUT=''
QUIET='0'
NOSTATS='0'
max_input_size=0
max_output_size=0
usage()
@sergeylukin
sergeylukin / optimg.sh
Last active July 3, 2019 07:15
Shell script for JPGs and PNGs optimization
#!/usr/bin/env sh
#
# This script automates images optimization
# is mainly used by a developer who manually
# can execute it when adding new images to the
# project
#
# Download and compile following binaries:
#
# - [jpegtran](http://www.ijg.org/)
@mudassir0909
mudassir0909 / selectize_no_results.js
Created July 24, 2014 13:56
A hacky plugin to display "No results found" message on selectize. Don't use this along with "dropdown_header" plugin though.
/*
https://github.com/brianreavis/selectize.js/issues/470
Selectize doesn't display anything to let the user know there are no results.
This is a temporary patch to display a no results option when there are no
options to select for the user.
*/
Selectize.define( 'no_results', function( options ) {
var self = this;
@jkovacs618
jkovacs618 / AppActiveQuery.php
Created August 26, 2014 16:17
Yii2 custom AppActiveQuery class used to extend yii\db\ActiveQuery to provide a cache function for backwards-compatibility with Yii 1.1 CActiveRecord->cache.
<?php
namespace common\models\db;
class AppActiveQuery extends \yii\db\ActiveQuery
{
private $cacheDuration = null;
private $functionName = '';
private $q = null;
/**
@xskif
xskif / ReverseController.php
Last active July 30, 2021 04:26 — forked from bmarston/InitialDbMigrationCommand.php
1) Copy this gist to project/console/controllers. 2) call -- yii reverse/migrate > tmp.migrate.php 3) copy functions to existing migration class.
<?php
namespace console\controllers;
use \Yii;
class ReverseController extends \yii\console\Controller
{
public function actionMigrate() {
// $schema = $args[0];
$tables = Yii::$app->db->schema->getTableSchemas();
@appbak3r
appbak3r / DocxGenerator.php
Last active August 29, 2015 14:10
Create docx file with variables escaped with {variable}
<?php
/**
* Класс для генрации Docx
* User: Алексей Дмитриев
* Date: 10.07.14
* Time: 17:52
*/
class FileConverterDOC extends FileConverter {