Skip to content

Instantly share code, notes, and snippets.

@li2
li2 / IOHelper.java
Last active March 20, 2018 07:05
read bytes stream from IO #tags: java
class IOHelper {
public byte[] readBytes(InputStream inputStream) throws IOException {
// this dynamically extends to take the bytes you read
ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
// this is storage overwritten on each iteration with bytes
int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
// we need to know how may bytes were read to write them to the byteBuffer
@li2
li2 / ProgressRequestBody.java
Last active March 20, 2018 11:50
[Is it possible to show progress bar when upload image via Retrofit 2?] http://stackoverflow.com/questions/33338181/is-it-possible-to-show-progress-bar-when-upload-image-via-retrofit-2/33384551#33384551 #tags: android-network
public class ProgressRequestBody extends RequestBody {
private File mFile;
private String mPath;
private UploadCallbacks mListener;
private static final int DEFAULT_BUFFER_SIZE = 2048;
public interface UploadCallbacks {
void onProgressUpdate(int percentage);
void onError();
@li2
li2 / iterm2-solarized.md
Last active March 20, 2018 04:40 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + Powerlevel9k - (macOS) #tags: tool

Default

Default

Powerlevel9k

Powerlevel9k

@li2
li2 / c.md
Last active March 20, 2018 10:55
Jira workflow #tags: agile

//Jira workflow

Jira workflow

@li2
li2 / c.md
Last active March 20, 2018 07:03
git remote: determine the URL that a local Git repository was originally cloned from #tags: git

If referential integrity has been broken:

git config --get remote.origin.url

If referential integrity is intact:

git remote show origin
@li2
li2 / c.md
Last active March 20, 2018 07:02
[Git Feature Branch Workflow] The core idea behind the Feature Branch Workflow is that all feature development should take place in a dedicated branch instead of the master branch. #tags: git

The core idea behind the Feature Branch Workflow is that all feature development should take place in a dedicated branch instead of the master branch. This encapsulation makes it easy for multiple developers to work on a particular feature without disturbing the main codebase. It also means the master branch will never contain broken code, which is a huge advantage for continuous integration environments.

pull requests make it incredibly easy for your team to comment on each other’s work.

link: Git Feature Branch Workflow

Start with the master branch

git checkout master

@li2
li2 / c.md
Last active March 20, 2018 06:58
[gitk : View the details changed history of an individual file using Git versioning] https://goo.gl/NvJUD9 #tags: git

For this I'd use:

gitk [filename]

or to follow filename past renames

gitk --follow [filename]

@li2
li2 / c.md
Last active March 20, 2018 04:48
lambda #tags: java

@li2
li2 / introrx.md
Last active June 17, 2018 09:21
[The introduction to Reactive Programming you've been missing] #tags: rx
@li2
li2 / category_plugin.rb
Last active May 6, 2018 11:48
[How I organize posts in Jekyll (code snippets for blog post - see comments)] #tags: tool
module Jekyll
Page.class_eval {
def clone
Page.new(@site, @base, @dir, @name)
end
}