Skip to content

Instantly share code, notes, and snippets.

@Duobe
Duobe / gist:fa8bd8e1ac7222d881959d2cbc853994
Created June 2, 2017 09:43 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@Duobe
Duobe / TestSetupExampleCRAEnzymeChaiMocka.md
Created June 15, 2017 07:20 — forked from busypeoples/TestSetupExampleCRAEnzymeChaiMocka.md
Mocha/Chai/Enyzme test setup with create-react-app

Basic setup for using Enzyme/Mocha/Chai with create-react-app

This is a temporary solution. Might change in the near future, this depends on how create-react-app will implement testing.

create-react-app quick-test-example

cd quick-test-example

npm run eject
@Duobe
Duobe / index.js
Created August 15, 2017 08:06
时间计算
getTimeByYearAndMonth = () => {
// month start with 0
// 获取某日开始时间、结束时间
const firstTimeOfDay = new Date(year, month, date);
const lastTimeOfDay = new Date(new Date(year, month, date + 1) - 1);
// 获取某月开始第一天时间、月最后一天时间
const firstDayOfMonth = new Date(year, month, 1);
const lastDayOfMonth = new Date(new Date(year, month + 1, 1) - 1);
@Duobe
Duobe / 1.js
Last active March 8, 2021 05:37
Check if an array contains any element of another array in JavaScript
let a = ['a', 'b', 'c'];
let b = ['c', 'a', 'd'];
let c = ['f', 'g', 'h'];
console.log(a, b, a.some(v => b.includes(v)));
console.log(a, b, a.some(v => b.indexOf(v) >= 0);
console.log(a, c, a.some(v => b[b.indexOf(v)] === v));
@Duobe
Duobe / colors.less
Last active December 14, 2017 08:28
@rectangle-color: green;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
body {
background: black;
}
@Duobe
Duobe / method_01.js
Created April 17, 2018 13:28
日期选择器
function calendar() {
const {year, month, current} = this.state
console.log(current)
const LastDate = this.getLastDateOfMonth(year, month)
const array = []
const preMonthDiffDay = this.getFirstDateOfMonth(year, month).getDay()
const selectedDate = `${current.getFullYear()}-${current.getMonth() + 1}-${current.getDate()}`
@Duobe
Duobe / webpack.config.js
Created August 6, 2018 08:42 — forked from learncodeacademy/webpack.config.js
Sample Basic Webpack Config
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
context: __dirname,
devtool: debug ? "inline-sourcemap" : null,
entry: "./js/scripts.js",
output: {
path: __dirname + "/js",
filename: "scripts.min.js"
@Duobe
Duobe / commit-message-convention.md
Created August 7, 2018 01:50 — forked from julienbourdeau/commit-message-convention.md
The seven rules of a great git commit message

Source: http://chris.beams.io/posts/git-commit/#seven-rules

  1. Separate subject from body with a blank line
  2. Limit the subject line to 50 characters
  3. Capitalize the subject line
  4. Do not end the subject line with a period
  5. Use the imperative mood in the subject line
  6. Wrap the body at 72 characters
  7. Use the body to explain what and why vs. how
root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 100