Skip to content

Instantly share code, notes, and snippets.

View nakamura-to's full-sized avatar

Toshihiro Nakamura nakamura-to

View GitHub Profile
@ferrerojosh
ferrerojosh / R2DBCIO.kt
Last active February 16, 2024 18:06
Simple r2dbc client wrapper using kotlin coroutines
import io.r2dbc.spi.*
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.reactive.asFlow
import kotlinx.coroutines.reactive.awaitFirst
import kotlinx.coroutines.reactive.awaitFirstOrNull
import kotlin.reflect.KClass
/**
* An R2DBC client that uses Kotlin coroutines.
*/
@gaearon
gaearon / ReduxMicroBoilerplate.js
Last active March 26, 2020 00:35
Super minimal React + Redux app
import React, { Component } from 'react';
import { createStore, combineReducers, applyMiddleware, bindActionCreators } from 'redux';
import { provide, connect } from 'react-redux';
import thunk from 'redux-thunk';
const AVAILABLE_SUBREDDITS = ['apple', 'pics'];
// ------------
// reducers
// ------------
@nkbt
nkbt / .eslintrc.js
Last active May 11, 2024 13:03
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

@kawasima
kawasima / SafeResolver.java
Last active October 3, 2020 02:40
Struts1 S2-020対応
/**
* A Resolver that doesn't call getClass().
*
* @author kawasima
*/
public class SafeResolver extends DefaultResolver {
private static final char NESTED = '.';
private static final char MAPPED_START = '(';
private static final char MAPPED_END = ')';
private static final char INDEXED_START = '[';
@wilsonwc
wilsonwc / stateMock.js
Created January 10, 2014 17:24
Angular Mock for properly resolving ui-router $state in Karma unit tests
angular.module('stateMock',[]);
angular.module('stateMock').service("$state", function($q){
this.expectedTransitions = [];
this.transitionTo = function(stateName){
if(this.expectedTransitions.length > 0){
var expectedState = this.expectedTransitions.shift();
if(expectedState !== stateName){
throw Error("Expected transition to state: " + expectedState + " but transitioned to " + stateName );
}
}else{
@asafge
asafge / ng-really.js
Created November 12, 2013 13:06
ng-really? An AngularJS directive that creates a confirmation dialog for an action.
/**
* A generic confirmation for risky actions.
* Usage: Add attributes: ng-really-message="Are you sure"? ng-really-click="takeAction()" function
*/
angular.module('app').directive('ngReallyClick', [function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', function() {
var message = attrs.ngReallyMessage;
@gakuzzzz
gakuzzzz / 1_LogicalDeletable.java
Last active December 10, 2015 03:08
汎用的なDelegateのリフレクション使わない版
import org.joda.time.DateTime;
import org.seasar.doma.Column;
import org.seasar.doma.Entity;
@Entity
public abstract class LogicalDeletable {
@Column
protected DateTime deletedTime;
@jimoneil
jimoneil / WNSHelper.cs
Created November 8, 2012 07:04
Sample code for OAuth and push notification handling for Windows Store applications
/*
Copyright (c) Microsoft
All rights reserved.
Licensed under the Microsoft Limited Public License (the “License”); you may not
use this file except in compliance with the License.
You may obtain a copy of the License at http://msdn.microsoft.com/en-us/cc300389.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS
OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
@taichi
taichi / nue_mod.js
Created October 4, 2012 08:43
nue.jsの改善案
// async の引数が無い場合、全部が次に渡される様にして欲しい。
// コールバック関数の引数が3つ以上の場合、次のステップには配列が入ってきてよい。
// 目的
// コールバック関数の引数がerrのみ、もしくは二つの場合、
// つまりas(1)で事足りるケースをnueに特別扱いして貰って楽に記述したい。
// nodeのcallbackを取る関数は殆どがそうなっている。
// 現状1
flow(function start(file1, file2) {
fs.readFile(file1, 'utf8', this.async(as(1)));