Skip to content

Instantly share code, notes, and snippets.

@realyze
realyze / SubPartial
Created Sep 19, 2018
Make only some field optional
View SubPartial
type MakeOptional<T, K extends keyof T> =
{[P in keyof Pick<T, K>]+?: T[P]} &
{[P in keyof Pick<T, Exclude<keyof T, K>>]: T[P]};
View gist:50a9cdc7db562ca3ee5f6e98e4762f10
<html>
<body>
<div style="overflow: hidden; position: relative;">
<div style="background: yellow; height: 100%; overflow-y: scroll;">
<div style="height: 10000px; display: flex; justify-content: flex-end;">
<div style="height: 100px; width: 100px; background: red; transform: translate3d(0, 0, 0);">foo</div>
</div>
</div>
</div>
</body>
View yarn-post-merge-and-checkout-hooks.sh
#/usr/bin/env bash
git config --global init.templatedir '~/.git-templates' && \
mkdir -p ~/.git-templates/hooks && \
cd ~/.git-templates/hooks
cat >post-checkout <<'EOL'
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep -E --quiet "$1" && eval "$2" || true
View gist:7edee7eb4f91b262df8480e77ad9c2d6
it('renders results', () => {
const { configuration } = install();
const Results = configuration.Results!;
expect(toJson(shallow(<Results />), {
noKey: false,
map: (val) => {
// Filter out noisy rxjs subscription from the snapshot.
if (val.type === 'ResultsListScrollContainer') {
val.props.resultState.subscription = {};
}
View IntelliJ cmd line formatter
FILES=$(git diff --name-only `git merge-base HEAD green`)
FORMAT_BIN=${HOME}/.ideaformatter/Contents/bin/format.sh
if [[ ! -f ${FORMAT_BIN} ]]; then
echo 'Please symlink idea into $HOME/.ideaformatter';
exit 1;
fi
FILES_ARR=($FILES)
ABS_FILES=( "${FILES_ARR[@]/#/`cd .. && pwd`/}" )
@realyze
realyze / packages
Last active Apr 5, 2017
accounts-google@1.1.1 error
View packages
meteor-base # Packages every Meteor app needs to have
mobile-experience # Packages for a great mobile UX
mongo # The database Meteor supports right now
blaze-html-templates # Compile .html files into Meteor Blaze views
reactive-var # Reactive variable for tracker
jquery # Helpful client-side library
tracker # Meteor's client-side reactive programming library
standard-minifier-css # CSS minifier run for production mode
standard-minifier-js # JS minifier run for production mode
@realyze
realyze / pizza.js
Last active Feb 14, 2018
Pizza challenge
View pizza.js
const defer = (res, ms) => new Promise(resolve => setTimeout(() => resolve(res), ms));
const makeDough = () => defer({add: () => {}}, 500);
const makeSauce = () => defer({determineCheese: () => 'cheddar'}, 250);
const grateCheese = () => defer({type: 'cheddar'}, 150);
async function makePizza(sauceType = 'red') {
const pDough = makeDough();
@realyze
realyze / meteor_slow.js
Last active Jul 13, 2018
Slow meteor query
View meteor_slow.js
if (Meteor.isClient) {
Meteor.startup(function () {
var collection = new Mongo.Collection(null);
for (var i = 0; i < 1000; ++i) {
collection.insert({
_id: new Mongo.ObjectID().toHexString(),
"kind": "t3",
@realyze
realyze / meteor_slow
Created Jan 16, 2016
slow meteor query
View meteor_slow
if (Meteor.isClient) {
Meteor.startup(function () {
var collection = new Mongo.Collection(null);
for (var i = 0; i < 1000; ++i) {
collection.insert({
_id: new Mongo.ObjectID().toHexString(),
"kind": "t3",
@realyze
realyze / slow_query.js
Last active Jan 16, 2016
Slow meteor query
View slow_query.js
if (Meteor.isClient) {
Meteor.startup(function () {
var messageThreads = new Mongo.Collection(null);
for (var i = 0; i < 1500; ++i) {
messageThreads.insert({
_id: new Mongo.ObjectID().toHexString(),
"posts": [
You can’t perform that action at this time.