//creates an instance and connects
var socket = new SillySockets(io, {
baseUrl: '<sockets-server-address>',
appId: 'ABCDE12345',
debug: true,
tags: ['superawesomeclient', 'iphone']
});
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
| # Allows us to read user input below, assigns stdin to keyboard | |
| exec < /dev/tty | |
| printf "About to push to remote...\n" | |
| # read user input with <message>, continue when input length is <n> | |
| read -p "Run some checks first? [Y/n] " -n 1 cont | |
| printf "\n" |
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
| var gm = require('gm'), | |
| app = require('express')(); | |
| app.get('/:width/:height', function(req, res){ | |
| gm('download.jpeg') | |
| .resize(req.params.width, req.params.height, '^') | |
| .gravity('Center') | |
| .crop(req.params.width, req.params.height) | |
| .toBuffer('PNG',function(err, buffer){ |
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>Counter Test</title> | |
| <style> | |
| * { | |
| margin: 0; | |
| padding: 0; | |
| box-sizing: border-box; |
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
| //put UITableView in a UIView and point the data source and delegate of the UITableView to the UIView | |
| class ListTableView: UIView, UITableViewDataSource, UITableViewDelegate { | |
| func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
| return 20 | |
| } | |
| func numberOfSectionsInTableView(tableView: UITableView) -> Int { | |
| return 1 |
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 SchemaParser { | |
| typeOptions = ["String", "Number", "Date", "Array", "Object", "Boolean"]; | |
| constructor(schema){ | |
| this._schema = schema; | |
| } | |
| _getValueType(value){ | |
| var type = {}.toString.call(value); | |
| return type.match(/\s(\w+)/)[1]; |
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
| //https://thatthinginswift.com/background-threads/ | |
| import Foundation | |
| //{ /* do some task on bg thread */ } ~> { /* update some UI on the main thread */} | |
| infix operator ~> {} | |
| private let queue = dispatch_queue_create("serial-worker", DISPATCH_QUEUE_SERIAL) |
npm install -g babel-node
npm install babel-preset-es2015
echo '{ "presets": ["es2015"] }' > .babelrc
babel-node index.js
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 Router { | |
| constructor(hashMode = true){ | |
| this._hashMode = hashMode; | |
| this._routes = {}; | |
| window.addEventListener(hashMode ? 'hashchange' : 'popstate', this.check.bind(this)); | |
| } | |
| add(route, ...callbacks){ | |
| if(this._hashMode){ |
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
Show hidden characters
| { | |
| "presets": ["es2015"] | |
| } |