Skip to content

Instantly share code, notes, and snippets.

View cbweixin's full-sized avatar
🏠
Working from home

凌虚御风 cbweixin

🏠
Working from home
View GitHub Profile
@cbweixin
cbweixin / SimpleHttpClient.java
Created July 24, 2015 16:09
by using org.apache.httpclient, how you could accept all certification, it is dangerous, but good for testing purpose.
package com.intuit.sb.dispatcher;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
@cbweixin
cbweixin / DispatcherLib.java
Created July 24, 2015 16:16
how to use jax-rs rest client to accept all certifications. the way is different from the way which used by org.apache.httpclient
package com.intuit.sb.dispatcher;
import com.intuit.qbn.util.ids.CompanyId;
import com.intuit.sb.dispatcher.common.domain.CompanyShardVHost;
import com.intuit.sb.dispatcher.common.error.ServiceErrorBean;
import com.intuit.sb.dispatcher.error.ServiceException;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@cbweixin
cbweixin / aws_delete_volume
Created August 13, 2015 17:02
aws remove all in-active volumes
#!/bin/bash
ids=$(aws ec2 describe-volumes --output=json --query 'Volumes[?State!=`in-use`].VolumeId')
arr=()
read -a arr <<< $(echo "$ids"| jq '.[]')
for id in "${arr[@]}"; do
#remove the suffix double quotes
id="${id%\"}"
#remove the prefix double quotes
@cbweixin
cbweixin / gist:8050204
Created December 20, 2013 03:54
uva 699
#include<iostream>
#include<cstring>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
bool used[1000000];
int a[1000000];
Comparator<List<Integer>> cp = new Comparator<List<Integer>>(){
public int compare(List<Integer> l1 , List<Integer> l2){
return l1.size()-l2.size();
}
} ;
Collections.sort(res,cp);
//With JDK 8 the syntax is much simpler.
List<CustomObject> list = new ArrayList<CustomObject>();
package beginnersbook.com;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.Set;
import java.util.Iterator;
public class Details {
package beginnersbook.com;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@cbweixin
cbweixin / Populating.java
Created December 22, 2016 05:12
population next point II
TreeLinkNode leftMost = root;
while(leftMost!=null){
TreeLinkNode p = leftMost;
while(p!=null && p.left==null && p.right==null){
p = p.next;
}
if(p==null){
return;
}
leftMost = p.left!=null ? p.left : p.right;
"ScalaTest-run-running-GenTest" #1 prio=5 os_prio=31 tid=0x00007f85f780f000 nid=0xe03 waiting on condition [0x0000700004d5d000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x0000000719c7e4e8> (a java.util.concurrent.FutureTask)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:429)
at java.util.concurrent.FutureTask.get(FutureTask.java:191)
at fpinscala.chapt7.Par$.$anonfun$map2$1(Par.scala:97)
at fpinscala.chapt7.Par$$$Lambda$216/875016237.apply(Unknown Source)
at fpinscala.chapt7.Par$.$anonfun$map2$1(Par.scala:95)
"ScalaTest-run-running-GenTest" #1 prio=5 os_prio=31 tid=0x00007f85f780f000 nid=0xe03 waiting on condition [0x0000700004d5d000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x0000000719c7e4e8> (a java.util.concurrent.FutureTask)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:429)
at java.util.concurrent.FutureTask.get(FutureTask.java:191)
at fpinscala.chapt7.Par$.$anonfun$map2$1(Par.scala:97)
at fpinscala.chapt7.Par$$$Lambda$216/875016237.apply(Unknown Source)
at fpinscala.chapt7.Par$.$anonfun$map2$1(Par.scala:95)