Skip to content

Instantly share code, notes, and snippets.

View waghcwb's full-sized avatar
🎧
‌‌

Wagner Souza waghcwb

🎧
‌‌
View GitHub Profile
@waghcwb
waghcwb / encoding-video.md
Created August 8, 2019 23:24 — forked from Vestride/encoding-video.md
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
@waghcwb
waghcwb / delete-slack-messages.js
Last active June 3, 2019 22:14 — forked from firatkucuk/delete-slack-messages.js
Deletes slack public/private channel and chat messages.
#!/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 #############################################################################################################

choco install 7zip.install

choco install putty.install

choco install nodejs.install

choco install skype

choco install python2

// 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 April 19, 2019 03:44 — forked from vlucas/encryption.js
Stronger Encryption and Decryption in Node.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')
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'
/**
* 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.)
function getArrayOfDoubles(size = 30, factor = 0.5) {
return Array(size).fill(0).map((item, index) => Number((index * factor).toFixed(1))).splice(1)
}
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]) {
# runs prettier only in modified files on git
git diff --name-only | xargs prettier --config ./prettier.config.js --write