Skip to content

Instantly share code, notes, and snippets.

@smilesrg
smilesrg / pubapi_docs.html
Last active June 24, 2019 14:58 — forked from andreij/pubapi_docs.html
Chess.com Published-Data API
<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 March 10, 2017 15:59
Objects have to be passed by reference explicitly if function is replacing original object with cloned one.
<?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 August 29, 2015 14:17
PHP Factorial calculation usng BC Math extension
<?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 March 19, 2015 16:50
Register Globals emulation
<?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);
}
> 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" : [
{
> 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" : [
{
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]
{
"_id" : ObjectId("52e7c9744947253b568b4567"),
"avatar" : "http://cs5422.vk.me/u3688507/d_ada9050a.jpg",
"contract" : "12345",
"contractRequest" : {
"_id" : ObjectId("52e7f93c4947253b568b4568"),
"firstname" : "Сергей",
"lastname" : "Смирнов",
"address" : "Домашний Адрес",
"phone" : "+111111111",
<?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;
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <[email protected]>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}