Skip to content

Instantly share code, notes, and snippets.

Roman Nurik romannurik

Block or report user

Report or block romannurik

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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 Nov 7, 2019
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 Aug 26, 2019
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
@romannurik
romannurik / AndroidCreateGhostIcon.java
Created Jun 14, 2013
Android ColorMatrixColorFilter example: Creates a 'ghost' bitmap version of the given source drawable (ideally a BitmapDrawable). In the ghost bitmap, the RGB values take on the values from the 'color' argument, while the alpha values are derived from the source's grayscaled RGB values. The effect is that you can see through darker parts of the …
View AndroidCreateGhostIcon.java
/**
* Creates a 'ghost' bitmap version of the given source drawable (ideally a BitmapDrawable).
* In the ghost bitmap, the RGB values take on the values from the 'color' argument, while
* the alpha values are derived from the source's grayscaled RGB values. The effect is that
* you can see through darker parts of the source bitmap, while lighter parts show up as
* the given color. The 'invert' argument inverts the computation of alpha values, and looks
* best when the given color is a dark.
*/
private Bitmap createGhostIcon(Drawable src, int color, boolean invert) {
int width = src.getIntrinsicWidth();
You can’t perform that action at this time.