Skip to content

Instantly share code, notes, and snippets.

View axetroy's full-sized avatar
💭
Get busy living or get busy dying

Axetroy axetroy

💭
Get busy living or get busy dying
View GitHub Profile
@axetroy
axetroy / .bashrc
Created July 7, 2017 07:34
Bash Config
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@axetroy
axetroy / README.md
Created June 27, 2017 06:53
List of languages that compile to JS
@axetroy
axetroy / README.md
Created June 26, 2017 01:54
Github两步验证的恢复码

经过最严格的加密算法加密

用于恢复无法使用两步验证的情况

@axetroy
axetroy / README.md
Last active September 26, 2017 03:05
解决Linux下因防火墙问题无法开放端口

暂时开放所有

iptables -I INPUT -j ACCEPT
@axetroy
axetroy / README.md
Created June 12, 2017 02:17
Linux下的smb配置

因为开发中有协同需求,需要远程修改另一台电脑上的文件.

如果使用默认的smb配置,则会有写入权限问题: 既文件权限改成写入人

例如A要去改B电脑上的文件

A改了文件之后,文件的所有权变成了A的,而B没有该文件的权限,这会导致一些问题.

摸索了一下,解决了这个问题

@axetroy
axetroy / README.md
Last active January 18, 2024 15:28
nginx接口转发/代理/单页面应用配置

关于nginx的小小笔记

不常用,没过一段时间都要去搜一下,干脆自己记下来

重启nginx服务器

/etc/init.d/nginx restart
# or
service nginx restart
@axetroy
axetroy / str2color.js
Last active March 20, 2021 14:02
根据一个字符串,生成一个动态的hex颜色
var stringToColor = function(str) {
var hash = 0;
for (var i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
var color = '#';
for (var i = 0; i < 3; i++) {
var value = (hash >> (i * 8)) & 0xFF;
color += ('00' + value.toString(16)).substr(-2);
}
@axetroy
axetroy / maximum-difference.js
Last active August 18, 2020 08:45
美团2016校招算法题-最大差值
/*
描述:
有一个长度为n的A,满足0<=a<=b<=n的A[b] - A[a]的最大值
给定数组A以及它的大小n,请返回最大差值
example:
[10, 5], 2
@axetroy
axetroy / point.js
Last active April 26, 2017 09:54
坐标系中如何最快确定距离最近/远的两个点, 如果选择一条最优路线
class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
distance(point) {
const diffX = Math.abs(point.x - this.x);
const diffY = Math.abs(point.y - this.y);
return Math.sqrt(Math.pow(diffX, 2) + Math.pow(diffY, 2));
}
@axetroy
axetroy / diff-time.js
Created April 25, 2017 02:32
计算两个时间点的时间差
function diffTime(time1) {
return function(time2) {
let seconds = Math.abs(time1 - time2) / 1000;
const days = Math.floor(seconds / (3600 * 24));
seconds = seconds - days * 3600 * 24;
const hours = Math.floor(seconds / 3600);
seconds = seconds - hours * 3600;
const minutes = Math.floor(seconds / 60);