Skip to content

Instantly share code, notes, and snippets.

global.io.on('connection', (socket) => {
socket.setMaxListeners(20);
console.log('index connected')
socket.emit('notification', {
unread: 2,
list: [{
requestor: {
name: 'hello',
id: 'word',
avatar:'https://semantic-ui.com/images/avatar2/small/rachel.png'
$(document).ready(function () {
// socket.io
let socket = io.connect(window.location.href,{'forceNew':true });
// notification
socket.on('notification', function(data){
notification(data)
});
// end socket io
});
import express from "express"
import next from "next"
import bodyParser from "body-parser"
import cookieParser from "cookie-parser"
import dotenv from "dotenv"
import jwt from "jsonwebtoken"
import lusca from "lusca"
import moment from "moment"
import helmet from "helmet"
import Auth from "./tools/Auth"
import React from "react"
import { translate } from "react-i18next"
import { Button, Container, Divider, Grid, Icon, Menu, Segment, Input, Responsive } from "semantic-ui-react"
import Link from "next/link"
import MetaTags from "./HeadTags"
const menuItem = [ "workflow", "plugins", "events", "training", "contact" ]
export default class topMenu extends React.Component {
constructor(props) {
super(props)
@nhanco
nhanco / Login.js
Created March 7, 2018 14:51
[DOM] Password field is not contained in a form: (More info: https://goo.gl/9p2vKq) <input type=​"password" placeholder=​"Password" class=​"form-control">​
import React, { Component, PropTypes } from "react"
import { Form, FormGroup, Label, Button, Input, InputGroup, InputGroupAddon, InputGroupText } from "reactstrap"
export default class Login extends React.Component {
render() {
return (
<Form className="was-validated">
<InputGroup className="mb-3">
<InputGroupAddon addonType="prepend">
<InputGroupText>
@nhanco
nhanco / client.js
Created March 26, 2018 15:20
csurf
exports.post = (urlPath, postData, callback) => {
axios.post(urlPath, qs.stringify(postData),{
headers: {'X-Requested-With': 'XMLHttpRequest'},
xsrfCookieName:'csrftoken',
xsrfHeaderName:'csrf-token',
data:postData
})
.then(function (response) {
callback(response)
@nhanco
nhanco / nginx-dev-ssl.sh
Created July 7, 2018 16:02 — forked from LeZuse/nginx-dev-ssl.sh
nginx development SSL setup on localhost
# copy default OpenSSL config
cp /usr/local/etc/openssl/openssl.cnf .
# make changes according to https://fbcs.co.uk/self-signed-multiple-domain-ssl-certificates/
vim openssl.cnf
# [alt_names]
# DNS.1 = localhost
# IP.1 = 0.0.0.0
# IP.2 = 127.0.0.1
@nhanco
nhanco / perssit.js
Created December 27, 2018 07:05
perssit bug
export const toggleConfig = key => ({ type: "TOGGLECONFIG", key })
const initialState = {
darkMode: false,
element: true,
compare: true,
god: true,
immortal: true,
trieu: true,
yTuong: true,
tangBo: true,
@nhanco
nhanco / childrenWithProps.js
Created January 7, 2019 06:42
Send props color = this.props.color to all children
const { children } = this.props
const childrenWithProps = React.Children.map(children, child =>
React.cloneElement(child,{color:this.props.color})
)
@nhanco
nhanco / tomorrow.js
Created January 15, 2019 08:16
wtf bug
function tomorrow(str) {
var r = []
var d = new Date(str)
d.setDate(d.getDate() + 1)
r["year"] = d.getFullYear()
r["month"] = d.getMonth() + 1
r["day"] = d.getDate()
return r
}