type below:
brew update
brew install redis
To have launchd start redis now and restart at login:
brew services start redis
| #!/bin/bash | |
| if [ ! $1 ]; then | |
| echo " Example of use: $0 database_name dir_to_store" | |
| exit 1 | |
| fi | |
| db=$1 | |
| out_dir=$2 | |
| if [ ! $out_dir ]; then | |
| out_dir="./" |
| { | |
| "quotes": [ | |
| { | |
| "quote": "Life isn’t about getting and having, it’s about giving and being.", | |
| "author": "Kevin Kruse" | |
| }, | |
| { | |
| "quote": "Whatever the mind of man can conceive and believe, it can achieve.", | |
| "author": "Napoleon Hill" | |
| }, |
| // Copied by https://gist.github.com/dotcypress/8fd12d6e886cd74bba8f1aa8dbd346aa, | |
| // thanks for improving code style | |
| const { createHash, createHmac } = require('crypto'); | |
| const TOKEN = "ABC:12345..."; | |
| // I prefer get the secret's hash once but check the gist linked | |
| // on line 1 if you prefer passing the bot token as a param | |
| const secret = createHash('sha256') | |
| .update(TOKEN) |
| // -- updated in 2020/04/19 covering the issues in the comments to this point | |
| // -- remember you also have things like `ensureDirSync` from https://github.com/jprichardson/node-fs-extra/blob/master/docs/ensureDir-sync.md | |
| const fs = require('fs') | |
| function writeFileSyncRecursive(filename, content, charset) { | |
| // -- normalize path separator to '/' instead of path.sep, | |
| // -- as / works in node for Windows as well, and mixed \\ and / can appear in the path | |
| let filepath = filename.replace(/\\/g,'/'); | |
| // -- preparation to allow absolute paths as well |
type below:
brew update
brew install redis
To have launchd start redis now and restart at login:
brew services start redis
| //calculate aspect ratio | |
| // Via: http://stackoverflow.com/questions/1186414/whats-the-algorithm-to-calculate-aspect-ratio-i-need-an-output-like-43-169 | |
| function gcd (a, b) { | |
| return (b == 0) ? a : gcd (b, a%b); | |
| } | |
| var w = screen.width; | |
| var h = screen.height; | |
| var r = gcd (w, h); | |
| console.log("Dimensions = " + w + " x " + h); |
| /* | |
| * Copyright (C) 2015 Mohib Sheth <[email protected]> | |
| * | |
| * Original Java version Copyright (C) 2014 Jared Rummler <[email protected]> | |
| * https://gist.github.com/jaredrummler/16ed4f1c14189375131d | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * |
| /** | |
| * Module dependencies. | |
| */ | |
| var express = require('express') | |
| , routes = require('./routes') | |
| , user = require('./routes/user') | |
| , http = require('http') | |
| , path = require('path'); |
Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
| function slugify(text) | |
| { | |
| return text.toString().toLowerCase() | |
| .replace(/\s+/g, '-') // Replace spaces with - | |
| .replace(/[^\w\-]+/g, '') // Remove all non-word chars | |
| .replace(/\-\-+/g, '-') // Replace multiple - with single - | |
| .replace(/^-+/, '') // Trim - from start of text | |
| .replace(/-+$/, ''); // Trim - from end of text | |
| } |