Instead of this:
if( person !== undefined && person.details !== undefined && person.details.city !== undefined )
Using this method you can use this:
if( person.testPath('details.city') )
Instead of this:
if( person !== undefined && person.details !== undefined && person.details.city !== undefined )
Using this method you can use this:
if( person.testPath('details.city') )
//Border | |
@mixin border($side:false, $color:$grey-light){ | |
@if $side { | |
border-#{$side}: $border-style $border-width $color; | |
} @else { | |
border: $border-style $border-width $color; | |
} | |
} | |
//Prefix property |
module.exports = function (grunt){ | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
appRoot: 'app', | |
connect: { | |
server: { |
grunt.registerTask('parse-includes', 'Parse include tags in HTML files', function(){ | |
//projects root and | |
//HTML files folder | |
var basePath = 'public/', | |
viewsDir = 'views/', | |
//get all HTML files in folder | |
htmlFiles = grunt.file.expand(basePath+viewsDir+'*.html'), | |
currFileContents; |
function genRandStr(length = 41){ | |
// Math.random returns number with length between 16 and 18 chars | |
// if length below 16 do in one go | |
if (length <= 16) { | |
return Math.random().toString(36).substring(2,length+2); | |
} | |
// else calculate how many iterations we need | |
const iterations = Math.ceil(length / 16); | |
let outputStr = ''; |
def makeAwesome(sayFunc): | |
def wrapper(*args): | |
print sayFunc(args[0]+" are awesome") | |
return wrapper | |
@makeAwesome | |
def say(name): | |
print name | |
""" | |
Equal to: makeAwesome(say), this returns wrapper. |
import xlrd | |
import json | |
import os.path | |
class ExcelToJson: | |
def convertFile(self, filePath, sheetName=None): | |
if not os.path.isfile(filePath): | |
print filePath+' does not exist or is not a file' |
=begin | |
Class that parses command line arguments | |
@author Koen Vendrik <k.vendrik@gmail.com> | |
@date November 2014 | |
=end | |
=begin | |
Simple Usage: | |
require_relative 'parse_args' |
class BinaryText | |
@eight_bit_nums = [128, 64, 32, 16, 8, 4, 2, 1] | |
def self.binaryToText(binary) | |
groups = binary.scan(/.{8}/) | |
resultStr = '' | |
# loop through groups of 8 | |
groups.each do |group| |
int cryptString (int argc, char* argv[]){ | |
char* s = argv[1]; | |
for(int i = 0; i < strlen(s); i++){ | |
int newAscii = (s[i]+6 > 122 ? ((s[i]+6)%122)+96 : s[i]+6); | |
printf("%c", newAscii); | |
} | |
} |