Skip to content

Instantly share code, notes, and snippets.

Avatar

Sunho Kim sunho

View GitHub Profile
View client.js
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 => {
View asdf
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
View typeof.go
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
View component vs container
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.
View example1-4.as
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;
View example1-3.as
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));
View example1-2.as
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);
View example1-1.as
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);
View toggle.js
toggleDetails() {
this.setState({
showDetails: !this.state.showDetails
});
}
View error.go
func badtype(expected string, data interface{}) error {
return e("cannot load TOML value of type %T into a Go %s", data, expected)
}
You can’t perform that action at this time.