Skip to content

Instantly share code, notes, and snippets.

Avatar

Roman Nurik romannurik

View GitHub Profile
View duplicate-components.scripter.ts
// 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;
@romannurik
romannurik / Expando.jsx
Last active Jun 2, 2019
A simple expand/collapse animation using React
View Expando.jsx
import React, {useRef, useLayoutEffect} from 'react';
const [DURMIN, DURMAX] = [0.1, .8];
const dur = f => Math.min(DURMAX, (1 - f) * DURMIN + f * DURMAX);
export function Expando({className, children, open}) {
open = !!open;
let node = useRef();
let lastOpen = useRef(open);
let duration = useRef(.5);
@romannurik
romannurik / .gitconfig
Last active Nov 6, 2019
Cheap Sketch file version control with Git + Kaleidoscope
View .gitconfig
# Add this to your .git/config file
[diff]
tool = SketchKaleidoscope
[difftool "SketchKaleidoscope"]
cmd = ./util-sketch-kaleidoscope-diff.bash \"$MERGED\" \"$LOCAL\" \"$REMOTE\"
@romannurik
romannurik / tab-widget.tsx
Created Aug 23, 2018
A proof-of-concept Tab widget for Framer X
View tab-widget.tsx
import { ControlType, PropertyControls } from "framer";
import * as React from "react";
interface TabWidgetProps {
selectedTab: number;
accentColor: string;
}
@romannurik
romannurik / nunjucks-block-call-extension.js
Last active Nov 13, 2017
Nunjucks Block Call Extension (call a macro, pass content of sub-blocks as keyword args)
View nunjucks-block-call-extension.js
const TAG_NAME = 'blockcall';
const ARG_TAG_NAME = 'argblock';
class BlockCallExtension {
constructor(nunjucks) {
this.tags = [TAG_NAME];
this.nunjucks = nunjucks;
}
View keybase.md

Keybase proof

I hereby claim:

  • I am romannurik on github.
  • I am romannurik (https://keybase.io/romannurik) on keybase.
  • I have a public key whose fingerprint is 9C43 1BD9 8E4A C518 5DF1 8FB5 F838 5A88 DB4C 6EE2

To claim this, I am signing this object:

@romannurik
romannurik / make_material_icon_svg_folder_for_iconjar.sh
Last active Aug 29, 2015
Quick script to make a folder of 24px SVGs from the downloadable material icons file.
View make_material_icon_svg_folder_for_iconjar.sh
#!/bin/sh
#
# 1. Download the file linked here:
# http://www.google.com/design/spec/resources/sticker-sheets-icons.html#sticker-sheets-icons-components
#
# 2. Run this:
# ./make_material_icon_svg_folder_for_iconjar.sh material-design-icons-1.0.1
#
DIR="$1"
@romannurik
romannurik / DrawInsetsFrameLayout.java
Created Feb 10, 2014
DrawInsetsFrameLayout — adding additional background protection for system UI chrome when using KitKat’s translucent decor flags.
View DrawInsetsFrameLayout.java
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@romannurik
romannurik / AndroidManifest.xml
Last active Oct 20, 2020
Android example of how to programmatically instantiate a View with a custom style.
View AndroidManifest.xml
<manifest ...>
...
<!-- Make sure your app (or individual activity) uses the
theme with the custom attribute defined. -->
<application android:theme="@style/AppTheme" ...>
...
</application>
</manifest>
@romannurik
romannurik / CharsPerLineActivity.java
Last active Jun 22, 2020
Demonstrates how to identify and avoid line-length issues with TextView. The measure, or characters per line, of a block of text plays a key role in how comfortable it is to read (sometimes referred to as readability). A widely accepted optimal range for a text block's measure is between 45 and 75 characters. This code demonstrates two phases of…
View CharsPerLineActivity.java
/*
* Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software