Skip to content

Instantly share code, notes, and snippets.

echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@ursuleacv
ursuleacv / gist:92d7d91323448aaade34
Last active August 29, 2015 14:16
Iptables Block Baidu Spider
iptables -A INPUT -s 119.63.193.0/24 -j DROP
iptables -A INPUT -s 180.76.0.0/20 -j DROP
iptables -A INPUT -s 180.76.2.0/24 -j DROP
iptables -A INPUT -s 180.76.3.0/24 -j DROP
iptables -A INPUT -s 180.76.5.0/24 -j DROP
iptables -A INPUT -s 180.76.6.0/24 -j DROP
iptables -A INPUT -s 180.76.8.0/24 -j DROP
iptables -A INPUT -s 180.76.9.0/24 -j DROP
iptables -A INPUT -s 180.76.11.0/24 -j DROP
iptables -A INPUT -s 180.76.12.0/24 -j DROP
@ursuleacv
ursuleacv / gist:0a24821e0b6694a389bb
Last active August 29, 2015 14:16
Yii Framework : format log message - add ip address
class YourFileLogRoute extends CFileLogRoute
{
protected function formatLogMessage($message,$level,$category,$time)
{
return @date('Y/m/d H:i:s',$time)." [". Yii::app()->request->userHostAddress."]"." [$level] [$category] $message\n";
}
}
# Do not insert 404 error in logs file
# http://www.yiiframework.com/forum/index.php?/topic/22510-no-route-chttpexception/page__p__110030__fromsearch__1#entry110030
php cron.php sendpinsmsemail fill > fill.txt
php cron.php sendpinsmsemail send > send.txt
@ursuleacv
ursuleacv / gist:2b8fb4e5f449d28b83db
Created March 6, 2015 22:36
How to Reset MySQL root Password on CentOS
Stop the MySQL process
$ service mysqld stop
Once MySQL has stopped
Restart it with the --skip-grant-tables option
$ mysqld_safe --skip-grant-tables &
Connect to MySQL using the root user.
$ mysql -u root
@ursuleacv
ursuleacv / gist:72493c6e898cecca75a4
Created February 23, 2015 14:28
Twilio test credentials
5005550001 This phone number is invalid. 21211
5005550002 Twilio cannot route to this number. 21612
5005550003 Your account doesn't have the international permissions necessary to SMS this number. 21408
5005550004 This number is blacklisted for your account. 21610
5005550009 This number is incapable of receiving SMS messages. 21614
All Others Any other phone number is validated normally. Input-dependent
<?php
// post to page
$page_post = (new FacebookRequest( $session, 'POST', '/'. $page_id .'/feed', array(
'access_token' => $access_token,
'name' => 'Facebook API: Posting As A Page using Graph API v2.x and PHP SDK 4.0.x',
'link' => 'https://www.webniraj.com/2014/08/23/facebook-api-posting-as-a-page-using-graph-api-v2-x-and-php-sdk-4-0-x/',
'caption' => 'The Facebook API lets you post to Pages you administrate via the API. This tutorial shows you how to achieve this using the Facebook PHP SDK v4.0.x and Graph API 2.x.',
'message' => 'Check out my new blog post!',
) ))->execute()->getGraphObject()->asArray();
http://www.eyecon.ro/datepicker/#download
@ursuleacv
ursuleacv / gist:80d35b6b6d13fc8760ca
Created October 14, 2014 22:20
PHP: How to generate a random, unique, alphanumeric string
$t1 = microtime();
function crypto_rand_secure($min, $max) {
$range = $max - $min;
if ($range < 0) return $min; // not so random...
$log = log($range, 2);
$bytes = (int) ($log / 8) + 1; // length in bytes
$bits = (int) $log + 1; // length in bits
$filter = (int) (1 << $bits) - 1; // set all lower bits to 1
do {
$rnd = hexdec(bin2hex(openssl_random_pseudo_bytes($bytes)));
@ursuleacv
ursuleacv / gist:c963b2610985989b2786
Created September 25, 2014 13:20
Page Scroll 3D effect
<div class="wrapper active-page1">
<div class="page page1">
<h2>Здравствуйте</h2>
</div>
<div class="page page2">
<h2>Листайте страницу</h2>
</div>
<div class="page page3">
<h2>Чтобы увидеть</h2>
</div>