Skip to content

Instantly share code, notes, and snippets.

View joelhinz's full-sized avatar

Joel Hinz joelhinz

  • Falkenberg, Sweden
View GitHub Profile
<?php
namespace App\Some\Path;
class ShortTermMemory
{
private $store = [];
public function set($key, $value)
{
export function bemify(block, modifiers) {
if (!modifiers) {
return block;
}
if (typeof modifiers == 'object' && !Array.isArray(modifiers)) {
modifiers = Object.keys(modifiers).filter(modifier => modifiers[modifier])
}
if (typeof modifiers == 'string') {
export function bemify(block, modifiers) {
return block + ' ' + modifiersToArray(modifiers)
.map(modifier => `${block}--${modifier}`)
.join(' ');
}
function modifiersToArray(modifiers) {
if (!modifiers) {
return []
}
// ==UserScript==
// @name Bet365 reality checker
// @version 0.1
// @namespace joelhinz
// @description Automatically click on "Förbli inloggad"
// @author Joel
// @include https://members.bet365.com/*
// @grant none
// ==/UserScript==
<?php
/**
* Render the view partial for the side component.
*
* @return string
*/
public function renderView()
{
$data = [
<?php
foreach ($this->lines as $line) {
if (!str_contains($line, ':')) {
$this->addError($line, 'No code found');
} else {
$this->convertLine($line);
}
}
function (event) {
event.preventDefault();
const activate = document.getElementById(this.dataset.activate);
const deactivate = document.getElementById(this.dataset.deactivate);
deactivate.classList.add('inactive');
deactivate.classList.remove('active');
setTimeout(() => {
<?php
// variables
$foo = 'bar';
$megafoo = 2345;
$superfoo = new AmaziClass();
// class properties
class Lingon
{
<?php
$countries->map(function ($country) {
return $country->capital;
})->reject(function ($capital) {
return $capital->isTiny();
})->partition(function ($capital) {
return $capital->hasMayor();
});
<?php
// vanliga arrayer
$capitals = [];
foreach ($countries as $country) {
$capitals[] = $country->capital;
}
// collections
$capitals = $countries->map(function ($country) {