Skip to content

Instantly share code, notes, and snippets.

@andreyserdjuk
andreyserdjuk / docker_static_ip.sh
Last active April 9, 2022 19:15
docker static ip
# in case of conflict with local nginx:
# make sure in all *.confs (
# also in default and example to avoid error like
# 'nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)'
# )
# set for instance "listen 127.0.0.1:80" instead of "listen *:80"
# docker & network settings
DOCKER_IMAGE_NAME="maxexcloo/nginx-php" # build of nginx-php - for example
DOCKER_CONTAINERS_NAME="nginx_bridged" # our container's name
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;
@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
@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 / determine_csv_delimiter.php
Last active July 26, 2017 10:59
determine csv delimiter php
<?php
/**
* Determine csv delimiter
*
* @param resource $fileHandle - handle of csv file
* @return string - correct delimiter of csv file
*/
function determineCsvDelimiter($fileHandle)
{
<?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 / 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
@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 / 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 / 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"