Skip to content

Instantly share code, notes, and snippets.

View Linrstudio's full-sized avatar
🌴
On vacation

xyz Linrstudio

🌴
On vacation
View GitHub Profile
@nobodxbodon
nobodxbodon / extension.ts
Created April 26, 2020 06:38
vs code插件 auto-correct 基础上实现了中文标点符号自动替换为英文标点符号的原型
'use strict';
import * as vscode from 'vscode';
import { getWords } from './helpers';
const ks = require('node-key-sender');
// let config: vscode.WorkspaceConfiguration;
let words: any;
// let triggers: string[];
@romannurik
romannurik / duplicate-components.scripter.ts
Last active February 24, 2022 16:08
Figma + Scripter scripts
// Makes a copy of all selected components (how is this not built into Figma?)
let newSelection = [];
for (let component of figma.currentPage.selection.filter(node => node.type == 'COMPONENT')) {
let clone = component.clone()
clone.x += clone.width;
newSelection.push(clone);
}
figma.currentPage.selection = newSelection;
@rsms
rsms / pdf-to-svg.md
Last active February 21, 2023 09:04

Converting PDF → SVG

Surprisingly complicated. Figma supports SVG → PDF but not the other way around. Sketch supports PDF → SVG with some bugs (often vector shape overlaps are incorrect.)

dawbarton/pdf2svg looks like an interesting project that could be compiled as WASM but it is itself poinsoned by GNU GPL license. Plus, it depends on a huge amount of (also GPL-licensed) code in the form of Poppler and Cairo.

@ledudu
ledudu / lebo
Created February 16, 2020 04:13 — forked from loerise/MiTV ADBlock
乐播投屏广告屏蔽
127.0.0.1 sdkauth.hpplay.cn
127.0.0.1 adeng.hpplay.cn
127.0.0.1 ad.hpplay.cn
127.0.0.1 conf.hpplay.cn
127.0.0.1 fix.hpplay.cn
127.0.0.1 adcdn.hpplay.cn
127.0.0.1 sl.hpplay.cn
127.0.0.1 rp.hpplay.cn
@rsms
rsms / fig-thumbnails.js
Created November 18, 2019 23:33
Script to fetch thumbnails of figma files
// 1. Make sure you have imagemagick installed (`brew install imagemagick` on macos)
// 2. Visit https://www.figma.com/developers/api#authentication and click "Get personal access token"
// 3. Add your file links below, replacing the example links
// 4. Run with `FIGMA_API_TOKEN=YOUR_TOKEN_FROM_STEP_2_HERE node fig-thumbnails.js`
// [ host:string, filekey:string ][]
const fileKeys = `
https://www.figma.com/file/FILEKEY/
https://staging.figma.com/file/FILEKEY/
https://www.figma.com/file/FILEKEY/
@rsms
rsms / fps.ts
Created November 3, 2019 20:25
FPS measurement in web browser
// measureFPS uses requestAnimationFrame to measure frame times and reports
// the average frames per second.
//
function measureFPS(report :(fps:number)=>void) {
const samplesSize = 120 // total number of frame times look at (window size)
const samples :number[] = [] // ring buffer; sliding window
const reportAt = Math.round(samplesSize / 4)
let samplesIndex = 0 // next index in samples
let prevTime = 0 // last time value; frameTime = prevTime - time
figma.showUI(`<script>
let imurl = 'https://66.media.tumblr.com/7af65560449c91e8cd82a4a3478f5e0b/tumblr_pb7bt5CTrS1qzdllao1_1280.jpg'
fetch(imurl).then(r => r.arrayBuffer()).then(a =>
parent.postMessage({ pluginMessage: ["imdata", new Uint8Array(a)] }, '*'))
</script>`, { visible:false, width:200, height:200 })
figma.ui.onmessage = msg => {
if (msg[0] == "imdata") {
let data = msg[1] as Uint8Array
let imageHash = figma.createImage(new Uint8Array(data)).hash
const rect = figma.createRectangle()
@ChrisDobby
ChrisDobby / forwardRef.tsx
Created July 30, 2019 20:03
Example of React component in Typescript using forwarding refs
import * as React from "react";
const Forward = React.forwardRef((props, ref: React.Ref<HTMLDivElement>) => (
<div ref={ref} style={{ width: "100%", height: "30px", backgroundColor: "green" }} />
));
function ForwardRef() {
const divRef = React.useRef<HTMLDivElement>(null);
React.useEffect(() => {
type ValidClass = string | number | undefined | null | ObjectClass;
type ObjectClass = {
[key: string]: boolean | undefined;
};
type ClassName = ValidClass | ValidClass[];
/**
* Easier class names management for JSX elements.
@MDSilviu
MDSilviu / webpack.config.js
Last active January 7, 2020 06:43
mini-css-extract-plugin moduleFilename bug
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
plugins: [
new MiniCssExtractPlugin({
moduleFilename: ({ name }) => `${name}.dsadas.css`
}),
],
entry: {
'scripts/theme': './theme/index.js'),