Skip to content

Instantly share code, notes, and snippets.

@andreyserdjuk
andreyserdjuk / imagemagick install
Last active August 29, 2015 14:00
imagemagick install
но самое главное - сначала мейкнуть ImageMagick из исходников, а потом уже ставить rmagick. Если не будет ставиться, то поставить лабуду ниже.
sudo apt-get install libmagickwand-dev
sudo apt-get install libmagickwand-dev imagemagick
sudo apt-get install imagemagick libmagickcore-dev
./configure --disable-static --with-modules --without-perl --without-magick-plus-plus --enable-shared=yes --with-jpeg=yes --with-png=yes --with-tiff=yes
apt-get install graphicsmagick-libmagick-dev-compat
@andreyserdjuk
andreyserdjuk / MY_Form_validation.php
Last active August 29, 2015 14:02
valid JSON, iso time, for codeigniter ci
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* MY_Form_validation Class works with predefined input params:
* @example
* $params = $this->get();
* if($this->form_validation->run("do_something", $params)) {
* //do something
* } else throw new Exception(validation_errors());
@andreyserdjuk
andreyserdjuk / netbeans.conf
Created June 6, 2014 18:43
toggle English interface in NetBeans 8
# all downloaded verions of IDE has English localization, so add to ~/netbeans-8.0/etc/netbeans.conf
netbeans_default_options="-J-Duser.language=en -J-Duser.region=US"
@andreyserdjuk
andreyserdjuk / git_crear_repo.sh
Created June 17, 2014 20:09
git remove cached objects
#!/bin/sh -ev
git remote rm origin || true
git branch -D in || true
(
cd .git
rm -rf refs/remotes/ refs/original/ *_HEAD logs/
)
git for-each-ref --format="%(refname)" refs/original/ | xargs -n1 --no-run-if-empty git update-ref -d
git -c gc.reflogExpire=0 -c gc.reflogExpireUnreachable=0 -c gc.rerereresolved=0 -c gc.rerereunresolved=0 -c gc.pruneExpire=now gc "$@"
@andreyserdjuk
andreyserdjuk / doctrine_get_all_classes.php
Created June 25, 2014 08:50
get all classes in Doctrine 2.3+
<?php
$entityClassNames = $doctrine->em->getConfiguration()
->getMetadataDriverImpl()
->getAllClassNames();
@andreyserdjuk
andreyserdjuk / linux_problem_fix
Created July 16, 2014 19:28
dpkg: error processing package qapt-batch (--configure) dpkg: error processing package aspell (--configure)
/usr/share/debconf/fix_db.pl
sudo dpkg --configure -a
<?php
function cp1251_to_utf8 ($txt) {
$in_arr = array (
chr(208), chr(192), chr(193), chr(194),
chr(195), chr(196), chr(197), chr(168),
chr(198), chr(199), chr(200), chr(201),
chr(202), chr(203), chr(204), chr(205),
chr(206), chr(207), chr(209), chr(210),
@andreyserdjuk
andreyserdjuk / mysql_real_escape_string
Created October 19, 2014 16:11
mysql_real_escape_string alternative (analogue)
<?php
// mysql_real_escape_string requires an active mysql connection
function mysqlPrepareStr($str) {
return "'". str_replace(
array( '\\', "\0", "\n", "\r", "'", '"', "\x1a" ),
array( '\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z' ),
$str ) . "'";
}
@andreyserdjuk
andreyserdjuk / .bashrc
Last active August 29, 2015 14:07
linux aliases
alias ra='sudo service apache2 restart'
alias composer='php ~/composer.phar'
alias ssh1='ssh -p65035 andrey@192.168.1.3'
alias phpx="php -d xdebug.remote_autostart=1 -d xdebug.remote_host=192.168.1.88"
sshfs -p 65035 andrey@192.168.1.3:/ ~/Desktop/sftp
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
# for xdebug remote
server {
listen 80;
server_name ntest.dev www.ntest.dev;
client_max_body_size 1m;
access_log /var/log/nginx/ntest.dev.access.log;
error_log /var/log/nginx/ntest.dev.error.log;
root /var/www/ntest.dev;
location / {
try_files $uri $uri/ index.php /index.php$is_args$args;