Skip to content

Instantly share code, notes, and snippets.

Serhii Smirnov smilesrg

Block or report user

Report or block smilesrg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@smilesrg
smilesrg / pubapi_docs.html
Last active Jun 24, 2019 — forked from andreij/pubapi_docs.html
Chess.com Published-Data API
View pubapi_docs.html
<p>The PubAPI is a read-only REST API that responds with JSON-LD data. Our goal is to re-package all currently public data from the website and make it available via the PubAPI. "Public Data" is information available to people who are not logged in, such as player data, game data, and club/tournament information. This excludes private information that is restricted to the logged in user, such as game chat and conditional moves.</p>
<p>This is read-only data. You cannot send game-moves or other commands to Chess.com from this system. If you wish to send commands, you will be interested in the Interactive API releasing later this year.</p>
<p>To use the PubAPI:</p>
<ol>
<li>determine the data you want, and compose the URL for it based on the endpoint URL pattern</li>
<li>request that URL in your browser, program, <a href="https://www.getpostman.com/">Postman</a>, cURL, or <a href="https://en.wikipedia.org/wiki/IP_over_Avian_Carriers">pigeon</a>.</li>
<li>enjoy the JSON <img src="https://www.chess.com/bundles/we
@smilesrg
smilesrg / reference.php
Last active Mar 10, 2017
Objects have to be passed by reference explicitly if function is replacing original object with cloned one.
View reference.php
<?php
class A {
public $property = "Default Value";
}
function clone_and_modify(A $obj) {
$cloned = clone $obj;
$cloned->property = "Modified Value";
@smilesrg
smilesrg / bcmath_factorial
Last active Aug 29, 2015
PHP Factorial calculation usng BC Math extension
View bcmath_factorial
<?php
define('F_NUMBER', 25);
function factorial($in) {
// 0! = 1! = 1
$out = '1';
// Only if $in is >= 2
for ($i = 2; $i <= $in; $i++) {
@smilesrg
smilesrg / gist:35747174a91be7ddf910
Created Mar 19, 2015
Register Globals emulation
View gist:35747174a91be7ddf910
<?php
// Emulate register_globals on
if (!ini_get('register_globals')) {
$superglobals = array($_SERVER, $_ENV, $_FILES, $_COOKIE, $_POST, $_GET);
if (isset($_SESSION)) {
array_unshift($superglobals, $_SESSION);
}
foreach ($superglobals as $superglobal) {
extract($superglobal, EXTR_SKIP);
}
View gist:8792810
> db.user_posts.runCommand( "text" , { search: "сердце",project:{"user":1, "posts.$.post":1,_id:0},limit: 3 } )
{
"queryDebugString" : "сердц||||||",
"language" : "russian",
"results" : [
{
"score" : 0.625,
"obj" : {
"posts" : [
{
View gist:8792681
> db.user_posts.runCommand( "text" , { search: "сердце",project:{"user":1, "posts.post":1,_id:0},limit: 3 } )
{
"queryDebugString" : "сердц||||||",
"language" : "russian",
"results" : [
{
"score" : 0.625,
"obj" : {
"posts" : [
{
View gist:8729585
services:
# handler.user_creation:
# class: PrestoHeads\BrainGames\CoreBundle\Handler\UserCreationHandler
# arguments: [@monolog.logger, @doctrine_mongodb.odm.document_manager]
current_time:
class: PrestoHeads\BrainGames\CoreBundle\DateTime\CurrentDateTime
assignment_publisher:
class: PrestoHeads\BrainGames\CoreBundle\Assignment\AssignmentPublisher
arguments: [@doctrine_mongodb.odm.document_manager, @logger]
View gist:8673532
{
"_id" : ObjectId("52e7c9744947253b568b4567"),
"avatar" : "http://cs5422.vk.me/u3688507/d_ada9050a.jpg",
"contract" : "12345",
"contractRequest" : {
"_id" : ObjectId("52e7f93c4947253b568b4568"),
"firstname" : "Сергей",
"lastname" : "Смирнов",
"address" : "Домашний Адрес",
"phone" : "+111111111",
View gist:8672923
<?php
namespace PrestoHeads\BrainGames\CoreBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\HttpFoundation\Request;
View gist:8647793
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
You can’t perform that action at this time.