Skip to content

Instantly share code, notes, and snippets.

View vagusX's full-sized avatar
🎯
Focusing

vagusX vagusX

🎯
Focusing
View GitHub Profile
@vagusX
vagusX / gist:cd04c081a1b2858ff369d4941518bd5c
Created December 6, 2023 04:43
切掉图片白边.js
// write by openai chatgpt
const Jimp = require('jimp');
Jimp.read('./sample.jpg')
.then((image) => {
const width = image.bitmap.width;
const height = image.bitmap.height;
let left = 0;
let top = 0;
@vagusX
vagusX / sublime-command-line.md
Created January 18, 2018 08:49
Launch Sublime Text from the command line on OSX

Launch Sublime Text from the command line on OSX

Sublime Text includes a command line tool, subl, to work with files on the command line. This can be used to open files and projects in Sublime Text, as well working as an EDITOR for unix tools, such as git and subversion.

Requirements

  • Sublime text 2 or 3 installed in your system within Applications folder

Setup

@vagusX
vagusX / modal.tsx
Last active December 26, 2017 02:40
write a modal in react 15
import * as React from 'react'
import Overlay from './Overlay'
const styles = require('./styles.scss')
const Modal = props => {
const { show, onCancel, children } = props
return (
<Overlay show={show} onCancel={onCancel}>
@vagusX
vagusX / rm_mysql.md
Created November 26, 2017 13:06 — forked from vitorbritto/rm_mysql.md
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

brew remove mysql

@vagusX
vagusX / coordinating-async-react.md
Created September 19, 2017 01:58 — forked from acdlite/coordinating-async-react.md
Demo: Coordinating async React with non-React views

Demo: Coordinating async React with non-React views

tl;dr I built a demo illustrating what it might look like to add async rendering to Facebook's commenting interface, while ensuring it appears on the screen simultaneous to the server-rendered story.

A key benefit of async rendering is that large updates don't block the main thread; instead, the work is spread out and performed during idle periods using cooperative scheduling.

But once you make something async, you introduce the possibility that things may appear on the screen at separate times. Especially when you're dealing with multiple UI frameworks, as is often the case at Facebook.

How do we solve this with React?

@vagusX
vagusX / jsbin.zukeyof.js
Last active May 28, 2017 12:54
React Life Cycle// source http://jsbin.com/zukeyof
'use strict';
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = pr
@vagusX
vagusX / dfs.js
Created March 31, 2017 04:05 — forked from Dammmien/dfs.js
Depth First Search (DFS) Graph Traversal in Javascript
var nodes = [
{
links: [ 1 ], // node 0 is linked to node 1
visited: false
}, {
links: [ 0, 2 ], // node 1 is linked to node 0 and 2
visited: false
},
...
];
@vagusX
vagusX / android_instructions.md
Created March 10, 2017 05:45 — forked from patrickhammond/android_instructions.md
Easily setup an Android development environment on a Mac

Here is a high level overview for what you need to do to get most of an Android environment setup and maintained.

Prerequisites (for Homebrew at a minimum, lots of other tools need these too):

  • XCode is installed (via the App Store)
  • XCode command line tools are installed (xcode-select --install will prompt up a dialog)
  • Java

Install Homebrew:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

@vagusX
vagusX / drop-filter.js
Created January 18, 2017 09:33
drop-filter in d3
// add drop shadow for hovering/selected
var filter = svg.append('defs')
.append('filter')
.attr('id', 'drop-shadow')
// .attr('filterUnits', 'userSpaceOnUse')
.attr('x', 0)
.attr('y', 0)
.attr('width', '200%')
.attr('height', '200%')
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy