Skip to content

Instantly share code, notes, and snippets.

@BUNotesAI
BUNotesAI / build artifacts like jar with jetbrains.md
Last active April 11, 2018 02:26
jetbrains package with jar file - export

To build a JAR file from a module

  1. On the main menu, choose Build | Build Artifact.
  2. From the drop-down list, select the desired artifact of the type JAR. The list shows all the artifacts configured for the current project. To have all the configured artifacts built, choose the Build all artifacts option.

Detail process

@BUNotesAI
BUNotesAI / 基于Dropbox实现的免费私有Git版本库托管.md
Last active April 11, 2018 02:26
基于Dropbox实现的免费私有Git版本库托管 from: http://bit.ly/2H8gmV7

基于Dropbox实现的免费私有Git版本库托管

你是否有私有Git项目需要托管却又不想把你买午饭的钱用来购买Github的付费账户?Git与Dropbox整合使用可以免费的实现这一目的,从而你的代码库可以同步到Dropbox并且在多台电脑上同步,通过这种方式你可以托管任意数量的版本库,并且是云备份哦!~。Dropbox的免费账户就有2G的空间,如果只用来托管代码是完全足够的。

下面就来一步一步的实现这个功能。

创建一个普通的本地Git版本库

创建一个git目录来存放你的版本库

@BUNotesAI
BUNotesAI / 00 [Shell脚本增加bom方式解决csv文件乱码问题].md
Last active April 11, 2018 02:27
Shell script to add UTF-8 BOM to any file (from: https://gist.github.com/jamesqo/d65e10f6a2aa3fc6ffe0) 解决Excel乱码的问题

解决Excel乱码的问题

如下java代码导出的csv文件用Excel打开还是乱码, 用Sublime Text的Save with Encoding -> UTF-8 with BOM

public static void exportWithOpencsvBySql(String sql, String file) throws Exception {
        OutputStreamWriter ows = new OutputStreamWriter(new FileOutputStream(new File("/tmp/" + file)), "utf-8");
        try {
 CSVWriter writer = new CSVWriter(ows);
@BUNotesAI
BUNotesAI / creating git branch from tag.md
Last active April 11, 2018 02:28
creating git branch from tag

Go to the starting point of the project git checkout origin master

fetch all objects git fetch origin

Make the branch from the tag git branch new_branch tag_name

Checkout the branch

@BUNotesAI
BUNotesAI / 00 [get github gists with httpclient].md
Last active April 11, 2018 02:29
get github gists with httpclient
;;
@BUNotesAI
BUNotesAI / 00 [clojure调用google api实现客户端翻译].md
Last active April 11, 2018 02:30
google translate with httpclient

google api 翻译

>! 基本用法

promise and deliver

(defn <!!
  "takes a val from port. Will return nil if closed. Will block
  if nothing is available."
  [port]
 (let [p (promise)
@BUNotesAI
BUNotesAI / 00 [core.async alts! 选取最快的服务].md
Last active April 11, 2018 02:32
core.async alts! 选取最快的服务

alts! vs alt!

alts! is a function that accepts a vector of channels to take from and/or channels with values to be put on them (in the form of doubleton vectors: [c v]). The vector may be dynamically constructed; the code calling alts! may not know how many channels it'll be choosing among (and indeed that number need not be constant across invocations).

alt! is a convenience macro which basically acts as a cross between cond and alts!. Here the number of "ports" (channels or channel+value

@BUNotesAI
BUNotesAI / 1_donation.clj
Last active March 31, 2018 11:33
STM usage ref and dosync (alter , commute, ensure)
(def total-donations (ref 0))
(def count-donations (ref 0))
;; start 9 people collecting money
(comment
(dotimes [_ 9]
(doto (Thread. (fn []
;; go collect $10
@BUNotesAI
BUNotesAI / 0_delay.clj
Last active March 31, 2018 11:07
delay 用法
;;
;; clojure.core
;; 延迟执行并缓存
;; add something
(comment
(defmacro delay
"Takes a body of expressions and yields a Delay object that will
invoke the body only the first time it is forced (with force or deref/@), and
will cache the result and return it on all subsequent force
calls. See also - realized?"