Skip to content

Instantly share code, notes, and snippets.

Avatar
🎧
‌‌

Wagner Souza waghcwb

🎧
‌‌
View GitHub Profile
@waghcwb
waghcwb / delete-slack-messages.js
Last active Jun 3, 2019 — forked from firatkucuk/delete-slack-messages.js
Deletes slack public/private channel and chat messages.
View delete-slack-messages.js
#!/usr/bin/env node
// Channel ID is on the the browser URL.: https://mycompany.slack.com/messages/MYCHANNELID/
// Pass it as a parameter: node ./delete-slack-messages.js CHANNEL_ID
// CONFIGURATION #######################################################################################################
const token = '<token>'; // You can learn it from: https://api.slack.com/custom-integrations/legacy-tokens
// GLOBALS #############################################################################################################
View fresh-install-windows.md

choco install 7zip.install

choco install putty.install

choco install nodejs.install

choco install skype

choco install python2

View convertToSeconds.js
// timeFormat = 'mm:ss'
function convertToSeconds(time) {
const [ minutes, seconds ] = time.split(':')
const minutesToSeconds = (Number(minutes) * 60)
return minutesToSeconds + Number(seconds)
}
@waghcwb
waghcwb / encrypt.js
Last active Apr 19, 2019 — forked from vlucas/encryption.js
Stronger Encryption and Decryption in Node.js
View encrypt.js
const crypto = require('crypto')
function encrypt(text) {
let key
let iv = crypto.randomBytes(16)
let hash = crypto.createHash('sha1')
hash.update(text)
return hash.digest().slice(0, 16).toString('hex')
View save-blob.js
const link = document.getElementById('link')
const data = { username: 'waghcwb' }
const json = JSON.stringify(data, null, 2)
const blob = new Blob([json], { type: 'octet/stream' })
const url = window.URL.createObjectURL(blob)
link.href = url
link.download = 'username.json'
View range-function.js
/**
* range()
*
* Returns an array of numbers between a start number and an end number incremented
* sequentially by a fixed number(step), beginning with either the start number or
* the end number depending on which is greater.
*
* @param {number} start (Required: The start number.)
* @param {number} end (Required: The end number. If end is less than start,
* then the range begins with end instead of start and decrements instead of increment.)
View getArrayOfDoubles.js
function getArrayOfDoubles(size = 30, factor = 0.5) {
return Array(size).fill(0).map((item, index) => Number((index * factor).toFixed(1))).splice(1)
}
View await-global.js
function awaitGlobal(keys, wait = 300) {
return Promise.all(
[].concat(keys).map(key => {
return new Promise((resolve, reject) => {
let timer
const loop = () => {
if (key.indexOf('.') > -1) {
try {
let __key = key.split('.')[0]
if (root[__key]) {
View prettier-only-staged.sh
# runs prettier only in modified files on git
git diff --name-only | xargs prettier --config ./prettier.config.js --write
View masked-fetch.js
const i = 'gfudi'
const k = s => s.split('').map(c => String.fromCharCode(c.charCodeAt() - 1)).join('')
self[k(i)](url)