Skip to content

Instantly share code, notes, and snippets.

@peterjmag
peterjmag / components.test-component-with-init.js
Created August 3, 2017 16:03
avoid-leaking-state-in-components
import Ember from 'ember';
export default Ember.Component.extend({
init() {
this._super(...arguments);
this.set('items', [
'this is a default value',
'it shouldn’t appear if `items` is passed in from the parent'
]);
}
@peterjmag
peterjmag / components.size-chooser-list.js
Last active January 12, 2018 19:51
Declaratively selecting an option from a list
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
onSelect(sizeValue) {
this.get('onSelectSize')(sizeValue);
}
}
});
@peterjmag
peterjmag / icloudtabs2md.js
Created July 15, 2019 11:39 — forked from mems/icloudtabs2md.js
Generate a markdown links list from iCloud tabs
#!/usr/bin/env node
/*
Generate a markdown links list from iCloud tabs, on macOS
Usage:
./icloudtabs2md.js > icloudtabs.md
./icloudtabs2md.js | pbcopy
Require:
import json
import sqlite3
import zlib
# ~/Library/Safari/CloudTabs.db
# Ref: https://www.reddit.com/r/mac/comments/89qx5n/iphone_safari_tabs_into_text_list_via_icloud/
db = sqlite3.connect('CloudTabs.db')
tabs = []
@peterjmag
peterjmag / output.log
Created February 21, 2020 14:41
@reach/tabs local test failure (https://github.com/reach/reach-ui/pull/486)
$ yarn test
yarn run v1.19.2
$ cross-env NODE_ENV=test CI=true tsdx test packages
PASS packages/component-component/__tests__/component-component.test.tsx
PASS packages/tooltip/__tests__/tooltip.test.tsx
PASS packages/combobox/__tests__/combobox.test.tsx
PASS packages/slider/__tests__/slider.test.tsx
FAIL packages/tabs/__tests__/tabs.test.tsx
● <Tabs /> › focuses the correct tab with keyboard navigation (vertical orientation)

Keybase proof

I hereby claim:

  • I am peterjmag on github.
  • I am peterjmag (https://keybase.io/peterjmag) on keybase.
  • I have a public key ASDAoPJh__ZwSZSf0VIIEw1bixU74lkzTQgDaqcmY_Xbwwo

To claim this, I am signing this object:

@peterjmag
peterjmag / react-native-talk.md
Last active June 21, 2021 10:13
Let's build a React Native app in 20 minutes - React Berlin #1 (April 2015)
@peterjmag
peterjmag / gource.sh
Last active January 31, 2024 00:41 — forked from XueshiQiao/gource.sh
Generate a MP4 Video for your Git project commits using Gource!
# 1.install gource using HomeBrew
$ brew install gource
# 2.install avconv
git clone git://git.libav.org/libav.git
cd libav
# it will take 3-5 minutes to complie, be patient.
./configure --disable-yasm
make && make install
@peterjmag
peterjmag / letters-to-100.py
Created September 20, 2012 02:46
Find English words whose letter values add up to 100
#!/usr/bin/env python
# encoding: utf-8
"""
letters-to-100.py
"""
import string
letter_values = dict((l, i) for i, l in enumerate(string.lowercase, start=1))
english_dict = open('/usr/share/dict/words', 'rU')