Skip to content

Instantly share code, notes, and snippets.

View frederickfogerty's full-sized avatar

Frederick Fogerty frederickfogerty

View GitHub Profile
@fokusferit
fokusferit / enzyme_render_diffs.md
Last active June 18, 2024 11:27
Difference between Shallow, Mount and render of Enzyme

Shallow

Real unit test (isolation, no children render)

Simple shallow

Calls:

  • constructor
  • render
@gaearon
gaearon / combining.js
Created June 3, 2015 18:03
Combining Stateless Stores
// ------------
// counterStore.js
// ------------
import {
INCREMENT_COUNTER,
DECREMENT_COUNTER
} from '../constants/ActionTypes';
const initialState = { counter: 0 };
@tyler-smith
tyler-smith / gist:1c30566b01aa76bd75e1
Last active April 2, 2016 00:44
ES function_score troubles with filtered query_string query
// Final working version
{
"query":{
"filtered":{
"query":{
"function_score":{
"query":{
"query_string":{
"query":"this is a cool search",
"fields":[
@chenglou
chenglou / gist:40b75d820123a9ed53d8
Last active March 13, 2024 12:14
Thoughts on Animation

Interesting part (unmounting & API) is at the end if you're not interested in the rest =).

Stress Tests

This animation proposal is just an attempt. In case it doesn't work out, I've gathered a few examples that can test the power of a future animation system.

  1. Parent is an infinitely spinning ball, and has a child ball that is also spinning. Clicking on the parent causes child to reverse spinning direction. This tests the ability of the animation system to compose animation, not in the sense of applying multiple interpolations to one or more variables passed onto the child (this should be trivial), but in the sense that the parent's constantly updating at the same time as the child, and has to ensure that it passes the animation commands correctly to it. This also tests that we can still intercept these animations (the clicking) and immediately change their configuration instead of queueing them.

  2. Typing letters and let them fly in concurrently. This tests concurrency, coordination of an array of ch

@khrice
khrice / README
Last active December 11, 2020 22:41
Applescript to pause and play youtube videos using Alfred (In Chrome)
First go to https://www.youtube.com/html5 and request the html5 player (click the button)
Then download Alfred from the app store (https://itunes.apple.com/us/app/alfred/id405843582?mt=12)
go to alfred preferences and make sure AppleScripts is checked in the results preferences
next open a youtube video in chrome
then open alfred via the shortcut (ctrl+space or option+space) and type youtubeController (you can just start to type it and as soon as it shows up hit enter)
this is will pause or play the video for you and after you use alfred to run it a few times you should be able to open alfred and type yo and hit enter and it works.
@aras-p
aras-p / preprocessor_fun.h
Last active June 21, 2024 12:20
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
/**
The idea here is that all changes to your new object can be observed
*/
Ember.View.extend({
model: Ember.StalkableObject.create(),
saveModel: Ember.observer(function () {
/** do some fancy stuff to save changes to your model */
}, 'model.@properties')
});
@briancavalier
briancavalier / simple-promise-retry.js
Created February 24, 2011 18:35
A few general patterns for retries using promises
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active June 18, 2024 18:27
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh