Skip to content

Instantly share code, notes, and snippets.

View silvenon's full-sized avatar

Matija Marohnić silvenon

View GitHub Profile

Keybase proof

I hereby claim:

  • I am silvenon on github.
  • I am silvenon (https://keybase.io/silvenon) on keybase.
  • I have a public key ASBMkRBQIOMQZD1KKKFsjmxk7FExRR1wmClUd-YvTndoMQo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am silvenon on github.
  • I am silvenon (https://keybase.io/silvenon) on keybase.
  • I have a public key whose fingerprint is 7462 1CB0 97F9 2CBA 8A0F F41D 344C 1482 0427 45AC

To claim this, I am signing this object:

@silvenon
silvenon / 0.Readme.md
Last active April 11, 2019 08:45
An example dropdown using Tether Drop, React Portal and Redux.

This is an example of using Tether Drop with React Portal (and Redux for managing the state). I was asked if using React Portal is redundant, as both libraries pull the content into the <body>. Using only Drop would cause an invariant violation in React becuase of the DOM mutation, so I'm using React Portal to first bring it outside without React complaining (I don't know how React Portal does it, I haven't checked out the source, but it works). Once it's out of React's supervision, I can apply Drop to it.

  • Dropdown.jsx is the actual dropdown component
  • App.jsx is just an demo that uses it

This is my lazy way out of this limitation using an existing library that has much more features than you need, but chances are that you're going to need a library like React Portal anyway for stuff like modals.

Notes

@silvenon
silvenon / mocha-jsdom-test.js
Last active December 20, 2017 22:28
Mocha setup I use for testing React with jsdom.
import jsdom from 'jsdom';
import assert from 'assert';
describe('suite', () => {
let React, utils, Component;
before(() => {
global.document = jsdom.jsdom('<!DOCTYPE html><html><head></head><body></body></html>');
global.window = document.parentWindow;
global.navigator = {userAgent: 'node.js'};
@silvenon
silvenon / chai-as-promised.js
Last active August 29, 2015 14:19
WebdriverIO example with chai-as-promised.
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
var client = require('webdriverio').remote({
desiredCapabilities: {
browserName: 'phantomjs'
}
});
chai.use(chaiAsPromised);
chai.should();
@silvenon
silvenon / 0.forEach.md
Last active August 29, 2015 14:19
Why is using Browserify a good idea again? There's absolutely nothing I can do to reduce the size of bundled JS if it contains things I don't need.

These are two forEach functions; the one I wrote vs. the one I imported from lodash via Browserify.

(I removed the comments to be more fair.)

// DEBOUNCE FUNCTION via @http://davidwalsh.name/javascript-debounce-function
function debounce(a,b,c){var d;return function(){var e=this,f=arguments;clearTimeout(d),d=setTimeout(function(){d=null,c||a.apply(e,f)},b),c&&!d&&a.apply(e,f)}}
skrollrCheck = debounce(function() {
var winWidth = window.innerWidth;
if(winWidth >= 600) {
// Init Skrollr
skrollr.init({
forceHeight: false,//disable setting height on body
mobileDeceleration:0.05,
@silvenon
silvenon / ie-opacity.css
Created August 26, 2014 20:31
IE opacity hacks.
/* IE 5-7 */
filter: alpha(opacity=50);
/* IE 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
/* ಠ_ಠ */
@silvenon
silvenon / generator-webapp-with-compass.diff
Last active September 24, 2015 19:38
Changes needed in order to implement Compass back to Yeoman's generator-webapp.
-sass: {
- files: ['<%= config.app %>/styles/{,*/}*.{scss,sass}'],
- tasks: ['sass:server', 'autoprefixer']
-}
+compass: {
+ files: ['<%= config.app %>/styles/{,*/}*.{scss,sass}'],
+ tasks: ['compass:server', 'autoprefixer']
+}
...