This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Connection, createPool, createConnection, Pool } from 'mysql'; | |
import { MYSQL_DATABASE, MYSQL_HOST, MYSQL_PASSWORD, MYSQL_PORT, MYSQL_USER } from './config.service'; | |
import { InternalServerError } from 'http-errors'; | |
import { LoggerService } from './logger.service'; | |
import { isEmpty } from '../lib/utilities'; | |
const logger = LoggerService.getInstance(); | |
export class MySQLService { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* fUCK yOU php | |
* | |
* @craig552uk | |
*/ | |
<?php | |
You echo to the browser, not to std out. | |
So I hunt for bugs in XHRs or (here or (there about)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Promises can only resolve (return) a single value | |
// Sometimes, you want to collect multiple values as you progress through a promise chain | |
// e.g. Customer, Product, Basket, Payment Details | |
// | |
// I can only think of three options for handling this type of scenario (below) | |
// NB: Assume that FOO, BAR & BAZ are the result of some complex action (DB query etc.) | |
// | |
// What are the Pro's & Cons? | |
// Are there others? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Wrong ways to use Errors in Promises | |
// | |
// Passes Error constructor to next step in Promise chain | |
Promise.resolve('foo').then(val => { | |
return Error('Bad Thing 1'); | |
}).then(val => { | |
console.log('LOG 1', val); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# | |
# Author: Craig Russell <[email protected]> | |
# Simple exceptions for HTTP Errors | |
# http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml | |
# | |
# Example: | |
# | |
# try: | |
# raise BadRequest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# > telnet localhost 4000 | |
# Trying 127.0.0.1... | |
# Connected to localhost. | |
# Escape character is '^]'. | |
# hello | |
# world | |
# | |
# Connection closed by foreign host. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# | |
# A simple memory cache library | |
# Author: Craig Russell <[email protected]> | |
# | |
import time | |
class Cache(object): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# | |
# Author: Craig Russell <[email protected]> | |
# | |
# Find all KIS widgets in a site and check if they work | |
# Requires Python 2.7 | |
import urllib2 | |
from urlparse import urljoin | |
from urlparse import urlparse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Basics of the Unix Philosophy | |
============================= | |
Rule of Modularity: Write simple parts connected by clean interfaces | |
Rule of Clarity: Clarity is better than cleverness | |
Rule of Composition: Design programs to be connected with other programs | |
Rule of Separation: Separate policy from mechanism; separate interfaces from engines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- |
NewerOlder