Skip to content

Instantly share code, notes, and snippets.

View d6u's full-sized avatar

Daiwei Lu d6u

View GitHub Profile

Homebrew on Mac

A cleaner solution is to install homebrew into a custom location in a user's folder - use ~/homebrew/. Don't touch /opt/homebrew folder

Configure homebrew for use with a local folder. Here's how you can do it:

  1. Clone homebrew to a local directory, e.g., if you want to have it in ~/homebrew, run the command git clone https://github.com/Homebrew/brew ~/homebrew
  2. Add brew binary folders to the PATH environmental variable: echo 'export PATH="$HOME/homebrew/bin:$HOME/homebrew/sbin:$PATH"' >> ~/.bash_profile, then source ~/.bash_profile
  3. Run brew update; then use brew as you normally would, e.g. brew install octave
{
"compileOnSave": false,
"enableAutoDiscovery": false,
"compilerOptions": {
"declaration": true,
"declarationDir": "lib",
"module": "commonjs",
"noImplicitAny": true,
"noImplicitThis": true,
"noUnusedLocals": true,
import sax = require('sax');
/**
* Beautify HTML for human
*/
export function beautify(html: string) {
return new Promise((resolve, reject) => {
const parser = sax.parser(false, {});
let indent = 0;
@d6u
d6u / calculator.html
Last active January 11, 2022 06:47
Basic calculator in HTML
<html>
<head>
<meta charset="UTF-8">
<title>Calculator</title>
<style>
* {
box-sizing: border-box;
}
.calculator {
width: 400px;
@d6u
d6u / c.cpp
Created August 30, 2016 20:54
class WordDictionary {
private:
    struct Node {
        bool isWord;
        vector<Node*>sub;
        Node(): isWord(false), sub(vector<Node*>(26, NULL)){}
    };
    Node *dict = new Node();
public:
    
@d6u
d6u / demo.js
Created July 27, 2016 20:52 — forked from anatoliychakkaev/demo.js
Require in runInNewContext
var Module = require('module');
var vm = require('vm');
var path = require('path');
var filename = process.cwd() + '/lib/eval.js';
var mod = new Module(filename);
var context = {
module: mod,
__filename: filename,
{
"compileOnSaveDefinition": false,
"compilerOptions": {
"declaration": false,
"diagnostics": false,
"listFiles": false,
"module": "commonjs",
"noImplicitAny": true,
"outDir": "lib",
"pretty": true,
import React from 'react';
import ReactDOM from 'react-dom';
import {createStore} from 'redux';
import {Provider, connect} from 'react-redux';
import set from 'lodash/fp/set';
const ADD_TAG = 'ADD_TAG';
const repos = require('json!./repos.json');
[
{ "keys": ["ctrl+shift+r"], "command": "reveal_in_side_bar"},
{
"keys": ["ctrl+shift+a"],
"command": "align_tab",
"args": {
"user_input": "=/f"
}
}
]
npm config set init.author.name "Daiwei Lu"
npm config set init.author.email daiweilu123@gmail.com
npm config set init.author.url http://daiwei.lu/
npm config set init.license MIT