Skip to content

Instantly share code, notes, and snippets.

View briedis's full-sized avatar
🪵

Mārtiņš Briedis briedis

🪵
View GitHub Profile
@briedis
briedis / CacheInterface.php
Last active August 24, 2021 17:23
Cache interface
<?php
interface CacheInterface
{
/**
* Store a mixed type value in cache for a certain amount of seconds.
* Supported values should be scalar types and arrays.
*
* @param string $key
* @param mixed $value
$url = 'https://www.googleapis.com/drive/v2/files/' . urlencode($_POST['googleFileId']) . '?alt=media';
$oAuthToken = $_POST['oAuthToken'];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
class AwesomeWrongApiWrapper
{
const COMPANIES = [
//
];
private function invalidate()
{
foreach (self::COMPANIES as $companyId) {
Cache::forget($this->getPositionKey($companyId));
@briedis
briedis / breezy-all-company-search-v2
Last active June 11, 2018 08:49
Breezy All-Company Wide Search
javascript:(function () {
var search = prompt('Ko meklēt?');
if (!search) {
return;
}
var parsedCompanies = {};
var results = [];
var pendingRequests = 0;
(function(){ // namespace (ignore)
// bez priv var
var Simple = Class(
/**
* @lends {Simple#}
*/
{
__NAME:'Simple',
(function () {
'use strict';
var List = Class({
/**
* @type {Array<string>}
*/
_items: [],
/**
<?php
if (!defined("ROOT")) {
include('config.inc');
include('db.inc');
}
// Section loader
if(isset($_GET['section']) && $_GET['section'] != ''){
include $_GET['section'] . '.php';
}
/**
*
* @param {T.LoadMore.Par} par
* @constructor
*/
T.LoadMore = function(par){
this.nextPageUrl = par.nextPageUrl;
this.node = par.node;
this.id = this.node.id;
this.autoLoads = par.autoLoads || 3;
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
(function () {
'use strict';
function something() {
alert(counter);
}
var myObject = new function(){
this.data = {
counter: 0