This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
use Symfony\Component\Stopwatch\Stopwatch; | |
use Symfony\Component\EventDispatcher\EventDispatcher; | |
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher; | |
use Symfony\Component\EventDispatcher\GenericEvent; | |
use Symfony\Component\EventDispatcher\Event; | |
class EventSubscriber implements EventSubscriberInterface |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Silex\Application; | |
use Silex\SecurityServiceProvider; | |
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder; | |
$app = new Application(); | |
$app->register(new SecurityServiceProvider(), array( | |
'security.encoder.digest' => $app->share(function () use ($app) { | |
return new MessageDigestPasswordEncoder('md5', false, 1); | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
SETLOCAL EnableDelayedExpansion | |
SET _c=0 | |
FOR /F "delims=: tokens=1,2" %%A IN ('ipconfig') DO ( | |
FOR /F "tokens=2" %%C IN ("%%A") DO ( | |
IF !_c! EQU 0 IF /I %%C==IPv4. ( echo %%B & SET /A _c+=1 ) | |
) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Hello World!</title> | |
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400italic,400,700' rel='stylesheet' type='text/css'> | |
<link href='http://grommet.io/assets/latest/css/grommet.min.css' rel='stylesheet' type='text/css'> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.2/react.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.2/react-dom.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Controller; | |
use Silex\ControllerResolver as SilexControllerResolver; | |
use Symfony\Component\HttpFoundation\Request; | |
use \Pimple; | |
/** | |
* Extension of Silex\ControllerResolver, as that injects Application class if | |
* its requested by Controller by Typehinting; this looks for, and injects, | |
* services with same name as parameter argument and validates is the right |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Load WordPress | |
require_once 'path/to/www/wp-load.php'; | |
require_once ABSPATH . '/wp-admin/includes/taxonomy.php'; | |
// Set the timezone so times are calculated correctly | |
date_default_timezone_set('Europe/London'); | |
// Create post |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function iframe_render_shortcode($atts) { | |
$keys = array_flip(array_keys($atts)); | |
$params = shortcode_atts($keys, $atts); | |
$out = []; | |
foreach($params as $key => $val) { | |
$out[] = $key . '="' . $val . '"'; | |
} | |
return '<iframe ' . implode(' ', $out) . '></iframe>'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('rest_api_init', 'register_my_rest_field'); | |
/** | |
* It depends on term_meta key _thumbnail_id using the metadata API | |
* for terms. Only plugin I know uses this is Taxonomy Thumbnail: | |
* https://wordpress.org/plugins/sf-taxonomy-thumbnail/ instead of | |
* storing metadata for terms in wp_options or custom tables | |
*/ | |
function register_my_rest_field() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This is a straightforward example of what a ThemeClass may look like. It contains all the | |
* expected initialization, and wp_enqueue_script calls. | |
*/ | |
class ThemeClass | |
{ | |
protected $wp; | |
protected $themeDirectory; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fact(i) { | |
return i === 1 ? 1 : i * fact(i-1); | |
} | |
console.time('fact recursive naive'); | |
for(var i = 0; i<1000000 ; i++) { | |
var g=fact(170); | |
} | |
console.log(g); | |
console.timeEnd('fact recursive naive'); | |
metaparse("metafun fact_m(self, i, acc) { " + |