Skip to content

Instantly share code, notes, and snippets.

View rhamdeew's full-sized avatar
🏠
Working from home

Rail rhamdeew

🏠
Working from home
View GitHub Profile
@rhamdeew
rhamdeew / mail.php
Created March 28, 2014 08:27
PHP send mail with attach
<?php
$notAllowedExt = array('exe','apk'); //Неприемлимые расширения
$maxFileSize = 100 * 1024 * 1024; //100 MB
// Получатель (измените на ваш e-mail адрес)
$strEmail = "from@from.ru";
$email = filter_var($_REQUEST['email'],FILTER_VALIDATE_EMAIL);
if($email!==FALSE) {
$name = filter_var($_REQUEST['name'],FILTER_SANITIZE_STRING);
@rhamdeew
rhamdeew / .gitignore
Created June 9, 2014 13:29
1C-Bitrix .gitignore
# files
.DS_Store
Thumbs.db
*.sql
.gitignore
/.idea/
*/webstat/
# core
*/upload/*
<?php
if(isset($_REQUEST['ajaxform']) && isset($_REQUEST['ajaxform']['m'])) {
$data = $_REQUEST['ajaxform'];
$message_type = $data['m'];
$types = array(
1 => array(
'subject' => 'Обратный звонок',
'to' => 'mail@mail.ru',
@rhamdeew
rhamdeew / selectel_split_backup.sh
Created August 5, 2014 12:03
Backup script for selectel with split large files (+4Gb)
#!/bin/bash
#sync directories struct
rsync -a --include='*/' --exclude='*' /var/backups/local/ /var/backups/selectel
find /var/backups/local/ -name "admin-1_full*" -mtime -7 -size -4000M > /tmp/small_files.lst
for i in `cat /tmp/small_files.lst`; do ln -s $i `echo $i | sed 's/local/selectel/g'`; done;
find /var/backups/local/ -name "admin-1_full*" -mtime -7 -size +4000M > /tmp/large_files.lst
for i in `cat /tmp/large_files.lst`; do split --bytes=4000m $i `echo $i | sed 's/local/selectel/g'`; done;
@rhamdeew
rhamdeew / gist:a218aa6fd903fec4c534
Created January 26, 2015 19:14
bitrix .gitignore sample
*.komodoproject
.buildpath
.project
.settings
sitemap*.xml
awstats.*
*.sh
#symlinks
site.ru/bitrix
@rhamdeew
rhamdeew / vbox_nat.sh
Created July 3, 2013 20:18
Мой набор костыльных самопальных скриптов для старта виртуальной машины (VirtualBox Headless) с CentOS 6.4 + VestaCP для веб-разработки
#!/bin/bash
#запускать из под root
iptables -A FORWARD -o eth0 -i vboxnet0 -s 192.168.56.0/24 -m conntrack --ctstate NEW -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A POSTROUTING -t nat -j MASQUERADE
@rhamdeew
rhamdeew / ffmeg command
Created September 6, 2013 07:55
How to create video from jpeg with ffmpeg
cat *.jpg | ffmpeg -f image2pipe -r 1 -vcodec mjpeg -i - -vcodec libx264 out-`/bin/date +%Y-%m-%d`.mp4
@rhamdeew
rhamdeew / simple_full_backup.sh
Last active December 28, 2015 03:59
Simple backup script1. Dump MySQL tables into tmp folder2. Archive www, etc and tmp_sql dirs into one tarball3. Remove old archives4. Optional: mirror backups dir to remote server over ftp (lftp)5. Optional: chown backups dir
#!/bin/bash
USER="backuper" #MySQL user
PASSWORD="password" #MySQL password
DBTMP="/tmp/mysqldump/" #temporary dir for mysqldump
EXCLUDE_FILE="exclude.txt" #exclude files and dirs
TARGETDIR="/var/www/ /var/data/ /var/gitrepos/ /opt/nginx/ /etc/apache2/" #dirs to backup
BACKUPDIR="/var/backups/local/" #backup storage
DAYSOLD="3" #remove old backups
DAYSOLD_W="7" #remove old backups weekly
@rhamdeew
rhamdeew / selectel backup
Created January 16, 2014 23:32
use rsync for local sync use lftp for upload to selectel
#!/bin/bash
CURRENTDATE=$(date +%Y-%m-%d)
rm -rf /var/backups/selectel/*
find /var/backups/local/ -name admin-1_full-$CURRENTDATE.tar.gz -printf "%h\n"| xargs -i{} basename {} | xargs -i{} echo {}/admin-1_full-$CURRENTDATE.tar.gz > file.lst
rsync -a /var/backups/local /var/backups/selectel/ --files-from=file.lst
rm file.lst
/usr/bin/lftp -f /root/selectel_backup.x
@rhamdeew
rhamdeew / README
Last active May 3, 2016 17:01
rhamdeew/lamp description
1. sudo docker pull rhamdeew/lamp
2. sudo docker run -v /your_empty_project_path/:/var/www/srv/ -p 80:80 -t -i rhamdeew/lamp /bin/bash
3. in container: cp -R /var/www/example /var/www/srv
4. in container: cd /var/www/srv/
5. in container: ./start.sh
6. open http://localhost/1.php
Your project structure
projectname/