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
<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
@khepin
khepin / EasterEgg.js
Last active December 13, 2015 21:18
EasterEgg.js
function EasterEgg(egg, cb) {
this.egg = egg;
this.cb = cb;
this.start();
}
EasterEgg.prototype.start = function() {
var egg = this.egg;
var buffer = [];
var cb = this.cb;
describe(['class_to_be_tested'], function(my_class){
// Jasmine code
});