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
function getDistinctObjectsBasedUponPropertyValue(array, distinctProperty) { | |
var tempArray = [] | |
return array.filter(function (n) { | |
return tempArray.indexOf(n[distinctProperty]) == -1 && tempArray.push(n[distinctProperty]) | |
}) | |
} |
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
function KeyPress(e) { | |
const { keyCode } = window.event ? event : e; | |
// If "a" is pressed, scroll up | |
if (keyCode == 65) { | |
window.scrollBy(0, -100) | |
} | |
// If "z" is pressed, scroll down | |
if (keyCode == 90) { |
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://data.stackexchange.com/stackoverflow/query/new | |
SELECT Answers.Id as [Post Link], Question.ViewCount | |
FROM Posts as Answers, Posts as Question | |
WHERE Answers.PostTypeId = 2 | |
AND Answers.OwnerUserId = ##UserId## | |
AND Question.Id = Answers.ParentId | |
ORDER BY Question.ViewCount DESC; |
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
process.env.NODE_ENV = 'production'; | |
const webpack = require('webpack'); | |
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; | |
const webpackConfigProd = require('react-scripts/config/webpack.config')('production'); | |
// this one is optional, just for better feedback on build | |
const chalk = require('chalk'); | |
const ProgressBarPlugin = require('progress-bar-webpack-plugin'); | |
const green = text => { |
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
/** | |
* USE FROM COMMAND LINE: | |
* node gzipper.js ./path/to/file.txt ./path/to/output/dir | |
*/ | |
const fs = require('fs'); | |
const path = require('path'); | |
const zlib = require('zlib'); | |
const SOURCE = path.resolve(__dirname, process.argv[2]); |
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
import React, { useState, useEffect } from 'react'; | |
const CONSTANTS = { | |
TYPING_SPEED: 30, | |
DELETING_SPEED: 150, | |
} | |
export default function TypeWriter({ messages, heading }) { | |
const [state, setState] = useState({ | |
text: "", |
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 isUsernameTaken = (username) => { | |
User.find({username: username}) | |
.exec() | |
.then((err, doc) => { | |
if(err) throw err; | |
return doc ? true : false; | |
}); | |
} |
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 request = require('request'); | |
let MY_THINGS = []; | |
function getItems() { | |
let url = 'https://jsonplaceholder.typicode.com/todos/'; | |
return new Promise((resolve, reject) => { | |
request.get(url, (err, res, body) => { | |
if(err) reject(err); | |
if(res.statusCode !== 200) reject(res.statusCode); |
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
#!/bin/bash | |
# USE LIKE: | |
# bash jenkinsUpdater.sh "updates.jenkins-ci.org/download/war/2.190.1/jenkins.war" | |
# Change these locations to suit your needs | |
BACKUP_ROOT_PATH=/usr/share/jenkins/backups | |
JENKINS_WAR_PATH=/usr/share/jenkins | |
DOWNLOAD_ROOT_PATH=~/downloads |
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 fs = require('fs'); | |
function deleteFolderRecursive(path) { | |
if (fs.existsSync(path) && fs.lstatSync(path).isDirectory()) { | |
fs.readdirSync(path).forEach(function (file, index) { | |
var curPath = path + "/" + file; | |
if (fs.lstatSync(curPath).isDirectory()) { | |
deleteFolderRecursive(curPath); | |
} else { | |
fs.unlinkSync(curPath); |