Skip to content

Instantly share code, notes, and snippets.

@shrekuu
shrekuu / nginx-site-for-frp.conf
Created May 22, 2019 02:12
使用 nginx 代理帮助 "去掉" frp 代理用的端口号
server {
listen 80;
server_name example.com; # 指向你的网址
resolver 223.5.5.5 208.67.222.222 8.8.8.8 valid=300s;
resolver_timeout 10s;
add_header X-Cache $upstream_cache_status;
location / {
proxy_pass http://127.0.0.1:8080; # frp 默认使用了 8080 端口
proxy_redirect http://$host/ http://$http_host/;
proxy_set_header X-Real-IP $remote_addr;
@shrekuu
shrekuu / api-service.js
Last active June 16, 2019 04:26
小程序 api 请求数据方式封装
import { of } from 'rxjs'
import rxwx from 'rxjs6-wx'
import environment from '../environment'
import store from '../store'
// 假数据
import user from '../fixtures/user'
export default class ApiService {
constructor() {
@shrekuu
shrekuu / util.js
Last active April 25, 2019 02:11
跳转外部百度地图高德地图驾车线路规划
/**
* 跳转到地图导航界面
* http://lbsyun.baidu.com/index.php?title=uri/api/android
* https://developers.google.com/maps/documentation/urls/guide#directions-action
* @param longitude
* @param latitude
* @param mapAppName browser-浏览器打开, gaode-高德APP, baidu-百度APP,如果没有安装相应APP则使用浏览器打开。
* @param destination 目的地
*/
export function goToOuterMapApp (longitude = 0, latitude = 0, mapAppName = 'baidu', destination = '目的地') {
@shrekuu
shrekuu / App.js
Created January 31, 2019 09:58
react-native 微信登录示例代码片段
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
* @lint-ignore-every XPLATJSCOPYRIGHT1
*/
import React, {Component} from 'react';
@shrekuu
shrekuu / SwitchyOmega.txt
Last active January 6, 2019 14:34
科学上网配置 SwitchyOmega 2019-01-06
[SwitchyOmega Conditions]
@with result
*.cloudfront.net +科学上网
*.github.io +科学上网
*.githubusercontent.com +科学上网
*.4gifs.com +科学上网
*.akamaihd.net +科学上网
*.amazonaws.com +科学上网
*.android.com +科学上网
@shrekuu
shrekuu / project1.conf
Created November 13, 2018 04:11
nginx config for multiple angular projects
# config for 3 vhost; 2 angular projects, 1 backend api project.
# angular project1
# replace project1 with your own
server {
listen 80;
server_name project1.test;
access_log logs/project1.test-access.log;
@shrekuu
shrekuu / computed.js
Created November 12, 2018 10:42
an example of object computed property
// from: https://codepen.io/lamerumixa/pen/OxZgvO?editors=1010
var Dep = {
deps: {},
target: null,
subscribe: function (key) {
if (!this.deps[key]) this.deps[key] = [];
if (this.target && this.deps[key].indexOf(this.target) == -1) {
this.deps[key].push(this.target);
}
@shrekuu
shrekuu / httpGet.js
Created September 18, 2018 07:32
XMLHttpRequest to Promise
function httpGet(url, responseType = '') {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest()
xhr.onload = function() {
if (this.status === 200) {
resolve(xhr.response)
} else {
reject(new Error(this.statusText))
}
}
@shrekuu
shrekuu / fibonacci-js.md
Created September 11, 2018 08:07
Fibonacci Sequence js -- Dynamic Programming Tutorial with Fibonacci Sequence
@shrekuu
shrekuu / homebrew-mirror-in-china.sh
Last active August 15, 2023 02:42
homebrew 中国镜像服务, 清华大学与中科大
# 清华大学:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
# 手动修改 bottles 地址:
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
# 或: