Skip to content

Instantly share code, notes, and snippets.

View AshikNesin's full-sized avatar

Ashik Nesin AshikNesin

View GitHub Profile
@aurorabbit
aurorabbit / progress.10s.sh
Last active December 31, 2024 00:37
Bitbar timely progress bar
#!/bin/sh
# add this to your bitbar directory
# don't forget to chmod +x
# width and characters for the progress bars
# feel free to configure these
width=30
fill_char="█"
empty_char="▁"

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).

@shospodarets
shospodarets / Chrome headless Puppeteer- capture DOM element screenshot using
Last active July 29, 2024 05:58
Chrome headless Puppeteer- capture DOM element screenshot using
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Adjustments particular to this page to ensure we hit desktop breakpoint.
page.setViewport({width: 1000, height: 600, deviceScaleFactor: 1});
await page.goto('https://www.chromestatus.com/samples', {waitUntil: 'networkidle'});
@mterwill
mterwill / USAGE.md
Last active December 15, 2024 10:54
Beancount importers, scripts, etc.

Note: everything here is pretty specific to my usage/accounts and not written for public use... You'll probably have to tweak a bunch of stuff.

$ bean-extract config.py ~/Downloads # the csvs should be in here
@shankara-subramani
shankara-subramani / password-regex.txt
Last active March 19, 2021 02:33
password regex with optional special characters
^(?=.*\d)(?=.*[a-z])[\w~@#$%^&*+=`|{}:;!.?\"()\[\]-]{6,8}$
@oscarmorrison
oscarmorrison / validateEmail.js
Last active May 27, 2017 06:38
ES6 email validation
// regex from http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
const EMAIL_REGEX = /^[-!#$%&'*+\/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-?\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/;
const validateEmail = email => {
return email
&& email.length < 255
&& EMAIL_REGEX.test(email);
};
export default validateEmail;
@orta
orta / now.sh.md
Created March 26, 2017 08:34
Notes on trying now.sh for staging peril

now.sh notes

Setup

Deployment via docker works great, got something deployed in like ~10m

Running now with a dockerfile + npm, shows > Two manifests found. Press [n] to deploy or re-run with --flag but now help and now deploy help dont show that flag existing, and running now --flag 2 did nothing.

Read the source code, looks like it's refering to the &gt; [1] package.json --npm - --npm bit. Some minor wording

@wesbos
wesbos / async-await.js
Created February 22, 2017 14:02
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}
function validatePath (path) {
const components = path.split('/');
const validatedFolderTree = [];
const getRootFolders = foldersApi.getTopLevelFolders();
const finalValidationPromise = components.reduce((promise, folder, index) => {
const folderName = folder.toLowerCase();
return promise
.then(parentChildren => {