{{ message }}

Instantly share code, notes, and snippets.

# CosmoX hackjutsu

Last active Jun 26, 2021
[word cloud generator] github: https://github.com/amueller/word_cloud, instructions: http://amueller.github.io/word_cloud/index.html
View kickstart.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # installation: pip3 install wordcloud wordcloud_cli --text mytext.txt --imagefile wordcloud.png
Created May 31, 2021
[GraphQL test]
View test.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 query { resolution { .... #define section-info section { name uniqueName href parameters { key
Created Jun 20, 2020
[Guava Retryer] Snippet for retrying by Guava Retryer https://github.com/rholder/guava-retrying
View retryer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 Callable callable = new Callable() { public Boolean call() throws Exception { return true; // do something useful here } }; Retryer retryer = RetryerBuilder.newBuilder() .retryIfResult(Predicates.isNull()) .retryIfExceptionOfType(IOException.class) .retryIfRuntimeException()
Created Jun 6, 2020
[test scirpt for batch]
View test.bat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 @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"
Created Jun 6, 2020
[my zsh configurations] #zsh
View .zshrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # 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
Created Oct 2, 2019 — forked from chitchcock/20111011_SteveYeggeGooglePlatformRant.md

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

Created Aug 10, 2019
Two Pointer - Container with Most Water
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.

Created May 23, 2019
[medium snippets] #medium #designPattern #StatePattern
View ClientDemo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 public class ClientDemo { public static void main(String[] args) { MP3PlayerContext mp3Player = new MP3PlayerContext(); mp3Player.press(); mp3Player.getState(); mp3Player.press(); mp3Player.getState(); } }
Created May 23, 2019
[medium snippets] #medium #designPattern #StatePattern
View PlayingState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 public class PlayingState implements State { public void pressPlay(MP3PlayerContext context) { context.setState(new StandbyState()); } @Override public String getState() { return "Playing..."; } }
Created May 23, 2019
[medium snippets] #medium #designPattern #StatePattern
View State.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 public interface State { void pressPlay(MP3PlayerContext context); String getState(); }