Skip to content

Instantly share code, notes, and snippets.

View Linrstudio's full-sized avatar
🌴
On vacation

xyz Linrstudio

🌴
On vacation
View GitHub Profile
@mikowl
mikowl / oneliners.js
Last active February 19, 2025 05:20
👑 Awesome one-liners you might find useful while coding.
// Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// or
const sleep = util.promisify(setTimeout);
/*
* This script fetches all color styles from a Figma team/document.
*
* Dependencies:
*
* - node-fetch
*
* Due to a limitation in the Figma /styles endpoint, we need to use a
* document for actually using the colors in a color grid 🙄That's why
* we're both fetching from /styles and /files below.
@lqqyt2423
lqqyt2423 / node-heapdump.js
Created February 26, 2019 02:45
内存快照,通过chrome开发者工具查看内存快照
'use strict';
// kill -USR2 61365
const heapdump = require('heapdump');
const http = require('http');
const leakArray = [];
const leak = function () {
leakArray.push('leak' + Math.random());
@brookback
brookback / fetch-figma-color-styles.js
Created February 25, 2019 07:58
Call with `FIGMA_PERSONAL_TOKEN node fetch-figma-color-styles.js`
/*
* This script fetches all color styles from a Figma team/document.
*
* Due to a limitation in the Figma /styles endpoint, we need to use a
* document for actually using the colors in a color grid 🙄That's why
* we're both fetching from /styles and /files below.
*
* For now, you need to input the page and team IDs, as well as the file keys.
* The team ID is in the Figma URL of your team, and the file key is the long
* string in the full URL of a Figma file. The page ID is visible in the JSON
@profiprog
profiprog / simple-compressing.md
Last active February 21, 2025 10:43
Simple compressing base64 string in JavaScript

Story

In needed include base64 encoded simple image into HTML page in two formats:

1st as PNG format has length 196 characters and looks like this:

iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAWElEQVR42mNkwA/qgbgRnwJGAgb8BwI7RkbGw5QYUAs0oGXUAPwGgKKqgYF0ANLTyAi1xhZI2WOYzsjYDJTbC2QewGHIwcERBsPcgHqgAX8pMQAcxfhyIwATTkxL+hgX2QAAAABJRU5ErkJggg==

2nd as CUR format has length 1536 characters and looks like this:

`AAACAAEAEBAAAAcABwBoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAQAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///z0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH////98AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////3wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////98AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

@jherax
jherax / configure.md
Last active March 26, 2025 18:10
VS Code: Debugging with Jest

VS Code: Debugging Jest

Sometimes, debugging with console.log is not enough to find out what is happening in the code, as console.log prints only plain objects but neither functions nor objects with circular references. Besides, it's possible you may need to know the context and flow of the code.

Read more about debugging with VS Code in VS Code: Debugging.

@Gioni06
Gioni06 / darkmode.js
Last active November 30, 2022 00:11
Enable Dark mode with css variables and js
function activateDarkMode() {
const rootElement = document.querySelector(':root')
const darkTheme = {
'--background-color': '#1e1e1e',
'--primary-color': '#157efb',
'--font-color': '#dedede',
'--subtle-primary-color': '#151513',
'--block-background-color': '#323232',
'--menu-item-color': '#dedede',
'--menu-item-hover-color': '#157efb',
@uglyeoin
uglyeoin / background image for HTML email.html
Last active November 8, 2021 17:06
Background Image with Outlook support in HTML Email
<!-- Full width background image with content. Image is full width but 200px high -->
<div mc:repeatable="options" mc:variant="Main Background Image with Text overlay">
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="width:100%;min-height:328px;height:328px;" background="https://gallery.mailchimp.com/fa85a578f928f05fa5750d667/images/cc24d737-fea1-4a47-87fb-517f5fecb2f4.jpg">
<tr>
<td style="font-size: 16px;line-height: 20px; font-family: Georgia, Arial, sans-serif;">
<!--[if gte mso 9]>
<v:rect style="width:600px;height:328px;" strokecolor="none" stroke="false">
<v:fill type="frame" color="#303131" src="https://gallery.mailchimp.com/fa85a578f928f05fa5750d667/images/cc24d737-fea1-4a47-87fb-517f5fecb2f4.jpg" /></v:fill>
</v:rect>
<v:shape id="bgImage" style="position:absolute;width:600px;height:328px;">
@ryoldash
ryoldash / config-overrides.js
Last active December 27, 2019 10:55
Customize webpack configuration of React App created with Create-react-app
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = function override(config, env) {
if (!config.plugins) {
config.plugins = [];
}
config.plugins.push(
(process.env.NODE_ENV === 'production') ?
new CopyWebpackPlugin([{from: 'src/lib/legacyLib.js'}]) :
@AveYo
AveYo / .. MediaCreationTool.bat ..md
Last active March 26, 2025 17:03
Universal MediaCreationTool wrapper for all MCT Windows 10 versions - MOVED TO github.com/AveYo/MediaCreationTool.bat