Как удалить файлы из git индекса
git rm --cached mylogfile.log git rm --cached -r mydirectory
28 марта 2015, 19:48
git rm --cached mylogfile.log git rm --cached -r mydirectory
~google_appengine/dev_appserver.py --skip_sdk_update_check --port 8085 --admin_port 9005 --php_executable_path /usr/local/bin/php-cgi ~application_path
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.syslogd.plist sudo launchctl load /System/Library/LaunchDaemons/com.apple.syslogd.plist
<img id="uploadPreview" style="width: 100px; height: 100px;" /> <input id="uploadImage" type="file" name="myPhoto" onchange="PreviewImage();" /> <script> function PreviewImage() { var oFReader = new FileReader(); oFReader.readAsDataURL(document.getElementById("uploadImage").files[0]); oFReader.onload = function (oFREvent) { document.getElementById("uploadPreview").src = oFREvent.target.result; }; }; </script>
yum list | grep -i xml rpmdb: Thread/process 31902/140347322918656 failed: Thread died in Berkeley DB library error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery error: cannot open Packages index using db3 - (-30974) error: cannot open Packages database in /var/lib/rpm CRITICAL:yum.main: Error: rpmdb open failedТо должно помочь следующее
rm -f /var/lib/rpm/__* rpm --rebuilddb
$db = new PDO("mysql:host=localhost;dbname=test", 'root', ''); // works regardless of statements emulation $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); $sql = " DELETE FROM car; INSERT INTO car(name, type) VALUES ('car1', 'coupe'); INSERT INTO car(name, type) VALUES ('car2', 'coupe'); "; try { $db->exec($sql); } catch (PDOException $e) { echo $e->getMessage(); die(); }2. Используем prepare (ATTR_EMULATE_PREPARES надо включить)
$db = new PDO("mysql:host=localhost;dbname=test", 'root', ''); // works not with the following set to 0. You can comment this line as 1 is default $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); $sql = " DELETE FROM car; INSERT INTO car(name, type) VALUES ('car1', 'coupe'); INSERT INTO car(name, type) VALUES ('car2', 'coupe'); "; try { $stmt = $db->prepare($sql); $stmt->execute(); } catch (PDOException $e) { echo $e->getMessage(); die(); }
curl -X HEAD -e http://site.com -i http://ya.ru
service sysctl reloadLinux:
sysctl -p /etc/sysctl.conf
ddrescue --force /dev/ada1 /dev/null
mount -o remount,rw / # Linux mount -o rw / # FreeBSD
yum -y groupinstall "Development Tools" git clone https://github.com/tony2001/ffmpeg-php.git cd ffmpeg-php phpize ./configure make && make install
cd /root
yum install git gcc-c++ pcre-devel zlib-devel make wget openssl-devel libxml2-devel libxslt-devel gd-devel perl-ExtUtils-Embed GeoIP-devel gperftools-develКачаем исходники nginx
wget http://nginx.org/download/nginx-1.6.2.tar.gz tar -xvf nginx-1.6.2.tar.gzТеперь качаем модуль, и не забываем переключить бранч на 2.2
git clone https://github.com/vkholodkov/nginx-upload-module.git cd nginx-upload-module git checkout 2.2 cd ..Теперь нужно сконфигурировать
cd nginx-1.6.2 ./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-pcre --with-ipv6 --with-http_ssl_module --with-http_spdy_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module --with-pcre --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --with-ld-opt=-Wl,-E --add-module=/root/nginx-upload-moduleТеперь устанавливаем
make installНу и не забываем про инит скрипт /etc/init.d/nginx
#!/bin/sh # # nginx Startup script for nginx # # chkconfig: - 85 15 # processname: nginx # config: /etc/nginx/nginx.conf # config: /etc/sysconfig/nginx # pidfile: /var/run/nginx.pid # description: nginx is an HTTP and reverse proxy server # ### BEGIN INIT INFO # Provides: nginx # Required-Start: $local_fs $remote_fs $network # Required-Stop: $local_fs $remote_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: start and stop nginx ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions if [ -L $0 ]; then initscript=`/bin/readlink -f $0` else initscript=$0 fi sysconfig=`/bin/basename $initscript` if [ -f /etc/sysconfig/$sysconfig ]; then . /etc/sysconfig/$sysconfig fi nginx=${NGINX-/usr/sbin/nginx} prog=`/bin/basename $nginx` conffile=${CONFFILE-/etc/nginx/nginx.conf} lockfile=${LOCKFILE-/var/lock/subsys/nginx} pidfile=${PIDFILE-/var/run/nginx.pid} SLEEPMSEC=${SLEEPMSEC-200000} UPGRADEWAITLOOPS=${UPGRADEWAITLOOPS-5} RETVAL=0 start() { echo -n $"Starting $prog: " daemon --pidfile=${pidfile} ${nginx} -c ${conffile} RETVAL=$? echo [ $RETVAL = 0 ] && touch ${lockfile} return $RETVAL } stop() { echo -n $"Stopping $prog: " killproc -p ${pidfile} ${prog} RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} } reload() { echo -n $"Reloading $prog: " killproc -p ${pidfile} ${prog} -HUP RETVAL=$? echo } upgrade() { oldbinpidfile=${pidfile}.oldbin configtest -q || return echo -n $"Starting new master $prog: " killproc -p ${pidfile} ${prog} -USR2 echo for i in `/usr/bin/seq $UPGRADEWAITLOOPS`; do /bin/usleep $SLEEPMSEC if [ -f ${oldbinpidfile} -a -f ${pidfile} ]; then echo -n $"Graceful shutdown of old $prog: " killproc -p ${oldbinpidfile} ${prog} -QUIT RETVAL=$? echo return fi done echo $"Upgrade failed!" RETVAL=1 } configtest() { if [ "$#" -ne 0 ] ; then case "$1" in -q) FLAG=$1 ;; *) ;; esac shift fi ${nginx} -t -c ${conffile} $FLAG RETVAL=$? return $RETVAL } rh_status() { status -p ${pidfile} ${nginx} } # See how we were called. case "$1" in start) rh_status >/dev/null 2>&1 && exit 0 start ;; stop) stop ;; status) rh_status RETVAL=$? ;; restart) configtest -q || exit $RETVAL stop start ;; upgrade) rh_status >/dev/null 2>&1 || exit 0 upgrade ;; condrestart|try-restart) if rh_status >/dev/null 2>&1; then stop start fi ;; force-reload|reload) reload ;; configtest) configtest ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|upgrade|reload|status|help|configtest}" RETVAL=2 esac exit $RETVAL
mysqldump -u root -pPASSWORD -h localhost --lock-all-tables --disable-keys DBNAME | gzip -c | ssh root@xx.xx.xx.xx "cat > /home/database.core.sql.gz"
service postfix stop postsuper -d ALL service postfix start
mongorestore --dbpath /var/lib/mongo /home/backup/mongoЕсли не срабатывает, потому что версии разные, или еще почему, то придется экспортировать коллекции вручную
mongoexport --db databaseName --collection collectionName --out collectionName.jsonИмпортировать так
mongoimport --collection collectionName --file collectionName.json
#AuthOrder mod_auth_pam.c* mod_auth_unix.cЧтобы удобно дебажить можно запустить его в ручном режиме
proftpd -nd 10
php composer.phar require swiftmailer/swiftmailer @stableпример посылает емаил и аттачит файл
<?php require __DIR__ . '/vendor/autoload.php'; // создаем транспорт $transport = Swift_SmtpTransport::newInstance('smtp.mailgun.org', 587) ->setUsername('postmaster@snippets.pp.ru') ->setPassword('******'); $mailer = Swift_Mailer::newInstance($transport); // создаем сообщение $message = Swift_Message::newInstance('Тема') ->setFrom('mail@snippets.pp.ru') ->setTo('admin@snippets.pp.ru') ->setBody('<span style="color:red">Это текст сообщения</span>', 'text/html') ->attach(Swift_Attachment::fromPath('/home/file.pdf')); // шлем сообщение $result = $mailer->send($message); var_dump($result); ?>
curl -X HEAD -i http://www.google.com
sudo mv ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist /System/Library/LaunchDaemons/homebrew.mxcl.nginx.plist
<?php $cfIpRanges = [ '199.27.128.0/21', '173.245.48.0/20', '103.21.244.0/22', '103.22.200.0/22', '103.31.4.0/22', '141.101.64.0/18', '108.162.192.0/18', '190.93.240.0/20', '188.114.96.0/20', '197.234.240.0/22', '198.41.128.0/17', '162.158.0.0/15', '104.16.0.0/12', ]; $cidr_match = function ($ip, $range) { list ($subnet, $bits) = explode('/', $range); $ip = ip2long($ip); $subnet = ip2long($subnet); $mask = -1 << (32 - $bits); $subnet &= $mask; return ($ip & $mask) == $subnet; }; if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { foreach ($cfIpRanges as $cfIpRange) { if ($cidr_match($_SERVER['REMOTE_ADDR'], $cfIpRange)) { $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP']; break; } } } ?>