Skip to content

Instantly share code, notes, and snippets.

View chenminhua's full-sized avatar
🎯
Focusing

陈敏华 chenminhua

🎯
Focusing
View GitHub Profile
@chenminhua
chenminhua / 00-about-search-api-examples.md
Created March 6, 2016 10:20 — forked from jasonrudolph/00-about-search-api-examples.md
5 entertaining things you can find with the GitHub Search API
@chenminhua
chenminhua / template.js
Created May 1, 2017 07:10
模板引擎
String.prototype.render = function(obj) {
return this.replace(/\$\{(\w+|\w+\.\w+)\}/g, match => {
var keys = match.replace('${', '').replace('}', '').split('.')
return keys.reduce((acc, cv) => acc[cv], obj)
})
}
String.prototype.render = function (obj) {
with(obj) {
return eval('`' + this + '`')
const DateType = new GraphQLScalarType({
name: 'DateType',
description: '自定义时间类型',
parseValue: String,
serialize(value) {
return value.toString();
},
parseLiteral(ast) {
if (!moment(ast.value).isValid()) {
throw new GcBaseError('非法时间');
var http = require('http');
var net = require('net');
var url = require('url');
function request(cReq, cRes) {
var u = url.parse(cReq.url);
var options = {
hostname : u.hostname,
port : u.port || 80,
var http = require('http');
var net = require('net');
var url = require('url');
function request(cReq, cRes) {
var u = url.parse(cReq.url);
var options = {
hostname : u.hostname,
port : u.port || 80,
#!/bin/bash
#
# chkconfig: 2345 77 22
# description: Test Service
#
LOCKFILE=/var/lock/subsys/myservice
status() {
if [ -e $LOCKFILE ]; then
echo "Running..."
@chenminhua
chenminhua / Linux Static IP
Created August 3, 2017 03:04 — forked from fernandoaleman/Linux Static IP
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
digraph architecture {
rankdir=LR;
// Storage - #303F9F (dark blue)
node[fillcolor="#303F9F" style="filled" fontcolor="white"];
database[label="DB"]; cache[label="Redis"];
// Client-side Apps - #FFEB3B (yellow)
node[fillcolor="#FFEB3B" style="filled" fontcolor="black"];
front_end[label="Front-end App"]; extension[label="Browser Extension"];
@chenminhua
chenminhua / PrometheusAutoConfigure.java
Last active May 9, 2018 09:57
Spring Auto Configure
@Configuration
public class PrometheusAutoConfigure {
@Bean
SpringBootMetricsCollector springBootMetricsCollector(Collection<PublicMetrics> publicMetrics) {
SpringBootMetricsCollector springBootMetricsCollector = new SpringBootMetricsCollector(publicMetrics);
springBootMetricsCollector.register();
return springBootMetricsCollector;
@chenminhua
chenminhua / main.go
Created May 15, 2018 05:02
基于etcd的分布式锁
func main() {
c, err := clientv3.New(clientv3.Config{
Endpoints: []string{"ip:port"},
DialTimeout: 5 * time.Second,
})
if err != nil {
panic(err)
}
lockKey := "/lock"