Skip to content

Instantly share code, notes, and snippets.

@danmakenoise
danmakenoise / test.js
Last active February 29, 2024 20:23
Unit Testing Children of React Context API Consumers with Enzyme
// Component.js
const Component = props => (
<MyContext.Consumer>
{(context) => (
<Foo
bar={props.bar}
baz={context.baz}
/>
)}
</MyContext.Consumer>
@bathos
bathos / extreme-chrome-reset.css
Created December 27, 2016 02:19
extreme chrome css reset
/* Slash and burn / shock and awe / total war CSS reset for Chrome specifically */
:-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) h1,
:-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) h1,
:-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) h1,
:-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) h1,
:-webkit-any(article,aside,nav,section) h1,
::-webkit-input-placeholder,
:focus,
a:-webkit-any-link,
@goatslacker
goatslacker / alt-shopping.js
Created May 30, 2015 04:35
Shopping with alt and the new reducey stuff.
import Alt from './'
const alt = new Alt()
const ShopActions = alt.generateActions('addItem', 'taxPercentChanged')
const ItemStore = alt.createStore({
displayName: 'ItemStore',
state: {
import Alt from './'
import AltTestingUtils from './utils/AltTestingUtils'
const alt = new Alt()
const Store = alt.createStore(class {
constructor() {
this.x = 2
this.exportPublicMethods({
@goatslacker
goatslacker / stateless-stores.js
Last active August 29, 2015 14:20
stateless stores with reduce
import { Dispatcher } from 'flux'
function isPromise(obj) {
return obj && (typeof obj === 'object' || typeof obj === 'function') &&
typeof obj.then === 'function'
}
// the minimalest
class Alt {
constructor() {
@oriSomething
oriSomething / enum-builder.js
Last active February 24, 2019 08:08
build enums with lodash
import _ from 'lodash';
export function enumNumber(... params) {
return Object.freeze(_.mapValues(_.invert(params), Number));
}
export function enumString(... params) {
return Object.freeze(_.mapKeys(params));
}
@listochkin
listochkin / node-command-line-options.txt
Created April 17, 2014 11:00
Node V8 GC-related options
--log_gc (Log heap samples on garbage collection for the hp2ps tool.)
type: bool default: false
--expose_gc (expose gc extension)
type: bool default: false
--max_new_space_size (max size of the new generation (in kBytes))
type: int default: 0
--max_old_space_size (max size of the old generation (in Mbytes))
type: int default: 0
--max_executable_size (max size of executable memory (in Mbytes))
type: int default: 0
@burtlo
burtlo / private.xml
Created September 26, 2012 13:30
TMUX: Rebinding CAPS LOCK to CTRL + B
<?xml version="1.0"?>
<root>
<appdef>
<appname>Terminal</appname>
<equal>com.apple.Terminal</equal>
</appdef>
<item>
<name>TMUX Key Remappings</name>
<item>
<name>TMUX: Right Control to Ctrl+B</name>
@mauryaratan
mauryaratan / htaccess-tweaks
Created May 7, 2012 13:43
htaccess Gzip Compression and expires to speed up page load time
<IfModule mod_deflate.c>
#The following line is enough for .js and .css
AddOutputFilter DEFLATE js css
AddOutputFilterByType DEFLATE text/plain text/xml application/xhtml+xml text/css application/xml application/rss+xml application/atom_xml application/x-javascript application/x-httpd-php application/x-httpd-fastphp text/html
#The following lines are to avoid bugs with some browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
@brantfaircloth
brantfaircloth / gist:933843
Created April 21, 2011 06:22
Textmate save also commits to git
#!/usr/bin/env ruby
# Note: original hint from Florian Pilz @ http://stackoverflow.com/questions/4307192/is-it-possible-to-hook-a-git-commit-to-the-save-on-textmate. Slightly updated with git path (homebrew) and change to git_answer.
filename = ENV["TM_FILEPATH"].split("/").last
require ENV['TM_SUPPORT_PATH'] + '/lib/ui'
message = TextMate::UI.request_string(:title => "Committing changes of #{filename}", :prompt => "Please enter the commit message for your changes.")
`/usr/local/bin/git add #{ENV["TM_FILEPATH"]} 2>&1`
commit = `/usr/local/bin/git commit -m "#{message}" 2>&1`