This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @param apiKey - ключ для GCM, получить можно в https://code.google.com/apis/console/ | |
* @param registrationIdsArray - массив токенов устройств | |
* @param messageData - массив данных уведомления, например: array('message' => "Hey!") | |
*/ | |
function sendGCMNotification( $apiKey, $registrationIdsArray, $messageData ) | |
{ | |
$headers = array("Content-Type:" . "application/json", "Authorization:" . "key=" . $apiKey); | |
$data = array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT `user_login`, count(*) as total FROM users GROUP BY `user_login` HAVING total > 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var obj = { | |
a: 25, | |
b: 50, | |
c: 75, | |
x: function() { | |
alert(this.a); | |
} | |
}; | |
var A = Object.create(obj); | |
var B = Object.create(obj); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Firstly edit my.cnf: | |
# > nano my.cnf | |
# | |
# max_allowed_packet = 2600M | |
# net_buffer_length = 2600M | |
# Or by cmd: | |
# | |
# mysql> set global max_allowed_packet=1000000000; | |
# mysql> set global net_buffer_length=1000000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Wilson score formula with range | |
* | |
* @param {number} sum Objects sum | |
* @param {number} total Total objects | |
* @param {object} range Objects (votes) range: [0, 1] or [0, n] | |
* @param {number} z Confidence level | |
*/ | |
function wilsonScoreRange(sum, total, range, z) { | |
// http://amix.dk/blog/post/19588 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var score = 0; | |
var penalty = 100; // Penalty can be fine-tuned. | |
var lastact = new Date(); | |
function talk() { | |
/* The smaller the distance, more time has to pass in order | |
* to negate the score penalty cause{d,s}. | |
*/ | |
score -= (new Date() - lastact) * 0.55; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tar -zvcf archive.tar /path/to/site --exclude "/path/to/site/system" --exclude "/path/to/site/tmp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# You can replace "xenial" to another distribution: | |
# bionic (Ubuntu 18.04), artful, trusty, sid, buster, stretch, jessie, xenial (Ubuntu 16.04), yakkety, zesty | |
echo "deb https://dl.bintray.com/rabbitmq/debian xenial main erlang" | sudo tee /etc/apt/sources.list.d/bintray.rabbitmq.list > /dev/null | |
wget -O - 'https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc' | sudo apt-key add - | |
sudo apt-get update | |
sudo apt-get install rabbitmq-server -y | |
sudo service rabbitmq-server start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$string = ' | |
#abc123_ | |
#машина | |
#anytest😀 | |
#какой_тотекст😁 | |
#😂 | |
#🤣 | |
#😃 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO $$ | |
DECLARE | |
r record; | |
BEGIN | |
FOR r IN SELECT quote_ident(tablename) AS tablename, quote_ident(schemaname) AS schemaname FROM pg_tables WHERE schemaname = 'public' | |
LOOP | |
RAISE INFO 'Dropping table %.%', r.schemaname, r.tablename; | |
EXECUTE format('DROP TABLE IF EXISTS %I.%I CASCADE', r.schemaname, r.tablename); | |
END LOOP; | |
END$$; |
OlderNewer