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
class FancyString { | |
let name: String | |
init () { // Called one time | |
print("init") | |
name = "Frederik" | |
} | |
deinit { // Called one time | |
print("deinit") |
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 DbManager from './dbManager'; | |
let dbManager = new DbManager(process.env.DB_CONN_STRING); | |
(async function main() { | |
for(let entity of json) { | |
let { entityId } = await dbManager.insertEntity(entity); | |
} | |
})(); |
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
console.log('*** VARIABLES ***'); | |
// Declaration (make a new variable, and give it a name) | |
var person; | |
// Assignment (put a value inside the variable) | |
person = "Tomomi"; | |
console.log(person); | |
person = "Frederik"; |
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 SystemConfiguration | |
public class Reachability { | |
class func isConnectedToNetwork() -> Bool { | |
var zeroAddress = sockaddr_in() | |
zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress)) | |
zeroAddress.sin_family = sa_family_t(AF_INET) | |
let defaultRouteReachability = withUnsafePointer(&zeroAddress) { | |
SCNetworkReachabilityCreateWithAddress(nil, UnsafePointer($0)) | |
} |
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
// First creates a shallow copy of array, | |
// then shifts contents circularly according to | |
// number of steps and direction given | |
function circularShift(arrayPar, steps, shiftLeft) { | |
var array = arrayPar.slice(0); | |
for(var i = 0; i < steps; i++) { | |
if(shiftLeft) | |
array.push(array.shift()); | |
else |
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
<!DOCTYPE html> | |
<html data-ng-app="angular-client-side-auth" lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Angular Auth Example</title> | |
<link href="/css/app.css" rel="stylesheet"> | |
<link href="/components/bootstrap/dist/css/bootstrap.min.css" rel= | |
"stylesheet"> |
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
var mongoose = require('mongoose') | |
, Schema = mongoose.Schema | |
, passport = require('passport') | |
, bcrypt = require('bcrypt') | |
, check = require('validator').check | |
, Validator = require('validator').Validator; | |
var userSchema = new Schema({ | |
email: { type: String, unique: true, required: true }, | |
salt: { type: String, required: true }, |
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
function ensureAuthorized(req, res, next) { | |
var role; | |
if(!req.user) role = userRoles.public; | |
else role = req.user.role; | |
var accessLevel = _.findWhere(routes, { path: req.route.path }).accessLevel || accessLevels.public; | |
if(!(accessLevel.bitMask & role.bitMask)) return res.send(403); | |
return next(); | |
} |
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
module.exports = function(app) { | |
_.each(routes, function(route) { | |
var args = _.flatten([route.path, route.middleware]); | |
switch(route.httpMethod.toUpperCase()) { | |
case 'GET': | |
app.get.apply(app, args); | |
break; | |
case 'POST': |
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
<button access-level="accessLevels.user">Add</button> | |
<button access-level="accessLevels.user">Edit</button> | |
<button access-level="accessLevels.admin">Delete</button> |
NewerOlder