Skip to content

Instantly share code, notes, and snippets.

View robophil's full-sized avatar
🍷
Working from home

Balogun Oghenerobo Philip robophil

🍷
Working from home
View GitHub Profile
@robophil
robophil / Infix to postfix.js
Last active October 11, 2019 06:04
## Read me ## Javascript infix to postfix conversion (shunting yard algorithm). It also solves the expression passed to it after conversion to post fix, can be used for building a calculator ---->Reference the js script to your page html page, pass the arithmetic problem you wanna solve and voila it returns an ans, oh.. if there's an error, it r…
Array.prototype.peek = function () {
return this[this.length - 1];
};
/**
*This function accepts a string input for calculation, turns it into
*an array of token in infix notation, futher into postfix notation and
*returns an answer to the inputStr passed in or false if an error was
*found in the inputStr
**/
function infix2postfix(inputStr) {
@robophil
robophil / .vimrc
Last active May 13, 2019 09:08
configuration for my per project .vimrc
let $PATH = './node_modules/.bin:' . $PATH
let g:used_javascript_libs = 'react'
autocmd BufNewFile,BufEnter **/*.js setlocal filetype=javascript.jsx
if filereadable(".ctrlpignore")
let g:ctrlp_user_command = 'find %s -type f | grep -v "`cat ./.ctrlpignore`"'
endif
@robophil
robophil / env-examples.md
Created April 20, 2017 14:46 — forked from ericelliott/env-examples.md
env-examples

Most configuration really isn't about the app -- it's about where the app runs, what keys it needs to communicate with third party API's, the db password and username, etc... They're just deployment details -- and there are lots of tools to help manage environment variables -- not the least handy being a simple .env file with all your settings. Simply source the appropriate env before you launch the app in the given env (you could make it part of a launch script, for instance).

env files look like this:

SOMEVAR="somevalue"
ANOTHERVAR="anothervalue"

To source it:

$ source dev.env # or staging.env, or production.env, depending on where you're deploying to

@robophil
robophil / php5.6-fpm.conf
Last active August 21, 2018 00:32
Configure apache2.4 and php5.6-fpm
# location for config
# /etc/apache2/conf-available/php5.6-fpm.conf"
<IfModule mod_fastcgi.c>
AddHandler php5.6-fcgi .php
Action php5.6-fcgi /php5.6-fcgi
Alias /php5.6-fcgi /usr/lib/cgi-bin/php5.6-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5.6-fcgi -socket /var/run/php/php5.6-fpm.sock -pass-header Authorization -idle-timeout 3600
<Directory /usr/lib/cgi-bin>
Require all granted
</Directory>
@robophil
robophil / mocha-guide-to-testing.js
Created April 11, 2018 08:10 — forked from samwize/mocha-guide-to-testing.js
Explain Mocha's testing framework - describe(), it() and before()/etc hooks
// # Mocha Guide to Testing
// Objective is to explain describe(), it(), and before()/etc hooks
// 1. `describe()` is merely for grouping, which you can nest as deep
// 2. `it()` is a test case
// 3. `before()`, `beforeEach()`, `after()`, `afterEach()` are hooks to run
// before/after first/each it() or describe().
//
// Which means, `before()` is run before first it()/describe()
@robophil
robophil / magento_url_rewrite.patch
Created April 8, 2018 08:02 — forked from edannenberg/magento_url_rewrite.patch
Fixes the catalog url rewrite indexer in Magento 1.7.x-1.9.x See https://github.com/magento/bugathon_march_2013/issues/265 for details.Update: DexterDee in the ticket above noted that the previous patch had some side effects. This updated patch still feels like duct tape but at least it seems to be free of the mentioned side effects. It also fix…
diff -rupN mage_org/app/code/core/Mage/Catalog/Model/Url.php src_shop/app/code/core/Mage/Catalog/Model/Url.php
--- mage_org/app/code/core/Mage/Catalog/Model/Url.php 2013-11-19 00:48:25.679009391 +0100
+++ src_shop/app/code/core/Mage/Catalog/Model/Url.php 2013-11-19 00:49:24.188005601 +0100
@@ -643,13 +643,24 @@ class Mage_Catalog_Model_Url
$this->_rewrite = $rewrite;
return $requestPath;
}
+
+ // avoid unnecessary creation of new url_keys for duplicate url keys
+ $noSuffixPath = substr($requestPath, 0, -(strlen($suffix)));
// GET https://api.fixer.io/latest?base=USD
{
"base": "USD",
"date": "2018-01-30",
"rates": {
"AUD": 1.2354,
"BGN": 1.5746,
"BRL": 3.1624,
"CAD": 1.2321,
"CHF": 0.93302,
@robophil
robophil / .bashrc
Last active January 23, 2018 22:22
cuda
export PATH=/usr/local/cuda-9.1/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.1/lib64\${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
@robophil
robophil / promisesEM.md
Created January 18, 2018 10:14 — forked from dmvaldman/promisesEM.md
Promises as EventEmitters

Promises as EventEmitters

I was trying to understand JavaScript Promises by using various libraries (bluebird, when, Q) and other async approaches.

I read the spec, some blog posts, and looked through some code. I learned how to