Skip to content

Instantly share code, notes, and snippets.

View scriptex's full-sized avatar
🎨
Making email safer | Painting the pixels on your screen

Atanas Atanasov scriptex

🎨
Making email safer | Painting the pixels on your screen
View GitHub Profile
@lhorie
lhorie / longest-keyword-sequence.md
Last active November 13, 2024 04:15
What's the longest keyword sequence in Javascript?
@kitze
kitze / missing-date-fns.js
Last active June 21, 2020 19:56
good ol' date-fns
import {
formatDistance,
isAfter,
isBefore,
endOfDay,
startOfDay,
isSameDay,
isSameSecond,
isSameMinute,
isSameHour,
@scriptex
scriptex / jest-date-mock.ts
Last active February 1, 2021 13:37
Jest date mock (in Typescript)
/**
* Mock a date which is created with the `new Date()` constructor.
*
* Usage:
*
* import { onBeforeEach, onAfterEach } from 'FOLDER/jest-date-mock';
*
* describe('', () => {
* beforeEach(onBeforeEach);
* afterEach(onAfterEach);
@scriptex
scriptex / firebase.js
Last active February 1, 2021 13:36
Expo and Firebase integration in React Native
/**
* External dependencies
*/
import { auth } from 'react-native-twitter';
import * as firebase from 'firebase';
import Expo, { AuthSession } from 'expo';
/**
* Internal dependencies
*/
@bradtraversy
bradtraversy / webdev_online_resources.md
Last active November 5, 2024 12:03
Online Resources For Web Developers (No Downloading)
// Array hug, one array hugs the other
// If the hugger is odd numbered, more in the front
Array.prototype.hug = function(arr){
let hugged = this.slice(0,Math.ceil(this.length/2));
hugged.push(...arr);
hugged.push(...this.slice(Math.ceil(this.length/2), this.length));
return hugged;
}
// Array spoon, one array spoons the other
@scriptex
scriptex / hover.css
Last active April 5, 2021 09:40
Hover media query
/**
* Detailed info about the Hover CSS Media Feature can be found here:
* https://developer.mozilla.org/en-US/docs/Web/CSS/@media/hover
*
* This media query is implemented in almost all modern browsers and works as expected.
* The modern browsers include Chrome, Opera, Safari, Edge, Brave, Vivaldi, etc.
* Internet Explorer and Firefox do not understand this media feature and therefore will
* simply ignore all rules inside the query.
* Update: Firefox supports this media feature since version 64.
* A workaround can be found below.
@scriptex
scriptex / rename.js
Last active April 10, 2023 23:30
Rename all files in a folder with NodeJS
const { join } = require('path');
const { readdirSync, renameSync } = require('fs');
const [dir, search, replace] = process.argv.slice(2);
const match = RegExp(search, 'g');
const files = readdirSync(dir);
files
.filter(file => file.match(match))
.forEach(file => {
const filePath = join(dir, file);
@scriptex
scriptex / README.md
Last active February 1, 2021 13:35
create-svg-sprite usage

Как да използваме create-svg-sprite?

  1. Уверете се, че имате инсталиран node.js и npm. За целта, изпълнете следните команди в GitBash (или друг терминал): node -v npm -v

Ако резултата е цифри, значи всичко е наред и имате нужните зависимости инсталирани.

  1. Инсталирайте create-svg-sprite глобално:
@judy2k
judy2k / parse_dotenv.bash
Created March 22, 2017 13:34
Parse a .env (dotenv) file directly using BASH
# Pass the env-vars to MYCOMMAND
eval $(egrep -v '^#' .env | xargs) MYCOMMAND
# … or ...
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)