Skip to content

Instantly share code, notes, and snippets.

@Bogdaan
Bogdaan / mysql-innodb-utf.sh
Created January 6, 2014 13:22
Convert mysql database tables to "innodb+utf8"
#/usr/bin/env bash
DBS=$1
USER=$2
PASS=$3
if [[ -z $DBS || -z $USER || -z $PASS ]];
then
echo 'Usage: ./mysql-innodb-utf.sh DB USER PASS';
exit 1;
@Bogdaan
Bogdaan / load-csv.php
Created July 15, 2014 13:30
Load csv to mysql - with create table
<?php
$host = 'localhost';
$user = 'root';
$pass = '';
$database = 'database';
$db = mysql_connect($host, $user, $pass);
mysql_query("use $database", $db);
/**
* Generate keyframe for CSS3 animation
* ios bounce icon effect
* @size = bounce size (sample: 10)
* @onFrames = % time on frames (for delay or other effect 0-100) (sample: 50)
*/
function buildFrames(size, onFrames)
{
var source = ["0", "60", "83", "100", "114", "124", "128", "128", "124", "114", "100", "83", "60", "32", "0", "0", "18", "28", "32", "28", "18", "0"];
@Bogdaan
Bogdaan / bitrixsetup.sh
Last active August 29, 2015 14:15
bitrix remote setup, zlib functions fix
wget http://www.1c-bitrix.ua/download/scripts/bitrixsetup.php && \
sed -i 's/gztell/gztell64/' bitrixsetup.php && \
sed -i 's/gzseek/gzseek64/' bitrixsetup.php && \
sed -i 's/gzopen/gzopen64/' bitrixsetup.php
@Bogdaan
Bogdaan / Gruntfile.js
Created March 1, 2015 16:20
Gruntfile.js snippet
/**
* project minimalistic build template
*
* source - directory with source files
* source/img - standalone backgrounds or images for web
* source/icons - project icons (generate sprite)
* source/less - less project files
* source/css - css project files
* source/js - js project files
* source/lib - external libs, not from bower
@Bogdaan
Bogdaan / PCode.php
Created April 17, 2015 08:19
Code formatter
<?php
class PCode
{
private static $vector = array (
0 =>
array (
'detect' => '247\\d\\d\\d\\d',
'mask' => '+247-####',
),
@Bogdaan
Bogdaan / MyISAM
Last active August 29, 2015 14:20
Innodb to MyISAM
SET @DATABASE_NAME = 'name_of_your_db';
SELECT CONCAT('ALTER TABLE `', table_name, '` ENGINE=MyISAM;') AS sql_statements
FROM information_schema.tables AS tb
WHERE table_schema = @DATABASE_NAME
AND `ENGINE` = 'InnoDB'
AND `TABLE_TYPE` = 'BASE TABLE'
ORDER BY table_name DESC;
@Bogdaan
Bogdaan / backup
Created July 6, 2015 08:38
backup files and mysql base
#!/bin/bash
PROJNAME= #Имя проекта
CHARSET= #Кодировка базы данных (utf8)
DBNAME= #Имя базы данных для резервного копирования
DBFILENAME= #Имя дампа базы данных
ARFILENAME= #Имя архива с файлами
HOST= #Хост MySQL
USER= #Имя пользователя базы данных
PASSWD= #Пароль от базы данных
DATADIR= #Путь к каталогу где будут храниться резервные копии
@Bogdaan
Bogdaan / foreach.java
Created July 27, 2015 11:43
foreach.java
Iterator<String> iter = json.keys();
while (iter.hasNext()) {
String key = iter.next();
try {
Object value = json.get(key);
} catch (JSONException e) {
// Something went wrong!
}
}
@Bogdaan
Bogdaan / Hhvm.php
Last active February 16, 2016 18:36
Yii-1.x hhvm error handler hack
<?php
/**
* How to prevent "white page" on CHttpException and other errors
*
* Instruction:
* 1. place Hhvm.php to protected.components
* 2. add to index.php lines:
*
* define('YII_DEBUG', false);