Skip to content

Instantly share code, notes, and snippets.

View cnhappier's full-sized avatar

Rollin cnhappier

  • Guangzhou, China
View GitHub Profile
@cnhappier
cnhappier / .gitignore
Created September 2, 2015 11:46
My git ignore file for java
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@cnhappier
cnhappier / SeleniumUtil.java
Created July 24, 2015 02:18
Setup proxy in selenium chrome web driver
DesiredCapabilities cap = DesiredCapabilities.chrome();
Proxy proxy = new Proxy();
proxy.setHttpProxy(httpProxy).setSslProxy(httpProxy);
cap.setCapability(CapabilityType.PROXY, proxy);
ChromeDriver driver = new ChromeDriver(cap);
@cnhappier
cnhappier / gist:0f5e35c2ade7b321b4bc
Created May 8, 2015 09:53
Ubuntu下Jenkins如何配置ChromeWebDriver
1)首先安装必要的字体和xvfb
apt-get install xvfb gtk2-engines-pixbuf xfonts-base xfonts-75dpi xfonts-100dpi xfonts-scalable xfonts-cyrillic x11-apps imagemagick
2)安装firefox作为测试xvfb的安装是否生效
sudo apt-get install firefox
Xvfb -ac :99 -screen 0 1280x1024x16
export DISPLAY=:99
firefox http://ralf.schaeftlein.com
xwd -root -display :99 | convert xwd:- capture.png
@cnhappier
cnhappier / gist:3331fd7340771de8f806
Created March 16, 2015 08:31
spring Resttemplate support gzip
HttpClient httpClient = HttpClientBuilder.create().build();
ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
RestTemplate restTemplate = new RestTemplate(requestFactory);
HttpClient is from apache http.
http://docs.spring.io/spring/docs/current/spring-framework-reference/html/remoting.html#rest-client-access
@cnhappier
cnhappier / gist:d783922dd208f60fd974
Created January 14, 2015 07:02
Disable Save As dialog in Selenium ChromeDriver
public static WebDriver createWebDriver(String localPath)
{
System.setProperty("webdriver.chrome.driver", "D:/devtools/webdriver/2.13/chromedriver.exe");
Map<String, String> prefs = new Hashtable<>();
prefs.put("download.prompt_for_download", "false");
prefs.put("download.default_directory", localPath);
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);