Skip to content

Instantly share code, notes, and snippets.

Avatar

CosmoX hackjutsu

View GitHub Profile
View kickstart.sh
# installation: pip3 install wordcloud
wordcloud_cli --text mytext.txt --imagefile wordcloud.png
View test.graphql
query {
resolution {
....
#define section-info
section {
name
uniqueName
href
parameters {
key
@hackjutsu
hackjutsu / retryer.java
Created Jun 20, 2020
[Guava Retryer] Snippet for retrying by Guava Retryer https://github.com/rholder/guava-retrying
View retryer.java
Callable<Boolean> callable = new Callable<Boolean>() {
public Boolean call() throws Exception {
return true; // do something useful here
}
};
Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder()
.retryIfResult(Predicates.<Boolean>isNull())
.retryIfExceptionOfType(IOException.class)
.retryIfRuntimeException()
@hackjutsu
hackjutsu / test.bat
Created Jun 6, 2020
[test scirpt for batch]
View test.bat
@ECHO OFF
for /l %%a IN (4,-1,0) do (
echo.%%a: First command in block
echo. Second command in block
)
echo.
if exist "c:\windows" (
echo.The c:\windows directory exist.
set "IsWin=YES"
@hackjutsu
hackjutsu / .zshrc
Created Jun 6, 2020
[my zsh configurations] #zsh
View .zshrc
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/cosmoqiu/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
View 20111011_SteveYeggeGooglePlatformRant.md

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

View two-pointer-container-with-most-water.md

Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water. From https://leetcode.com/problems/container-with-most-water/

Algorithm

The intuition behind this approach is that the area formed between the lines will always be limited by the height of the shorter line. Further, the farther the lines, the more will be the area obtained.

We take two pointers, one at the beginning and one at the end of the array constituting the length of the lines. Futher, we maintain a variable \text{maxarea}maxarea to store the maximum area obtained till now. At every step, we find out the area formed between them, update \text{maxarea}maxarea and move the pointer pointing to the shorter line towards the other end by one step.

@hackjutsu
hackjutsu / ClientDemo.java
Created May 23, 2019
[medium snippets] #medium #designPattern #StatePattern
View ClientDemo.java
public class ClientDemo {
public static void main(String[] args) {
MP3PlayerContext mp3Player = new MP3PlayerContext();
mp3Player.press();
mp3Player.getState();
mp3Player.press();
mp3Player.getState();
}
}
@hackjutsu
hackjutsu / PlayingState.java
Created May 23, 2019
[medium snippets] #medium #designPattern #StatePattern
View PlayingState.java
public class PlayingState implements State {
public void pressPlay(MP3PlayerContext context) {
context.setState(new StandbyState());
}
@Override
public String getState() {
return "Playing...";
}
}
@hackjutsu
hackjutsu / State.java
Created May 23, 2019
[medium snippets] #medium #designPattern #StatePattern
View State.java
public interface State {
void pressPlay(MP3PlayerContext context);
String getState();
}