Skip to content

Instantly share code, notes, and snippets.

View garrus's full-sized avatar

Yaowen Hu garrus

  • Douyu TV
  • Wuhan Hubei, China
View GitHub Profile
@garrus
garrus / Another-style-of-syntactic-sugar-on-error-handling.md
Last active August 30, 2018 05:42
Another style of syntactic sugar on error handling

The check/handle keywords introduced to improve code style is a good effort, though doesn't help very much on the looking of golang source code. Before it, we see a lot of lines leading by if err != nil, after that we'll see a lot of lines leading by check.

How about we try another style, to put keyword AFTER a function call, just like below:

func CopyFile(src, dist string) error {

	on checked err {
(function(){
var fetchSectionDataApi = "http://news.oppomobile.com/api/news/index/focus";
var updateTitleApi = "http://news.oppomobile.com/M/News/entry/updateTitle/id/__ID__";
var clearSectionCacheApi = "http://news.oppomobile.com/M/News/apiData/rebuildCacheBySection/id/3";
var safeCheckCounter = 0;
checkWrongTitle();
function checkWrongTitle(){
$.get(fetchSectionDataApi + "?_t=" + Date.now(), function(json){
@garrus
garrus / bchat.js
Created July 30, 2013 08:44
pagemanager, eventmanage, datapersister
/**
* A Renderer is responsible for rendering specified container on the page, maybe
* with given jquery template. It should also delegate UI events on the container.
* On destroyed, it will clear the container and remove all delegates.
*
* @param id
* @param container
* @param jQTemplateId
* @param defaultRenderMode
* @constructor
traps:
when use button as the _button target of FileUploader, it will create a input[type=file] in the tag, which looks like this:
<button id="upload-button"> <input type="file" /></button>
now, if you attempt to use bootstrap's button text functionality, like this:
<button id="upload-button" data-loading-text="Loading"><input type="file" /><button>
$('#upload-button').button();
and when you change the text and change it back, the events binder to input[type=file] will be lost.