Skip to content

Instantly share code, notes, and snippets.

View sunho's full-sized avatar
🐈
math is beutiful

Sunho Kim sunho

🐈
math is beutiful
View GitHub Profile
func badtype(expected string, data interface{}) error {
return e("cannot load TOML value of type %T into a Go %s", data, expected)
}
toggleDetails() {
this.setState({
showDetails: !this.state.showDetails
});
}
button1.addEventListener(MouseEvent.CLICK, function(e:MouseEvent) {
if(button1.currentFrame == 1) {
button1.gotoAndStop(2);
} else
button1.gotoAndStop(1);
}
});
button2.addEventListener(MouseEvent.CLICK, function(e:MouseEvent) {
if(button2.currentFrame == 1) {
button2.gotoAndStop(2);
function click(e:MouseEvent) {
if(e.target.currentFrame == 1) {
e.target.gotoAndStop(2);
} else {
e.target.gotoAndStop(1);
}
}
button1.addEventListener(MouseEvent.CLICK,click);
button2.addEventListener(MouseEvent.CLICK,click);
function click(frame:Number) {
return function(e:MouseEvent) {
if(e.target.currentFrame == 1) {
e.target.gotoAndStop(frame);
} else {
e.target.gotoAndStop(1);
}
}
}
button1.addEventListener(MouseEvent.CLICK,click(2));
var colors:Array = ["red","blue","green"];
var buttons:Array = new Array();
function colorSwitch(frame:Number) {
return function(e:MouseEvent) {
color.gotoAndStop(frame);
}
}
for (var i=0;i<colors.length;i++) {
buttons[i]=new button;
buttons[i].y=30*i;
My presentational components:
Are concerned with how things look.
May contain both presentational and container components** inside, and usually have some DOM markup and styles of their own.
Often allow containment via this.props.children.
Have no dependencies on the rest of the app, such as Flux actions or stores.
Don’t specify how the data is loaded or mutated.
Receive data and callbacks exclusively via props.
Rarely have their own state (when they do, it’s UI state rather than data).
Are written as functional components unless they need state, lifecycle hooks, or performance optimizations.
func LoadParsers(customParsers map[reflect.Type]Parser) (map[reflect.Type]Parser, error) {
parsers := map[reflect.Type]Parser{}
var boolParser BoolValue
parsers[reflect.TypeOf(true)] = &boolParser
var intParser IntValue
parsers[reflect.TypeOf(1)] = &intParser
var int64Parser Int64Value
@sunho
sunho / asdf
Created February 5, 2019 06:50
using System;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using Game.Events;
using Models;
using Newtonsoft.Json;
using UnityEngine;
namespace Network
fetch("http://localhost:5353/10", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({"game": {"hello":"hi"}})
});
fetch("http://localhost:5353/10").then(x => x.json()).then(x => {