Skip to content

Instantly share code, notes, and snippets.

@riddla
riddla / Layout.js
Created May 3, 2017 17:51 — forked from gustavlrsn/Layout.js
Example bootstrap 4 integration into Next.js, with the reactstrap package
import Head from 'next/head'
import { Container } from 'reactstrap'
const Layout = (props) => (
<div>
<Head>
<title>PairHub</title>
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" />
</Head>
@riddla
riddla / .babelrc
Last active May 23, 2021 07:20
Debug ES6 React using Jest with Visual Studio Code (VSCode)
{
"presets": [
"react",
"es2015"
],
"sourceMaps": "inline",
"retainLines": true
}
@riddla
riddla / step.js
Last active March 25, 2019 12:45
Suppress render React component conditionally
import React, {PropTypes} from 'react';
import {connect} from 'react-redux';
export const Step = ({title, children, id, state}) => {
if (state && !(state.present.ui.step === Number(id))) {
console.log('step denied');
return null;
}
return (
@riddla
riddla / _angularServiceAsModuleTemplate.js
Last active June 30, 2016 12:59
Templates for RequireJS module
/* eslint-disable camelcase */
/* global define */
(function (define) {
'use strict';
var _;
var moment;
define(function (require) {
require('common/common.module');
  1. Check if a page variable has been defined
    1. Set variables in a page (page.html.haml) at the very biginning of the file:

      ---
      variable: value
      variable2: value 2
      ---
helpers do
def buffer()
@_out_buf
end
def capture(buffer)
pos = buffer.size
yield
buffer.slice!(pos..buffer.size)
end
def my_helper(&block)
// conditional hiding/showing made ...
if (chapterTitleHasVisibleFollowingNotes) {
$chapterTitle.show();
} else {
$chapterTitle.hide();
}
// ... simple
$chapterTitle.toggle(chapterTitleHasVisibleFollowingNotes);
/*!
* JavaScript preload() function
* Preload images, CSS and JavaScript files without executing them
* Script by Stoyan Stefanov – http://www.phpied.com/preload-cssjavascript-without-execution/
* Slightly rewritten by Mathias Bynens – http://mathiasbynens.be/
* Demo: http://mathiasbynens.be/demo/javascript-preload
*/
function preload(arr) {
var i = arr.length,