Skip to content

Instantly share code, notes, and snippets.

@nb
nb / -
Created September 29, 2013 17:33
pbpaste| base64 -D > x.pdf
@nb
nb / -
Created October 27, 2013 09:38
#!/bin/sh
LANG_DIR=/var/www/nb/nikolay.bg/bgbg/wp-content/languages
D=$LANG_DIR/tmp
/usr/bin/curl -s -o $D/bg_BG.po 'http://translate.wordpress.org/projects/wp/dev/bg/default/export-translations?format=po'
/usr/bin/curl -s -o $D/bg_BG.mo 'http://translate.wordpress.org/projects/wp/dev/bg/default/export-translations?format=mo'
/usr/bin/curl -s -o $D/admin-bg_BG.po 'http://translate.wordpress.org/projects/wp/dev/admin/bg/default/export-translations?format=po'
/usr/bin/curl -s -o $D/admin-bg_BG.mo 'http://translate.wordpress.org/projects/wp/dev/admin/bg/default/export-translations?format=mo'
@nb
nb / prio.php
Created November 27, 2013 16:01
<?php
add_filter( 'import_original_array', function( $args ) {
if ( isset( $args['references'] ) && preg_match( '|wp-content/themes/premium|', $args['references'] ) ) {
$args['priority'] = 'hidden';
}
return $args;
} );
#!/bin/sh
WP_CONTENT="path to the wp-content directory of your install"
LANG_DIR=$WP_CONTENT/languages
TMP=$LANG_DIR/tmp
mkdir -p $TMP
/usr/bin/curl -s -o $TMP/bg_BG.po 'http://translate.wordpress.org/projects/wp/dev/bg/default/export-translations?format=po'
/usr/bin/curl -s -o $TMP/bg_BG.mo 'http://translate.wordpress.org/projects/wp/dev/bg/default/export-translations?format=mo'
@nb
nb / gist:677b416912e14ec44b16
Created September 18, 2014 13:22
Keybase Verification
### Keybase proof
I hereby claim:
* I am nb on github.
* I am nikolayb (https://keybase.io/nikolayb) on keybase.
* I have a public key whose fingerprint is 5B90 5510 BE15 69CB 2D45 146F 9452 16AC 9610 D078
To claim this, I am signing this object:
it( 'should handle series of same component', function() {
var expectedResultString = '<span><a href="#">baba</a><a href="#">dyado</a></span>',
translatedComponent = translate( '{{link}}baba{{/link}}{{link}}dyado{{/link}}', { components: { link: link } } );
assert.equal( expectedResultString, stripReactAttributes( React.renderToString( translatedComponent ) ) );
} );
it( 'should handle wrong cross-nesting', function() {
var expectedResultString = '', // how do we return error?
translatedComponent = translate( '{{link}}a{{em}}b{{/link}}c{{/em}}', { components: { link: link, em: em } } );
assert.equal( expectedResultString, stripReactAttributes( React.renderToString( translatedComponent ) ) );
@nb
nb / gist:e6698066e0b0d686a026
Created February 20, 2015 22:53
ssh into a container for debugging
# look for the ID of the `default` VM
vagrant global-status
vagrant ssh <default-id>
# install nsenter
docker run -v /usr/local/bin:/target jpetazzo/nsenter
# get the container id, not the image id
docker ps
import unittest
def is_interval(interval, **kwargs):
to_list = lambda value: [value] if isinstance(value, basestring) else value
list_from_kwarg = lambda key: to_list(kwargs.get(key, []))
units = ['y', 'm', 'd', 'h', 'i', 's']
only = list_from_kwarg('only')
if only:
return is_interval(interval, with_ = only, without = list(set(units) - set(only)))
with_ = list_from_kwarg('with_')
// to run place your solution in index.js and run: babel-node --stage 0 test.js
import assert from 'assert';
import toTitleCase from './index';
const tests = [
{
"input": "follow step-by-step instructions",
"expect": "Follow Step-by-Step Instructions"
},
{
"input": "this sub-phrase is nice",
<?php
/**
* Retrieve category, tag, or term description.
*
* @since 4.1.0
*
* @return string Archive description.
*/
function get_the_archive_description() {
$description = '';