Skip to content

Instantly share code, notes, and snippets.

View hoangthai0302's full-sized avatar

hoangthai0302

View GitHub Profile
@hoangthai0302
hoangthai0302 / socket-cheatsheet.js
Created November 9, 2019 05:18 — forked from alexpchin/socket-cheatsheet.js
A quick cheatsheet for socket.io
// sending to sender-client only
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
@hoangthai0302
hoangthai0302 / client.js
Created November 4, 2019 02:04 — forked from crtr0/client.js
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});
@hoangthai0302
hoangthai0302 / test.md
Created January 18, 2019 16:05
Test lepton
var x = 5;
console.log(x);

Here is the demo for lepton

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@hoangthai0302
hoangthai0302 / connectExample.js
Created March 9, 2018 16:35 — forked from markerikson/connectExample.js
React-Redux connect example
import {action1, action2} from "myActions";
import {bindActionCreators} from "redux";
import {connect} from "react-redux";
const mapStateToProps = (state, ownProps) = {
return {
counter : state.counter,
someComponentValue : state.things[ownProps.someIdProp]
};
}
@hoangthai0302
hoangthai0302 / index.html
Created September 26, 2017 02:18
JS Bin code rxjs for searchbox // source http://jsbin.com/gocoduy
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="code rxjs for searchbox">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<input id="input">
h1 {
color:red
}
@hoangthai0302
hoangthai0302 / index.html
Created September 26, 2017 02:04
JS Bin rxjs interval example // source http://jsbin.com/juboto
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="rxjs interval example">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://npmcdn.com/@reactivex/rxjs@5.0.0-beta.3/dist/global/Rx.umd.js"></script>
</head>
<body>