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 t(s,d){ | |
for(var p in d) | |
s=s.replace(new RegExp('{'+p+'}','g'), | |
typeof d[p][1]=='f' ? d[p]() : d[p]); | |
return s; | |
} | |
t("Hello {who}!", { who: "JavaScript" }); | |
// "Hello JavaScript!" | |
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 Hypebeast\DesktopBundle\Router; | |
use Symfony\Component\Routing\RouteCollection; | |
use Symfony\Component\Translation\TranslatorInterface; | |
use Symfony\Component\Routing\Route; | |
use JMS\I18nRoutingBundle\Router\PatternGenerationStrategyInterface; | |
use JMS\I18nRoutingBundle\Router\DefaultPatternGenerationStrategy; |
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_once __DIR__.'/../symfony/app/bootstrap.php.cache'; | |
require_once __DIR__.'/../symfony/app/AppKernel.php'; | |
use Symfony\Component\HttpFoundation\Request; | |
$kernel = new AppKernel('dev', true); | |
$kernel->loadClassCache(); | |
$response = $kernel->handle(Request::createFromGlobals()); |
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
#!/bin/sh | |
user='dev101' | |
site='hypebeast' | |
cd /home/$user/public_html/$site | |
sudo -H -u $user git pull origin v9 |
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
/** | |
* Namespacing | |
* All method start with "init" will be automatically called at start. | |
*/ | |
var popbee = {} | |
popbee.body = $("body"); | |
popbee.initHomepage = function() { | |
if(!popbee.body.hasClass("homepage") return; // return if not at homepage |
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 _add_body_class($classes, $custom_classes = false) | |
{ | |
the_post(); | |
// insert buddypress class on buddypress page | |
if ( function_exists("bp_is_blog_page") && !bp_is_blog_page() ) | |
$classes[] = 'buddypress'; | |
// add category |
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 get_trimmed_excerpt($maxChars = 160, $appendingString = '...', $default_excerpt = "Default page description.") | |
{ | |
if( !is_single() && !is_page() ) | |
return $default_excerpt; | |
the_post(); | |
$content = substr(get_the_excerpt(), 0, $maxChars); | |
$content = strip_tags($content); |
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 function will return "now", "3 seconds ago", "1 month ago" etc ... | |
function get_the_relative_time($time = null) | |
{ | |
if(is_null($time)) $time = get_the_time("U"); | |
$time_diff = date("U") - $time; // difference in second | |
$second = 1; | |
$minute = 60; |
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
#!/bin/sh | |
cd /home/dstrt/www | |
unset GIT_DIR | |
git pull origin master |
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
<? | |
/** | |
* Give name to preg_match | |
*/ | |
$haystack = '01 Jan 1970'; | |
$pattern = '/(?<day>\d{1,2})\ (?<month>Jan|Feb)\ (?<year>19\d\d)/'; | |
preg_match($pattern, $haystack, $matches); | |
print_r($matches); |