Skip to content

Instantly share code, notes, and snippets.

View Jaballadares's full-sized avatar

John Balladares Jaballadares

View GitHub Profile
@phechzzz
phechzzz / regexTutorial.md
Last active January 2, 2024 18:46
Regex Tutorial: Matching an Email

Regex: Matching an Email

Regular expressions are powerful search tools comprised of a sequence of defining characters. With regex, you can search, validate, replace, and extract strings of text based on these defining characters.

Summary

In this tutorial, we will break down a regex used to match an email using the following code snippet:
/^([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+)\.([a-zA-Z]{2,})$/
Going character by character, we will work through this snippet of code to understand how it is defining search parameters. Regular expressions can feel overwhelming at first, but by breaking the code down into different defining groups, we can easily understand how this expression is working.

/*
Autosend Invites to anyone that shares X number of connections with you.
Way to use this script:
1. Save it as a bookmarklet
2. Go to 'People you may know'
3. Click on this bookmarklet.
4. Enter number of overlapping connections
5. Check your console
/** * @OnlyCurrentDoc */
function moveColumns() {
// get sheet
var sheet = SpreadsheetApp.getActiveSheet();
// select columns to be moved ('collegename' & 'shoesize')
var columnsToMove = sheet.getRange("E1:F1");
@evanreichard
evanreichard / archive-redirect.user.js
Last active September 15, 2023 07:40
Auto Archive Redirect
// ==UserScript==
// @name Auto Archive Redirect
// @namespace Evan Reichard
// @version 0.0.3
// @match *://*/*
// @grant GM.xmlhttpRequest
// @grant GM.openInTab
// @noframes
// @run-at document-start
// ==/UserScript==
@wcarss
wcarss / order-by.js
Last active May 13, 2021 15:50
a toy function to sort js arrays with sql-like syntax
// preamble: public domain; no warranty
//
// this is a toy -- it is slow, cannot handle unicode, keys w/
// spaces, nested keys, natural ordering, etc.
// orderBy('key1 [asc|1|desc|-1][, key2 [asc|1|desc|-1]][, etc]')
//
// write sql-like sort orders for arrays of objects, e.g.:
//
async function onTrack(event, settings) {
if (event.event !== settings.eventName) {
return;
}
const product = event.properties.products[0];
const itemPurchased = `${product.brand} ${product.name}`;
const Body = `Thank you for purchasing ${itemPurchased} from our site. We will follow-up with the tracking details shortly.`;
const To = settings.twilioDestinationNumber;
@rezonn
rezonn / GASPolyfills.js
Last active January 28, 2021 04:49
Google Apps Script polyfills
function fetch(url,options2) {
if (options2) {
if (options2.body) {
options2.payload = options2.body.toString("binary");
options2.body = undefined;
}
}
return new Promise(function (resolve, reject) {
try {
var data = UrlFetchApp.fetch(url, options2);
@spencerwooo
spencerwooo / termiWidget.js
Last active June 22, 2024 22:11
🍋 TermiWidget - Terminal-like Widget for iOS 14, made with Scriptable.
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: orange; icon-glyph: quote-right;
// Change these to your usernames!
const user = "spencer"
const jike = "4DDA0425-FB41-4188-89E4-952CA15E3C5E"
const telegram = "realSpencerWoo"
const github = "spencerwooo"

Interview Questions

Node.js

Q1: What do you mean by Asynchronous API? ☆☆

Answer: All APIs of Node.js library are aynchronous that is non-blocking. It essentially means a Node.js based server never waits for a API to return data. Server moves to next API after calling it and a notification mechanism of Events of Node.js helps server to get response from the previous API call.

Source: tutorialspoint.com

@sperand-io
sperand-io / worker.js
Last active October 28, 2023 09:41
Cloudflare Workers / Segment Smart Proxy — serve data collection assets and endpoints from your own domain
/**
* Steps to use:
* 1. Create CF Worker, copy and paste this in
* 2. (Optional) Update configuration defaults
* - If you want to manage in code, do so below under "Static Configuration"
* - If you want dynamic custom config: Create CFW KV namespace, link them, and add reference below
*
* - You can overwrite default path prefix for loading analytics.js (<yourdomain>/ajs)
* (corresponding KV entry: `script_path_prefix`)
* - You can overwrite default path prefix for handling first-party data collection (<yourdomain>/data)