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
Array.from({ length: 100 }, (v, i) => [[15, 'fizzbuzz'], [5, 'buzz'], [3, 'fizz']]).find(x => (i+1) % x[0] === 0) || (i + 1)).reduce((a, o) => a += (o[1] || o) + "\n",'') | |
return | |
for(var i = 1; i< 101; i++){ | |
console.log( (i%3 === 0 ? 'FIZZ' + (i%5 === 0 ? 'BUZZ' : '') : i%5 === 0 ? 'BUZZ' : i)) | |
} | |
return | |
/* | |
for(var i=1; i<101; i++){ |
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
There's an easier way for the SSH and wifi: | |
* flash the card with etcher | |
* put empty file called "ssh" on SD card | |
* put "wpa_supplicant.conf" file on SD card | |
* insert SD card in Pi Zero W | |
You're done, Pi will boot with SSH enabled and will automatically connect to wifi. |
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
const LRU = require("lru-cache") | |
const options = { | |
max: 500, | |
// length: function (n, key) { return n * 2 + key.length }, | |
// dispose: function (key, n) { n.close() }, | |
maxAge: 1000 * 60 * 60 | |
} | |
const cache = LRU(options) | |
export default cache |
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
{ | |
"name": "reactcomponents", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"start": "webpack --debug --watch --colors", | |
"build": "webpack -p --optimize-minimize --config webpack.production.config.js", | |
"watch": "webpack --debug --watch", |
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
<html> | |
<input id="input"></input> | |
<div id='results'></div> | |
<script src="https://code.jquery.com/jquery.js"></script> | |
<script src="https://cdn.jsdelivr.net/rxjs/4.1.0/rx.lite.min.js"></script> | |
<script> | |
const $input = $('#input'); | |
const $results = $('#results'); |
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
filetype plugin indent on | |
syntax on | |
set shiftwidth=2 | |
set tabstop=2 | |
set hlsearch | |
set ignorecase " Do case insensitive matching | |
set incsearch " Incremental searcha | |
set showmatch " Show matching brackets | |
set smartcase " Do smart case matching | |
set virtualedit=block " Square up visual selections |
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
//------------------------------------------------------- | |
// QUESTION: Can you implement the Semaphore type? | |
// | |
// In systems programming, it is sometimes important | |
// to restrict the requests made to a given resource. | |
// The resource may be a CPU bound process, or a | |
// network resource. Controlling throughput to that | |
// resource can be challenging, but simplified through | |
// the use of a semaphore like primitive. | |
// |
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 fs = require("fs"); | |
if (!process.argv[2]) { | |
console.log("Must pass in target file!!"); | |
process.exit(1); | |
} | |
fs.readFile(__dirname + "/" + process.argv[2], "utf8", function(err, data) { | |
data = data.split(/\n/); | |
var sys = [], dia = []; |
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
I don't like to use any third party tools. Hence I used a combination of ssh configuration and firewall settings. With the following solution an attacker is allowed to produce exactly 3 fault logins in 2 minutes, until he will be blocked for 120 seconds. | |
1) Add the following line to /etc/ssh/sshd_config | |
MaxAuthTries 1 #This locked me out of my server | |
2) Add the following firewall rules |
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 fs = require('fs'); | |
function nodeToPromise(resolve, reject){ | |
return function(err, value){ | |
if(err){reject(err);} else{resolve(value)} | |
}; | |
} | |
function readFileAsync(file = "./t.js"){ | |
return new Promise((resolve, reject) =>{ |
NewerOlder