Skip to content

Instantly share code, notes, and snippets.

View iolufemi's full-sized avatar

Olanipekun Femi iolufemi

View GitHub Profile
@xentek
xentek / wp-unit-tests.md
Created August 26, 2012 19:06
WordPress Unit Tests Quick Start

WordPress Unit Tests Quick Start Guide

This quick start guide is geared towards installing PHPUnit on OSX in order to run the WordPress unit tests. It uses homebrew to install PHP using homebrew-php. You can likely skip this step if you've already got php and pear installed properly.

If you use MAMP, then try these instructions to use MAMP's php and pear to install PHPUnit.

install homebrew

ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
@adamloving
adamloving / temporary-email-address-domains
Last active May 31, 2024 15:43
A list of domains for disposable and temporary email addresses. Useful for filtering your email list to increase open rates (sending email to these domains likely will not be opened).
0-mail.com
0815.ru
0clickemail.com
0wnd.net
0wnd.org
10minutemail.com
20minutemail.com
2prong.com
30minutemail.com
3d-painting.com
@enreeco
enreeco / ExpressJS rawBody
Last active August 7, 2016 17:37
NodeJS ExpressJS Getting Raw Body on request object
app.configure(function() {
//. . .
app.use(express.bodyParser());
app.use(function(req, res, next) {
var data = '';
req.setEncoding('utf8');
req.on('data', function(chunk) {
data += chunk;
});
req.on('end', function() {
@kerimdzhanov
kerimdzhanov / random.js
Last active June 25, 2024 19:41
JavaScript: get a random number from a specific range
/**
* Get a random floating point number between `min` and `max`.
*
* @param {number} min - min number
* @param {number} max - max number
* @return {number} a random floating point number
*/
function getRandomFloat(min, max) {
return Math.random() * (max - min) + min;
}
@jblashill
jblashill / promise.spread.js
Last active May 5, 2023 08:43
An extension to the Promise prototype to "spread" resolved data from Promise.all() to multiple function parameters
var Promise = require('es6-promise').Promise;
// idea borrowed from Q.spread
Promise.prototype.spread = function(fn) {
return this.then(function() {
if (!arguments || arguments.length === 0) {
return fn.apply();
}
return fn.apply(null, arguments[0]);
});
@justmoon
justmoon / custom-error.js
Last active June 26, 2024 09:36 — forked from subfuzion/error.md
Creating custom Error classes in Node.js
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
require('util').inherits(module.exports, Error);
@yoavniran
yoavniran / ultimate-ut-cheat-sheet.md
Last active July 12, 2024 11:15
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest
### I assume you run the commands as root
gradle_version=2.6
wget -c http://services.gradle.org/distributions/gradle-${gradle_version}-all.zip
unzip gradle-${gradle_version}-all.zip -d /opt
ln -s /opt/gradle-${gradle_version} /opt/gradle
printf "export GRADLE_HOME=/opt/gradle\nexport PATH=\$PATH:\$GRADLE_HOME/bin\n" > /etc/profile.d/gradle.sh
source /etc/profile.d/gradle.sh
# check installation
gradle -v
@dimasch
dimasch / redis-clear
Last active July 5, 2024 07:16
Clear a redis cache in Docker
docker exec -it container-name redis-cli FLUSHALL
@olanipekunife
olanipekunife / paginations.jsx
Last active August 19, 2019 17:02
react component that can be used with Express-REST-API-Generator
import React from 'react';
const Paginations = React.memo(({ pages, lastpage, page, prev, next, pageClick }) => {
let paginations = [], showNext = page + 3, showLast = pages - 3, lastpaginations = []
for (let i = 1; i <= pages; i++) {
//show last 3
if (i >= page - 3) {
if (i < showNext) {
paginations.push(<li key={i} className={`page-item ${page === i && 'active'}`}><button onClick={() => page !== i && pageClick(i)} className="link-button page-link">{i}</button></li>)
} else if (i > showLast) {