Skip to content

Instantly share code, notes, and snippets.

@gaearon
gaearon / connect.js
Last active April 11, 2024 06:46
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@joakimbeng
joakimbeng / router.html
Last active March 15, 2024 06:18
A really simple Javascript router
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Building a router</title>
<script>
// Put John's template engine code here...
(function () {
// A hash to store our routes:
var Col = require('react-bootstrap/lib/Col')
var PageHeader = require('react-bootstrap/lib/PageHeader')
var React = require('react')
var Row = require('react-bootstrap/lib/Row')
var {connect} = require('react-redux')
var {reduxForm} = require('redux-form')
var DateInput = require('./DateInput')
var FormField = require('./FormField')
var LoadingButton = require('./LoadingButton')
@gonzaloserrano
gonzaloserrano / log.go
Created August 18, 2015 17:56
logrus wrapper
package log
import (
"fmt"
"github.com/Sirupsen/logrus"
"runtime"
"strings"
)
var logger = logrus.New()
@yuheiy
yuheiy / spacing-rules.md
Last active October 28, 2021 15:47
ウェブデザインの余白に規則性を持たせるためのパターン

ウェブデザインの余白に規則性を持たせるためのパターン

フォントサイズベース

$spacing: 1rem;

body {
  margin: ($spacing * 4) $spacing;
}
@sebmarkbage
sebmarkbage / JSXSpreadAttributes.md
Last active August 13, 2020 15:18
JSX Spread Attributes

JSX Spread Attributes

If you know all the properties that you want to place on a component a head of time, it is easy to use JSX:

  var component = <Component foo={x} bar={y} />;

Mutating Props is Bad, mkay

@ababup1192
ababup1192 / elm-hello-world.md
Last active June 29, 2020 08:31
Elmの開発環境を整えて、HelloWorldをするまで

ElmのHello Worldができるまで (2018 10/25)

nodeのインストール

  • 可能であれば、nvm, nodebrew等を使ってnodeをインストールする。

以下が、現時点(2018/9/3)の安定版のバージョン。

$ node -v
@youcune
youcune / fadein.html
Created August 24, 2014 12:23
CSS3 のみで display: none からフェードインさせる
<!DOCTYPE html>
<html>
<head>
<meta charst='utf-8'>
<title>TEST</title>
<script src="//code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
<style>
.box {
background: #000000;
display: none;
@m2ym
m2ym / gist:774198
Created January 11, 2011 08:28
cl-indent-patchesの設定(Emacs LispとCommon Lispの共存)
(when (require 'cl-indent-patches nil t)
(setq lisp-indent-function
(lambda (&rest args)
(apply (if (memq major-mode '(emacs-lisp-mode lisp-interaction-mode))
'lisp-indent-function
'common-lisp-indent-function)
args))))
@fukajun
fukajun / gist:edea3c4f36e37bf36e8b
Last active February 19, 2017 14:28
pecoでgit logから指定したコミットのハッシュを取るコマンド
git log --graph --pretty=format:'%d %an: %s %ar %h' | peco | awk -F ' ' '{ print $NF }'