Skip to content

Instantly share code, notes, and snippets.

View josephfinlayson's full-sized avatar

Joseph Finlayson josephfinlayson

View GitHub Profile
//all are /application/json
//Offering an item
// POST request to endpoint /api/postItem
{
itemName: String,
itemPrice: Number,
Description: String,
lockerCode: String,
image: String, //BASE64

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@josephfinlayson
josephfinlayson / Opencart info.txt
Created April 16, 2012 01:08
Quick and dirty way for adding information pages on the top OpenCart Menu
Create a top level category in opencart - call it 'about us'
Add description, set it to show on the top level
Click on it. It looks great, it shows the information you want it to show... but it says this:
There are no products to list in this category.
Get rid of it to navigating to:
@josephfinlayson
josephfinlayson / gist:2519418
Created April 28, 2012 14:23
useful perl script to rename files+ a number
NUM=0 ; for FILE in * ; do NUM=`expr $NUM + 1` ; mv $FILE $NUM\.jpg ; done
[
{
"code": "1001",
"category": "HOME",
"type": "SUBSCRIPTION",
"name": "Home emergency assistance and insurance",
"description": "We cover the typical mishaps you may encounter: If you lost your keys, a window or door gets broken and many more. Our assistance service is able to dispatch every type of craftsmen at no additional cost & at high quality and guaranteed low cost. 12 month subscription, coverage max. 1,500 per incident.",
"price": 119
},
@josephfinlayson
josephfinlayson / ngProgressUIRouter
Created November 7, 2014 15:15
Pattern to combine ngProgress and ui router
'use strict';
angular.module('something', [
'deps'
])
.config(function($locationProvider) {
$locationProvider.html5Mode(true);
})
.config(function($provide) {
return $provide.decorator('$uiViewScroll', function($delegate, $window) {
return function(uiViewElement) {
@josephfinlayson
josephfinlayson / gist:5489278
Created April 30, 2013 14:59
Select shapes by style and colour, extract text, in powerpoint
Sub GetAllText()
Dim p As Presentation: Set p = ActivePresentation
Dim s As Slide
Dim sh As Shape
For Each s In p.Slides
For Each sh In s.Shapes
If sh.HasTextFrame Then
If sh.Type = msoShapeStylePreset1 Then
If sh.Fill.ForeColor = RGB(242, 242, 242) Or sh.Fill.BackColor = RGB(242, 242, 242) Then
If sh.TextFrame.HasText Then
@josephfinlayson
josephfinlayson / gist:6089286
Created July 26, 2013 14:28
Shell script to pull updates from git for all subfolders
files=`ls $1`
for file in $files; do
if [ -d $file ];then
cd $file
git pull
git checkout rel-15
cd ..
fi
done
arr=(git@github.com:asd/dasde.git
git@github.com:asform/dni_wpasdager.git
)
for git in "${arr[@]}"
do
git clone $git
done
@josephfinlayson
josephfinlayson / gist:6209492
Last active December 20, 2015 22:59
vanity url remover
DELETE *
FROM `wp_postmeta`
WHERE `meta_key` = 'vanity_url'
OR `meta_key` = '_dest_page_id'
DELETE *
FROM `wp_posts`
WHERE `post_type` = 'vanity_url'
DELETE FROM `wp_fusion`.`wp_posts` WHERE `wp_posts`.`ID` = 489 LIMIT 1;