Skip to content

Instantly share code, notes, and snippets.

View RaoHai's full-sized avatar
🎯
Focusing

陆沉 RaoHai

🎯
Focusing
View GitHub Profile
@RaoHai
RaoHai / child.js
Created March 4, 2015 02:00
send server handle
process.on('message', function(msg, tcp) {
console.log('CHILD got message:', msg, tcp);
});
process.send({ foo: 'bar' });
@RaoHai
RaoHai / socket.cpp
Last active August 29, 2015 14:17
socket.cpp
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/shm.h>
import React from 'react';
import { Editor, EditorState } from 'draft-js';
export default class EditorCore extends React.Component {
constructor(props) {
super(props);
this.state = { editorState: EditorState.createEmpty() };
this.onChange = this._onChange.bind(this);
}
_onChange(editorState) {
@RaoHai
RaoHai / App.js
Created September 27, 2016 12:21
import React, { Component } from 'react';
import logo from '../logo.svg';
import './App.css';
import EditorCore from './EditorCore';
class App extends Component {
render() {
return (
<div className="App">
<div className="App-header">
export default {
BOLD: {
fontWeight: 700,
},
ITALIC: {
fontStyle: 'italic',
},
};
import React from 'react';
import { Editor, EditorState } from 'draft-js';
import InlineStyles from '../InlineStyles';
export default class EditorCore extends React.Component {
constructor(props) {
super(props);
this.state = { editorState: EditorState.createEmpty() };
this.onChange = this._onChange.bind(this);
}
import React from 'react';
import classnames from 'classnames';
import './highlightMenu.less';
function getSelectionClientRect() {
const selection = window.getSelection();
console.log('> getSelectionClientRect', selection.rangeCount, selection.isCollapsed);
if (selection.rangeCount && !selection.isCollapsed ) {
const range = selection.getRangeAt(0).cloneRange();
return range.getBoundingClientRect && range.getBoundingClientRect();
@keyframes pop-upwards {
0% {
transform: matrix(.97,0,0,1,0,12);
opacity: 0
}
20% {
transform: matrix(.99,0,0,1,0,2);
opacity: .7
}
@RaoHai
RaoHai / upload.js
Created December 9, 2016 07:46
Simpe Image Resampling
// var fileInput = document.querySelector('file');
var targetWidth = 400;
var targetHeight = 400;
function doUpload () {
// upload picture
}
fileInput.onChange = function () {
var file = this.files[0];
@RaoHai
RaoHai / run.js
Created October 10, 2017 02:37
一键拉黑本页红卫兵
[].slice.call(document.querySelectorAll('.follow_item'))
.map(function(item) {
var d = item.getAttribute('action-data');
var data = /uid=(\d+)&/g.exec(d);
var uid = data && data[1];
if (uid) {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://weibo.com/aj/f/addblack?ajwvr=6');
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");