Skip to content

Instantly share code, notes, and snippets.

rettal

Block or report user

Report or block rettal

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View bling.js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active Dec 7, 2019
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew
View fix-homebrew-npm.md

READ THIS Very Important Update

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@Idered
Idered / script.js
Created Jan 5, 2014
Remove first and last empty lines, remove useless indentation. Good for parsing HTML
View script.js
var str = '\n\n\n Multiline text\n with indentation\n damn.\n\n\n';
// remove first and last empty lines
str = str.replace(/^[\r\n]+|[\n\r]+$/gi, '');
var indentTab = str.match(/\t*/) != '',
indentSize = indentTab ? 1 : str.match(/\s*/)[0].length,
regex = new RegExp('^(?:' + (indentTab ? '\\t' : ' {' + indentSize + '}') + ')', 'mg');
// Remove indent
@ralphschindler
ralphschindler / example.php
Created Oct 24, 2012
Zend\Db\Sql\Select example usage
View example.php
<?php
use Zend\Db\Sql\Select;
// basic table
$select0 = new Select;
$select0->from('foo');
// 'SELECT "foo".* FROM "foo"';
@wowo
wowo / PHPUnit way to mock Doctrine2 Entity Manager.php
Created Nov 1, 2011
PHPUnit's way to mock Doctrine2 Entity Manager
View PHPUnit way to mock Doctrine2 Entity Manager.php
<?php
class AbstractManagerBase extends \PHPUnit_Framework_TestCase
{
protected function getEmMock()
{
$emMock = $this->getMock('\Doctrine\ORM\EntityManager',
array('getRepository', 'getClassMetadata', 'persist', 'flush'), array(), '', false);
$emMock->expects($this->any())
->method('getRepository')
@ircmaxell
ircmaxell / Expressions.php
Created Sep 21, 2011
A math parser and evaluator implementation
View Expressions.php
<?php
class Parenthesis extends TerminalExpression {
protected $precidence = 6;
public function operate(Stack $stack) {
}
public function getPrecidence() {
return $this->precidence;
You can’t perform that action at this time.