Skip to content

Instantly share code, notes, and snippets.

View madeinfree's full-sized avatar
🐱
Focusing

Whien_Liou madeinfree

🐱
Focusing
View GitHub Profile
app.post('/audio-upload', (req, res) => {
var form = new formidable.IncomingForm();
form.uploadDir = './audio'; //set upload directory
form.keepExtensions = true;
form.type = true;
form.parse(req, function(err, fields, files) {
console.log(files);
});
form.on('file', function(field, file) {
require('fs').rename(
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "include/libplatform/libplatform.h"
#include "include/v8.h"
/* file: Recompose.re */
/* The very definition of a HOC, it's a function that gets a react component and returns another react component */
type hoc = ReasonReact.reactClass => ReasonReact.reactClass;
module type CreateWithStateParams = {
/* This is the secret sauce ingredient, with it the users can pass whatever state they want */
type state;
let defaultValue: state;
};
@madeinfree
madeinfree / what-forces-layout.md
Created August 15, 2018 11:43 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@madeinfree
madeinfree / babel-plugin-semantic-ui-react.js
Created September 2, 2018 13:53
Commonjs Semantic UI React Tree Shaking babel plugin
module.exports = function(babel) {
const { types: t } = babel;
const SingleTemplate = `semantic-ui-react/dist/commonjs/{{type}}/{{moduleName}}`;
const findTypeFolderToName = name => {
switch (name) {
case 'Grid':
case 'Breadcrumb':
case 'Form':
/**
* 如果 (if)
* 就 {}
* 喊(1) console.log(1)
* 不然就 else {}
* 喊(2) console.log(2)
* parse: if(15 > 10) { console.log(1); } else { console.log(2); }
*/
const code = `如果 (15 > 10) 就 喊(1)`;
@madeinfree
madeinfree / CreditCard.jsx
Created September 16, 2018 11:39
Rotate Credit Card for Reactjs
import React from "react";
import ReactDOM from "react-dom";
import "./styles.css";
function CreditCard(props) {
return (
<div className="credit-card__wrapper">
<div
className={`animation credit-card__gray ${
@madeinfree
madeinfree / index.html
Created September 23, 2018 02:42
use HTML5 MediaRecord API and SocketIO to build a simple voice room
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
@madeinfree
madeinfree / declare-idleCallback.ts
Created February 12, 2019 04:47
declare IdleCallback
type RequestIdleCallbackHandle = any;
type RequestIdleCallbackOptions = {
timeout: number;
};
type RequestIdleCallbackDeadline = {
readonly didTimeout: boolean;
timeRemaining: (() => number);
};
declare global {
module.exports = {
generateMultipleInsertValues(data) {
return data.reduce((result, nextData, index) => {
result = result + Object.keys(nextData).reduce((values, key, keyIndex, allKeys) => {
if (keyIndex === 0) {
if (typeof nextData[key] === 'string') {
return values + `('${nextData[key]}', `
} else {
return values + `(${nextData[key]}, `
}