Skip to content

Instantly share code, notes, and snippets.

View waghcwb's full-sized avatar
🎧
‌‌

Wagner Souza waghcwb

🎧
‌‌
View GitHub Profile
@waghcwb
waghcwb / tshark cheat sheet
Created March 9, 2024 08:17 — forked from githubfoam/tshark cheat sheet
tshark cheat sheet
============================================================================
#Wireshark installation directory: windows
C:\Program Files (x86)\Wireshark>tshark.exe
============================================================================
tshark -D #list of available interfaces
============================================================================
capture
============================================================================
tshark -i 2 #start capturing traffic on interface n°2
tshark -i 2 -a duration:10 #capture for 10 seconds, then stop
@waghcwb
waghcwb / ConvertMS.js
Created April 29, 2021 21:41 — forked from flangofas/ConvertMS.js
JS: Convert Milliseconds to days? minutes? seconds? or all!
function convertMiliseconds(miliseconds, format) {
var days, hours, minutes, seconds, total_hours, total_minutes, total_seconds;
total_seconds = parseInt(Math.floor(miliseconds / 1000));
total_minutes = parseInt(Math.floor(total_seconds / 60));
total_hours = parseInt(Math.floor(total_minutes / 60));
days = parseInt(Math.floor(total_hours / 24));
seconds = parseInt(total_seconds % 60);
minutes = parseInt(total_minutes % 60);
@waghcwb
waghcwb / maxWordsPerLine.js
Created June 15, 2020 16:56
Script that breaks a string into lines based on a maximum attribute
function maxWordsPerLine(str, max = 30) {
const result = [];
let counter = 1;
let tempArr = [];
for (const [index, letter] of str.split('').entries()) {
if (counter === max + 1) {
counter = 1;
result.push(tempArr);
if (!Element.prototype.findParentTagName) {
Element.prototype.findParentTagName = function (stringData) {
try {
if (this.tagName.equal(stringData)) return this;
let parent = this.parentElement;
while (parent) {
if (parent.tagName.equal(stringData)) return parent;
parent = parent.parentElement;
}
} catch (e) {
function diff(arr1, arr2) {
return arr1.filter(x => arr2.includes(x));
}
const arr1 = [
34242,
33030,
34241,
27118,
34152,
@waghcwb
waghcwb / code.md
Created January 11, 2020 17:25 — forked from gopalindians/code.md
Jetbrains IntelliJ IDEA 2019.2.4 Activation code

Please make fork of this, as this can be removed by Github.com sooner or later.

CATF44LT7C-eyJsaWNlbnNlSWQiOiJDQVRGNDRMVDdDIiwibGljZW5zZWVOYW1lIjoiVmxhZGlzbGF2IEtvdmFsZW5rbyIsImFzc2lnbmVlTmFtZSI6IiIsImFzc2lnbmVlRW1haWwiOiIiLCJsaWNlbnNlUmVzdHJpY3Rpb24iOiJGb3IgZWR1Y2F0aW9uYWwgdXNlIG9ubHkiLCJjaGVja0NvbmN1cnJlbnRVc2UiOmZhbHNlLCJwcm9kdWN0cyI6W3siY29kZSI6IklJIiwicGFpZFVwVG8iOiIyMDIwLTAxLTA4In0seyJjb2RlIjoiQUMiLCJwYWlkVXBUbyI6IjIwMjAtMDEtMDgifSx7ImNvZGUiOiJEUE4iLCJwYWlkVXBUbyI6IjIwMjAtMDEtMDgifSx7ImNvZGUiOiJQUyIsInBhaWRVcFRvIjoiMjAyMC0wMS0wOCJ9LHsiY29kZSI6IkdPIiwicGFpZFVwVG8iOiIyMDIwLTAxLTA4In0seyJjb2RlIjoiRE0iLCJwYWlkVXBUbyI6IjIwMjAtMDEtMDgifSx7ImNvZGUiOiJDTCIsInBhaWRVcFRvIjoiMjAyMC0wMS0wOCJ9LHsiY29kZSI6IlJTMCIsInBhaWRVcFRvIjoiMjAyMC0wMS0wOCJ9LHsiY29kZSI6IlJDIiwicGFpZFVwVG8iOiIyMDIwLTAxLTA4In0seyJjb2RlIjoiUkQiLCJwYWlkVXBUbyI6IjIwMjAtMDEtMDgifSx7ImNvZGUiOiJQQyIsInBhaWRVcFRvIjoiMjAyMC0wMS0wOCJ9LHsiY29kZSI6IlJNIiwicGFpZFVwVG8iOiIyMDIwLTAxLTA4In0seyJjb2RlIjoiV1MiLCJwYWlkVXBUbyI6IjIwMjAtMDEtMDgifSx7ImNvZGUiOiJEQiIsI

const { readFile: originalReadFile, writeFile: originalWriteFile } = require('fs')
const { promisify } = require('util')
const { resolve, join } = require('path')
const originalGlob = require('glob')
const glob = promisify(originalGlob)
const readFile = promisify(originalReadFile)
const writeFile = promisify(originalWriteFile)
class Storefront {
/**
* This method is used to detect the user browser and environment
*/
establishBrowser() {
const userAgent = (navigator && navigator.userAgent || '').toLowerCase()
const vendor = (navigator && navigator.vendor || '').toLowerCase()
const comparator = {
'<': function(a, b) { return a < b; },
'<=': function(a, b) { return a <= b; },
<!-- i needed to run webpack from ant build, so this was the solution -->
<macrodef name="nodejs">
<attribute name="module" description="The name of the NodeJS module to execute" />
<attribute name="failonerror" default="true" description="Fail if the exit code is not 0" />
<attribute name="dir" description="Directory to execute task" />
<element name="args" implicit="yes" description="Argument to pass to the exec task" />
<sequential>
<exec executable="cmd.exe" dir="@{dir}" failonerror="@{failonerror}" osfamily="winnt">
const sha256 = async message => {
const msgBuffer = new TextEncoder('utf-8').encode(message);
const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
const hashArray = Array.from(new Uint8Array(hashBuffer));
return hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join('');
}