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
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
@briedis
briedis / creating-components.js
Created September 23, 2016 13:01
Todo list example with Class and mkE
(function () {
'use strict';
// Lets create a simple checklist component, which can add items to the list, allow user to toggle check state,
// remove items, and display summary to the user
// Screen-shot: http://i.imgur.com/2ilIB6h.png
/* -------------- Main component -------------- */
var TodoList = Class({