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
(function ($) { | |
'use strict'; | |
$.fn.originalRemoveClass = $.fn.removeClass; | |
$.fn.removeClass = function (arg) { | |
if (arg instanceof RegExp) { | |
return this.originalRemoveClass(function (i, css) { | |
var remove = []; | |
$.each(css.split(/\s+/), function (i, cls) { |
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 | |
/** | |
* Creates a progress bar | |
* | |
* @param string $template Template to use, available placeholders are %finished, %unfinished, %percent and %eta | |
* @param int $width Width of the progress bar | |
* @return callable A function that renders the bar and takes the percent as only argument | |
*/ | |
function progressBar( |
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 | |
/** | |
* @param int $seconds | |
* @return string | |
*/ | |
function duration($seconds) | |
{ | |
foreach (['wk' => 604800, 'day' => 86400, 'hr' => 3600, 'min' => 60, 'sec' => 1] as $symbol => $subunit) { | |
$value = (int) floor($seconds / $subunit); |
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 ObjectId | |
{ | |
/** @var string */ | |
private $value; | |
/** | |
* @param string $value | |
*/ |
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 IDateTime extends \DateTime | |
{ | |
public function __construct($time = 'now', $timezone = null) | |
{ | |
if ($time === null || $time === 'now') { | |
$ts = microtime(true); | |
$micro = sprintf('%06d',($ts - floor($ts)) * 1000000); | |
$time = date('Y-m-d H:i:s.' . $micro, $ts); |
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
#!/bin/bash | |
if [ -z "$1" ] | |
then | |
echo "Usage $0 <token> [ip]" | |
exit | |
fi | |
if [ -n "$2" ] | |
then |
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 | |
/** | |
* Checks if a value exists in an array | |
* | |
* @param array $haystack | |
* @param mixed $needle | |
* @param bool $strict | |
* @return bool | |
*/ |
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
$('body').on('submit', 'form.ajax', function () { | |
var form = $(this); | |
$.ajax({ | |
type: form.attr('method') || 'GET', | |
url: form.attr('action') || location.href, | |
data: form.serialize(), | |
success: function (data, textStatus, jqXHR) { | |
form.trigger('success', [data, textStatus, jqXHR]); | |
}, |
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
<? $a='<? $a=\'%s\';printf($a,addslashes($a));';printf($a,addslashes($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
#include <stdio.h> | |
#include <stdlib.h> | |
int main(int argc, char *argv[]) | |
{ | |
char *p = malloc(1024); | |
int l[10], j = 0, i = 0; | |
while (argv[1][i]) { | |
switch (argv[1][i++]) { |