This file contains hidden or 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
| class Account {} | |
| interface Bank { | |
| getAccounts(): Account[] | |
| setAccounts(accounts: Account[]): void | |
| } | |
| // "Plain Old JavaScript Object" implementing abstraction | |
| class BankImpl implements Bank { | |
| private accounts: Account[]; |
This file contains hidden or 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 { createReadStream, ReadStream } from 'fs' | |
| class ReadStreamFactory { | |
| private readStream: ReadStream | |
| private promiseResolve: (stream: ReadStream) => void | |
| private promiseReject: (reason: Error) => void | |
| static createReadStream(filename: string): Promise<ReadStream> { | |
| const factory = new ReadStreamFactory(filename) | |
| return factory.promisifyReadStream() |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Colors</title> | |
| <style> | |
| body { | |
| background-color: black; | |
| font-size: 10em; | |
| font-family: sans-serif; |
This file contains hidden or 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
| function missingRequired() { | |
| const thisFunc = arguments.callee; | |
| const caller = thisFunc.caller; | |
| const passedArgs = caller.arguments; | |
| const args = caller.toString() | |
| .replace(/((\/\/.*$)|(\/\*[\s\S]*?\*\/)|(\s))/mg,'') // remove all spacing | |
| .split(/function\s*\w+\(?/)[1] // remove 'function name (' | |
| .split(/\)\s*\{/)[0] // remove everything after ){ | |
| .split(/,/); // break apart into comma separated list of arguments |
This file contains hidden or 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
| class SinglyLinkedList { | |
| constructor(value = []) { | |
| if (Array.isArray(value)) { | |
| value.forEach(val => this.addAtEnd(val)) | |
| } else { | |
| this.value = value | |
| this.next = null | |
| } | |
| } |
This file contains hidden or 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
| // Source http://exploringjs.com/es6/ch_proxies.html#_accessing-a-restful-web-service-method-calls | |
| const gitHubService = createWebService('http://api.github.com'); | |
| gitHubService.feeds.get().then(data => { | |
| console.log(data.timeline_url); | |
| }); | |
| gitHubService.users.blrobin2.get().then(data => { | |
| console.log(data.avatar_url); |
This file contains hidden or 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
| <?php | |
| use Doctrine\ORM\Mapping as ORM; | |
| /** | |
| * Class EventStore | |
| * | |
| * @ORM\Entity | |
| * @ORM\Table(name="event_store") | |
| */ |
This file contains hidden or 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
| <?php | |
| /** | |
| * Checks for an image and moves it to the set folder. | |
| * | |
| * @param $image . The image, most likely from the Request object | |
| * @param $destination . The folder in source where it's going. | |
| * @return null|string | |
| */ | |
| function moveImage($image, $destination) |
NewerOlder