Skip to content

Instantly share code, notes, and snippets.

View khepin's full-sized avatar

Sebastien Armand khepin

  • San Francisco, USA
View GitHub Profile
package requestcontext
type RequestLogger struct{}
type User struct{}
type RequestContextValues struct {
Logger RequestLogger
User User
}
@khepin
khepin / cookies.js
Last active February 16, 2018 04:06
console.log('reading cookies');
console.log(document.cookie);
console.log('finished reading cookies');
<?php
$parentClass = 'Some\Class\Name';
$anonObject = new class() extends $parentClass {};
<?php
class CreativeMarket_Sniffs_Functions_FunctionLengthSniff implements PHP_CodeSniffer_Sniff
{
const MAX_NUM_LINES = 30;
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
if (!function_exists('debuglog')) {
function debuglog($message) {
if (!is_string($message)) {
$message = print_r($message, true);
}
$message .= "\n";
$dir = ROOT . '/../logs/';
if (!is_dir($dir)) {
mkdir($dir);
}
/*
Le browser ne trigger aucun "blur" tant que la fenêtre du browser n'est pas active.
Ca peut se vérifier via un simple script dans ta console que tu laisses tourner avec un compteur de "blur"
Du coup on s'était résiliés à une fonction helper qui injecte du JS dans la page et
déclenche manuellement le "blur"
*/
function blurElement(selector) {
element(by.css(selector)).sendKeys(protractor.Key.TAB); // Element cannot have focus.
<span translate>Hello</span>
<!-- This one works standard, normal, no issues -->
<span translate>{{ widget_title }}</span>
<!-- How about this case? -->
/**
* This defines a simple widget
*/
function simpleWidget(){};
simpleWidget.$tags = [
{name: 'widget', value: {width: 1, height: 1}}
];
/**
* This defines a more complex one that depends on other services
swiftmailer:
spool: { type: memory }
transport: smtp
host: mailtrap.io
username: xxxxxxxx
password: xxxxxxxx
encryption: ~
auth_mode: plain
port: 2525
@khepin
khepin / example.js
Last active December 14, 2015 00:58
JS lazy evaluation and storing patterns
var SomeObject = {
views: {
firstPage: _.memoize(function(){
return new FirstPageView();
}) // Here all we have done is declare a function
// This function was never executed
},
renderFirstPage: function() {
var v = this.views.firstPage(); // Either the function is executed