Joseph Chu's Blog

积极勤奋,主动勇敢


  • Home

  • Archives

  • Tags

  • Categories

  • About

  • Search

子网掩码

Posted on 2018-07-24 | Edited on 2018-12-30 | In CS Basics

子网掩码(network)即该子网的地址。即规定所有该子网内的IP地址的前若干位应相同。

Read more »

如何在Mac上用Script启动Quicktime录制?

Posted on 2018-07-23 | Edited on 2018-12-30 | In Mac

1)创建AppleScript文件,输入一下代码并保存。如QTRecord.scpt

1
2
3
4
tell application "QuickTime Player"
activate
start (new movie recording)
end tell

2)在终端执行

1
osascript QTRecord.scpt

3)或者也可以一句话搞定以上两步

1
osascript -e 'tell application "QuickTime Player" to activate' -e 'tell application "QuickTime Player" to start (new movie recording)'

摘自How to start QuickTime recording at command line?

Read more »

Flask调用自己定义的api

Posted on 2018-07-23 | Edited on 2018-12-30 | In Backend

最近自己的做的一个项目flask_microblog里面有一个需求,就是要以api调用的形式显示用户的头像。

最初时为了简单,直接调用了Gravatr的api,就像这样。

1
2
def avatar(self):
return 'https://www.gravatar.com/avatar/6b541a0a667f5558208aad7309c22936'

后来为了实现GitHub风格的默认头像功能,就自己写了个简单的api,就像这样

Read more »

Python和OpenCV实现仿Github默认头像

Posted on 2018-07-21 | Edited on 2018-12-30 | In Personal Projects

思路

首先我们需要知道Github默认头像的一些参数。

  • GitHub默认头像是一个420*420像素的正方形图像,里面有个5*5的方块矩阵,每个方块为70*70像素。方块矩阵距离图像边缘的距离是35像素。
  • GitHub默认头像是左右对称的
  • GitHub默认头像的背景色是E6E6E6, 或者[230,230,230]

知道了这些以后,我们就可以着手开始做了。

Read more »

[Python] 注释规范

Posted on 2018-05-26 | Edited on 2018-12-30 | In Programming Languages

函数注释

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def function(arg1, arg2...):
""" [Brief description of function]

[Detailed description of function]

Args:
[arg1]: [Description of arg1]
[arg2]: [Description of arg2]
...

Returns:
[Description of returns]
For example:

[Example of returns]

[Any supplementary description of returns]

Raises:
[exception_type]: [description of exception]

"""
pass
Read more »

HBase 的启动

Posted on 2018-05-06 | Edited on 2018-12-30 | In Distributed Computing

HBase 的启动

start-hbase.sh
这个会启动整个hbase,包括master, regionserver, zookeeper

如果要单独启动master和regionserver,可参考以下方式

在regionServer上 hbase-daemon.sh start regionserver

在master上执行:hbase-daemon.sh start master

HBase shell 无法使用

Posted on 2018-05-06 | Edited on 2018-12-30 | In Distributed Computing

报错信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
hbase(main):001:0> list
TABLE

ERROR: org.apache.hadoop.hbase.PleaseHoldException: Master is initializing
at org.apache.hadoop.hbase.master.HMaster.checkInitialized(HMaster.java:1869)
at org.apache.hadoop.hbase.master.MasterRpcServices.getTableDescriptors(MasterRpcServices.java:775)
at org.apache.hadoop.hbase.protobuf.generated.MasterProtos$MasterService$2.callBlockingMethod(MasterProtos.java:42402)
at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:2031)
at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:107)
at org.apache.hadoop.hbase.ipc.RpcExecutor.consumerLoop(RpcExecutor.java:130)
at org.apache.hadoop.hbase.ipc.RpcExecutor$1.run(RpcExecutor.java:107)
at java.lang.Thread.run(Thread.java:744)

Here is some help for this command:
List all tables in hbase. Optional regular expression parameter could
be used to filter the output. Examples:
hbase> list
hbase> list 'abc.*'
hbase> list 'ns:abc.*'
hbase> list 'ns:.*'

原因

出现这种问题的原因是因为多台节点的时间不同步,导致节点之间的连接时间超时

解决方案

  1. 通过 ntpdate 0.cn.pool.ntp.org 命令使各个节点的时间跟网络时间同步
  2. 通过data -s命令手动调整节点时间

Google Python命名规范

Posted on 2018-05-01
1
2
3
4
5
6
7
8
9
10
module_name, 
package_name,
ClassName,
method_name,
ExceptionName,
function_name,
GLOBAL_VAR_NAME,
instance_var_name,
function_parameter_name,
local_var_name.

[Python] 引用上级目录

Posted on 2018-04-30 | Edited on 2018-12-30 | In Programming Languages

最近项目中需要用到与当前脚本所在目录同级的另一个目录下的文件,大概目录结构如下

Read more »

2018年网易PM599产培生-云计算领域 面试总结

Posted on 2018-04-30 | Edited on 2018-12-30 | In Interview

四月19号去杭州参加了网易产培的面试,作为浙江人,感觉对杭州有种天然的好感。网易园区就在阿里的旁边,显得有些不太起眼,但是园区内的环境很漂亮,休息区的环境也很好。

今年是网易产培的第二年,很幸运地进入到了终面,虽然最终没有拿到Offer,但是也很感恩有这样的一次机会可以近距离地接触网易,接触产品,并且锻炼自己。

今年据我所知网易产培有一个大的微信群,里面差不多有190人,内容领域居多。我所在的云计算领域大概有40人左右,最后拿到Offer是一位很厉害的南大小姐姐。

下面大概总结一下自己的面试经过,写的比较松散,还请见谅。

Read more »
1…5678

Joseph Chu

一日之功很有限,不过可以积少成多
72 posts
17 categories
50 tags
© 2019 Joseph Chu
Powered by Hexo v3.6.0
|
Theme – NexT.Pisces v7.0.1