Skip to content

Instantly share code, notes, and snippets.

View tai2's full-sized avatar
🐢

Taiju Muto tai2

🐢
View GitHub Profile
@tai2
tai2 / keyCaseTansform.js
Last active August 28, 2017 16:25
snakeCaseKeys and camelCaseKeys
function snakeCaseKeys(obj) {
const tr = obj => _.transform(obj, (result, value, key) => {
result[_.snakeCase(key)] = _.isPlainObject(value) ? tr(value) : value
});
return tr(obj);
}
function camelCaseKeys(obj) {
const tr = obj => _.transform(obj, (result, value, key) => {
result[_.camelCase(key)] = _.isPlainObject(value) ? tr(value) : value
-- this can be compiled
neverText : Html Never
neverText = text "never dispatch message"
-- this can not be compiled
htmlNever : Html msg -> Html Never
htmlNever elem = elem
@tai2
tai2 / draganddrop.html
Created July 26, 2017 08:02
mouseleave is not fired while dragging
<html>
<head>
<style>
.parent {
width: 300px;
height: 300px;
background: black;
padding: 100px;
}
.draggable {
module App exposing (..)
import Html exposing (Html, div, text, program)
-- MODEL
type alias Model =
String
module Hello exposing (..)
import Html exposing (text)
import List exposing (take, drop, head)
indexOf : a -> List a -> Int
indexOf target list =
let
f target n list =
// Aはpropsで装飾用のコンポーネントを受け取りたい
// ただし、装飾用のコンポーネントが必要とするpropsについては関知したくない
function A(props) {
const Decorator = props.decorator;
return (
<div>
<Decorator {...props.decoratorProps}>TEST</Decorator>
</div>
);
}
@tai2
tai2 / decoration.jsx
Last active July 15, 2017 12:35
コンポーネントの隙間に装飾用のコンポーネントを差し込みたい
// Aはpropsで装飾用のコンポーネントを受け取りたい
// ただし、装飾用のコンポーネントが必要とするpropsについては関知したくない
function A(props) {
const Decorator = props.decorator;
return (
<div>
<Decorator>TEST</Decorator>
</div>
);
}
@tai2
tai2 / jquery-selectmenu.js
Last active September 11, 2021 11:30
jquery ui select menu vue component
Vue.component('jquery-selectmenu', {
props: ['value'],
template: `<select><slot /></select>`,
mounted: function() {
const emit = value => this.$emit('input', value);
$(this.$el).selectmenu({
change: function(event, data) {
emit(data.item.value);
}
});
@tai2
tai2 / gflw_template.c
Created June 21, 2017 15:50
GLFW template
// gcc hello_opengl.c -o hello_opengl -lglfw -framework OpenGL
#include <GLFW/glfw3.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
@tai2
tai2 / plan.md
Last active June 12, 2017 08:13
Rails5.1でReact Todo MVC

Rails5.1でReact Todo MVC

読者はwebpackerのREADMEを読んでないと仮定。

入れるもの

  • redux
  • flowtype
  • eslint
  • reducerのテスト