Skip to content

Instantly share code, notes, and snippets.

View Svel's full-sized avatar
:octocat:
Looking for any good project to participate

Святослав Svel

:octocat:
Looking for any good project to participate
View GitHub Profile
@Svel
Svel / LogarithmTag.php
Created October 16, 2010 15:41
Logarithm Tag weights
<?php
/**
* Logarithm tag weights
*
* @see http://zhekanax.ru/2009/06/25/tag-cloud-logarithm/
* @see http://habrahabr.ru/blogs/webdev/30543/
*/
class Tag
{
/**
@Svel
Svel / _pager.php
Created February 10, 2011 22:05
Extend basic sfRequestRoute to accept optional variables
<?php
/**
* Pager block example
*
* @author Svel <[email protected]>
* @url https://gist.github.com/gists/821450
* @param sfDoctrinePager $pager
* @param string $route
* @param array $params
*/
@Svel
Svel / _break.xsl
Created May 7, 2011 03:34
XSL template method to convert new lines into <br /> tag
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="windows-1251" indent="yes" />
<xsl:template name="break">
<xsl:param name="text" />
<xsl:choose>
<xsl:when test="contains($text,'&#xa;')">
<xsl:value-of select="substring-before($text, '&#xa;')" disable-output-escaping="yes" />
<br />
@Svel
Svel / gist:1245745
Created September 27, 2011 17:53
PDO utf8
<?php
$handle = new PDO("mysql:host=localhost;dbname=dbname",
'username', 'password',
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
@Svel
Svel / gist:2288892
Created April 3, 2012 02:34
git workflow production commit
# Inspired from https://www.braintreepayments.com/braintrust/our-git-workflow
# and some https://www.google.com/search?q=git%20workflow&hl=en searching
#
git checkout master
git merge --squash dev
msg="Version XXX";log=$(git log --format=" * %s" dev ^$(git log --merges -n 1 dev --format="%H")); echo -e "$msg\n\n$log" | git commit -F-
git checkout dev && git merge master
@Svel
Svel / droptables.sh
Created April 7, 2012 10:51
Drop all tables in DB when you r on shared hosting without GRANT
mysqldump -u[USERNAME] -p[PASSWORD] -h[HOST] --add-drop-table --no-data [DATABASE] | grep ^DROP | mysql -u[USERNAME] -p[PASSWORD] -h[HOST] [DATABASE]
@Svel
Svel / recover_dump.sql
Created September 9, 2012 11:08
Commands to recover MySQL dump for InnoDB with FK
---# mysqldump -uUser -hHost -p database > database.sql
---# mysql -D database -uUser -p --init-command="set @@foreign_key_checks=0" < database.sql
SET FOREIGN_KEY_CHECKS=0 ;
use database ;
source database.sql ;
SET FOREIGN_KEY_CHECKS=1 ;
@Svel
Svel / test.php
Created November 12, 2012 16:38
Funny tests with xPath axes
<?php
/**
* http://habrahabr.ru/post/52680/
* http://stackoverflow.com/questions/453191/select-first-instance-only-with-xpath/
*/
$doc = new DomDocument('UTF-8', '1.0');
$doc->load(__DIR__ . '/xml.xml');
$path = new DomXPath($doc);
@Svel
Svel / Icu
Last active August 29, 2015 14:10
Updating ICU for PHP Intl
Обновляем ICU
нужен всякий gcc и проч. хлам для сборки ручками
wget http://download.icu-project.org/files/icu4c/54.1/icu4c-54_1-src.tgz
tar zxf icu4c-54_1-src.tgz
rm icu4c-54_1-src.tgz
cd icu/source/
./configure --prefix=/usr/local/
make
make install # sudo <...>