This file contains 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 | |
//Don't forget to change the namespace! | |
namespace App\Traits; | |
use Cron\CronExpression; | |
use Illuminate\Support\Carbon; | |
use Illuminate\Console\Scheduling\ManagesFrequencies; | |
trait Schedulable{ |
This file contains 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
var ctx = null, usingWebAudio = true; | |
try { | |
if (typeof AudioContext !== 'undefined') { | |
ctx = new AudioContext(); | |
} else if (typeof webkitAudioContext !== 'undefined') { | |
ctx = new webkitAudioContext(); | |
} else { | |
usingWebAudio = false; | |
} |
This file contains 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
#!/usr/bin/env php | |
<?php | |
echo "Running tests.. "; | |
exec('vendor/bin/phpunit', $output, $returnCode); | |
if ($returnCode !== 0) { | |
// Show full output | |
echo PHP_EOL . implode($output, PHP_EOL) . PHP_EOL; | |
echo "Aborting commit.." . PHP_EOL; |
This file contains 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 | |
// See http://www.php.net/manual/en/class.domelement.php#101243 | |
function get_inner_html( $node ) { | |
$innerHTML= ''; | |
$children = $node->childNodes; | |
foreach ($children as $child) { | |
$innerHTML .= $child->ownerDocument->saveXML( $child ); | |
} | |
return $innerHTML; |
This file contains 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 | |
/** | |
* Class Chainable | |
* Wrapper for convenient chaining methods | |
* | |
* @author Stefano Azzolini <lastguest@gmail.com> | |
*/ | |
class Chainable { | |
private $instance = null; |
This file contains 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
/* | |
* anchor-include pattern for already-functional links that work as a client-side include | |
* Copyright 2011, Scott Jehl, scottjehl.com | |
* Dual licensed under the MIT | |
* Idea from Scott Gonzalez | |
* to use, place attributes on an already-functional anchor pointing to content | |
* that should either replace, or insert before or after that anchor | |
* after the page has loaded | |
* Replace: <a href="..." data-replace="articles/latest/fragment">Latest Articles</a> | |
* Before: <a href="..." data-before="articles/latest/fragment">Latest Articles</a> |
This file contains 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 | |
/** | |
* PHP var_export() with short array syntax (square brackets) indented 2 spaces. | |
* | |
* NOTE: The only issue is when a string value has `=>\n[`, it will get converted to `=> [` | |
* @link https://www.php.net/manual/en/function.var-export.php | |
* @param mixed $expression | |
* @param bool $return | |
* @return string | |
*/ |
This file contains 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
namespace SHOpenFolderAndSelectItems | |
{ | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Runtime.CompilerServices; | |
using System.Runtime.InteropServices; | |
using System.Runtime.InteropServices.ComTypes; |
This file contains 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
/** | |
* Changes the requested URL to lowercase. | |
* | |
* Only if URL does not include a filename or query variable. | |
*/ | |
function force_lowercase_urls() { | |
// Grab requested URL | |
$url = $_SERVER['REQUEST_URI']; | |
// If URL contains a period, halt (likely contains a filename and filenames are case specific) | |
if ( preg_match('/[\.]/', $url) ) { |
This file contains 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
// Node.js implementation of Evan Miller's algorithm for ranking stuff based on upvotes: | |
// http://www.evanmiller.org/how-not-to-sort-by-average-rating.html | |
const stats = require('simple-statistics') | |
const lower_bound = (upvotes, n = 0, confidence = 0.95) => { | |
if (n === 0) return 0 | |
// for performance purposes you might consider memoize the calcuation for z | |
const z = stats.probit(1-(1-confidence)/2) |