id
stringlengths
36
36
text
stringlengths
1
1.25M
9696a751-e63f-4da4-a2c5-1844c0751211
public static void SaveFriends(List listUsers,int intUserCount,String strResponse,String strUrl) throws Exception{ File file=new File(strUrl+"\\"+listUsers.get(intUserCount).toString()+"\\friends\\getFriends.txt"); BufferedWriter output = new BufferedWriter(new FileWriter(file)); output.write(st...
c9043734-a495-45d1-b545-f42f0e59c42d
public static void SaveUsersPendingRequests(List listUsers,Map mapPendingRequestsCurr,String strUrl) throws Exception{ File file=new File(strUrl+"\\users\\getUsersPendingRequests.txt"); BufferedWriter output = new BufferedWriter(new FileWriter(file)); String strScreenName; ...
9c571406-e559-4acb-9815-cb7a32de33d1
public static void main(String[] args) throws Exception{ // TODO code application logic here consumer = new CommonsHttpOAuthConsumer(ConsumerKey,ConsumerSecret); consumer.setTokenWithSecret(AccessToken,AccessSecret); FriendFriendStdAttention(); }
2a14af33-917c-438c-9e05-f3450b15c669
public static void FriendFriendStdAttention() throws Exception { //FF //collect list of friend ids //collect tweets of friends //identify the tweets which are retweeted - R //identify the tweets which are retweeted by you - RU //initialization HttpGet request; Htt...
c3436083-0e0f-4b9e-b478-f4b2b3454001
public static void main(String[] args) throws Exception { new HelloWorldApplication().run(args); }
6360aaa4-b72e-46cb-b4df-ad1a9c9560e0
@Override public String getName() { return "hello-world"; }
60a26df8-b555-4a0e-a338-6da4400d5027
@Override public void initialize(Bootstrap<HelloWorldConfiguration> bootstrap) { // nothing to do yet }
fd55c2f5-f46d-468a-b697-91831e9ec36b
@Override public void run(HelloWorldConfiguration configuration, Environment environment) { final HelloWorldResource resource = new HelloWorldResource( configuration.getTemplate(), configuration.getDefaultName() ); final TemplateHealthChe...
861f216f-11b1-45d3-845c-07d4d11d81ea
public static void main( String[] args ) { System.out.println( "Hello World!" ); }
7fa98e3b-4994-47e6-88b2-6d3d649bc04c
@JsonProperty public String getTemplate() { return template; }
9bae6059-11c4-4d9c-b87b-9b80b0cd6c9a
@JsonProperty public void setTemplate(String template) { this.template = template; }
df1aaa12-8065-467e-a9f8-68c80598e88a
@JsonProperty public String getDefaultName() { return defaultName; }
2459d411-fefc-4779-8320-53d475a605af
@JsonProperty public void setDefaultName(String name) { this.defaultName = name; }
47c76791-bfb5-4981-b813-195cbe74930d
public TemplateHealthCheck(String template) { this.template = template; }
7a4587de-c5a9-4140-b58a-5933636d87f0
@Override protected Result check() throws Exception { final String saying = String.format(template, "TEST"); if (!saying.contains("TEST")) { return Result.unhealthy("template doesn't include a name"); } return Result.healthy(); }
ae5e059d-0438-460a-a999-a9a85bd707c0
public Saying() { // Jackson deserialization }
e2099f30-1658-43a8-bceb-2d2e0878e328
public Saying(long id, String content) { this.id = id; this.content = content; }
720fa12a-645a-4fa1-a700-d92bcc7ca2a2
@JsonProperty public long getId() { return id; }
2e96ed0a-d03c-4a12-9df3-5ff385febef7
@JsonProperty public String getContent() { return content; }
8da89d36-46ba-420b-9a26-d1d031f0c4e4
public HelloWorldResource(String template, String defaultName) { this.template = template; this.defaultName = defaultName; this.counter = new AtomicLong(); }
e5eda50d-0a7b-45d1-ab8e-4851cf120052
@GET @Timed public Saying sayHello(@QueryParam("name") Optional<String> name) { final String value = String.format(template, name.or(defaultName)); return new Saying(counter.incrementAndGet(), value); }
305c5747-0812-4a5b-94d3-76f5277d75fe
private String handleInputStream(java.nio.file.Path tmpDir, InputStream fileInputStream, String temp_upload_file_name) throws IOException, InterruptedException { LOGGER.info("HANDLING INPUT FILE: {}", temp_upload_file_name); java.nio.file.Path outputPath = Paths.get(tmpDir.toAbsolutePath().toString(), ...
23fd6493-e440-46a7-815e-df6e987aa6cb
private void importFileToPostGISshp2pgsql(String fileWeSaved) throws IOException, InterruptedException { // now build up the ogr2ogr command // ogr2ogr -f "PostgreSQL" PG:"host=yourhost user=youruser dbname=yourdb // password=yourpass" inputfilename.kml List<...
1f7206de-dffb-4b61-9daa-9da785bf3eba
private void importFileToPostGISogr2ogr(String fileWeSaved) throws IOException, InterruptedException { // now build up the ogr2ogr command // ogr2ogr -f "PostgreSQL" PG:"host=yourhost user=youruser dbname=yourdb // password=yourpass" inputfilename.kml List<St...
a193982f-f0cb-4392-b010-7e238be12204
@POST @Consumes(MediaType.MULTIPART_FORM_DATA) public Response uploadFile( FormDataMultiPart multiPart) throws IOException, InterruptedException { List<FormDataBodyPart> fields = multiPart.getFields("file"); List<String> filesWeCanImport = new ArrayList<>(); // create one ...
3bbc73ea-718e-4895-b091-5cb40a2b2ef4
public AppTest( String testName ) { super( testName ); }
f2ea58de-9129-46c1-bd62-e70aa1d1b842
public static Test suite() { return new TestSuite( AppTest.class ); }
ae89fbc6-aba6-4997-9713-71fc26a5753f
public void testApp() { assertTrue( true ); }
98b6434a-7135-4c92-901b-b6064c8d1f59
public static void main(String[] args) { int lower = 1; int upper = 20; long candidate = 1; // start with the product of the divisors as an upper bound for the answer for (int i = lower; i <= upper; i++) { candidate *= i; } // "pare down" the answer ...
547959f3-76ff-4028-abd4-ea1e59bf3d2e
private static boolean isDivisible(long n, int lower, int upper) { for (int i = lower; i <= upper; i++) { if (n % i != 0) { return false; } } return true; }
70981ffa-183a-4a8d-9e60-4d942aef1ad5
public static void main(String[] args) { explicit(); stream(); }
de2b1448-1829-4962-9c4e-1fe8a5bcc420
private static void explicit() { int sumOfSquares = 0; int squareOfSums = 0; for (int i = 1; i <= 100; i++) { sumOfSquares += i * i; squareOfSums += i; } squareOfSums *= squareOfSums; System.out.println(squareOfSums - sumOfSquares); }
8f50e8e9-8458-4e41-80a1-6bc0bf62e018
private static void stream() { int sumOfSquares = IntStream.rangeClosed(1, 100).map(i -> i * i).sum(); int sum = IntStream.rangeClosed(1, 100).sum(); int squareOfSums = sum * sum; System.out.println(squareOfSums - sumOfSquares); }
26721cfd-6b21-44f2-b117-f9a08a757085
public static void main(String[] args) { int result = IntStream.iterate(2, i -> i + 1).filter(Problem7::isPrime).skip(10000).findFirst().orElse(-1); System.out.println("result = " + result); }
c953415d-549e-4e23-a68a-cc19a62bab06
private static boolean isPrime(int n) { return IntStream.rangeClosed(2, (int) Math.sqrt(n)).noneMatch(i -> n % i == 0); }
36e7fe13-e499-4ddc-8c9e-cee91cef60e4
public static void main(String[] args) { int max = 4000000; int a = 1; int b = 2; int sum = 0; // only every third Fibonacci number is even, so we can compress the // math and iterate three times faster than a naive algorithm. while (b < max) { sum +...
598931c5-c26d-4b70-a77a-ab20d36674cd
public static void main(String[] args) { long n = 600851475143l; // without a list of primes, it's easier to just try dividing n with all // integers, including composites for (int i = 2; i < n; i++) { while (n % i == 0) { n /= i; } } ...
fb004fa5-c8cf-4249-8835-cbbc537b1837
public static void main(String[] args) { int digits = 3; int ubound = (int) (Math.pow(10, digits) - 1); // e.g. 999 int lbound = (int) Math.pow(10, digits - 1); // e.g. 100 int largest = 0; // impossible for a power of 10 to be a factor of a palindromic number for (int a...
238a2b5a-96ed-42d8-9c29-552f2209216d
private static boolean isPalindromic(int n) { int digits = (int) Math.log10(n) + 1; // digits are 1-indexed, where digit 1 is the least significant for (int i = 1; i <= digits / 2; i++) { if (ithDigit(n, i) != ithDigit(n, digits - i + 1)) { return false; ...
9844518b-5d75-47ec-aaed-1d8ab9e40562
private static int ithDigit(int n, int i) { n /= Math.pow(10, i - 1); return n - n / 10 * 10; }
1c201267-6283-4366-bf5f-5ca2d44866e0
public static void main(String[] args) { int max = 1000; int threes = 3 * triangularNum(max / 3); int fives = 5 * triangularNum(max / 5); int fifteens = 15 * triangularNum(max / 15); // trivial application of principle of inclusion/exclusion System.out.println(threes + ...
a34a36d9-1d48-4215-acda-d4ad37266b7f
private static int triangularNum(int n) { // returns the sum of integers between 1 and n, inclusive return n * (n + 1) / 2; }
a2b498ab-f6a2-4bcc-bd8c-4f4628976ee8
public static void main(String[] args) { for (int a = 0; a <= 1000; a++) { for (int b = a + 1; b <= 1000; b++) { for (int c = b + 1; c <= 1000; c++) { if (a * a + b * b == c * c && a + b + c == 1000) { System.out.println("a * b * c = " + a ...
af3d26df-bb4d-4d02-bc41-9323b0161740
public static void main(String[] args){ System.out.println("Hi"); }
74b68241-0f64-40ee-8213-22f0682eb4d9
public static void main(String[] args) { UserDetails user = new UserDetails(); //create address object Address address = new Address("7314 Powhatan St", "Lanham", 20708, "MD"); //now create a Vehicle object here... Vehicle vehicle = new Vehicle(); vehicle.setVehicleName("Toyota DX"); CellPhone cell1 = ...
ef593198-2b3a-4cb1-9ffb-89cf2bfdb946
public UserDetails() { }
d4446447-b2b4-43e7-96a1-c50802838778
public int getUserId() { return userId; }
6a54ddfa-5507-4988-9c4c-1e9b72e971d6
public void setUserId(int userId) { this.userId = userId; }
0d60c3c9-3d5c-41ac-a1be-e44f7d769800
public String getUserName() { return userName; }
e1cf6e8a-6944-4ec2-b865-572a8f55d452
public void setUserName(String userName) { this.userName = userName; }
eec5f575-a022-4cee-b004-a4325e136fbb
public Date getJoinedDate() { return joinedDate; }
504dacdc-c381-4108-ac63-1a94fdb5eb40
public void setJoinedDate(Date joinedDate) { this.joinedDate = joinedDate; }
4d80ac7d-36d7-4108-a358-f7b62b07ce8a
public Address getAddress() { return address; }
98ed0118-f0c5-4865-a656-11f983741d78
public void setAddress(Address address) { this.address = address; }
31fbaff5-f1f2-4b91-88fc-663c8281643e
public String getDescription() { return description; }
d18d4730-60dc-4489-b34b-124053c14a81
public void setDescription(String description) { this.description = description; }
421c6ac1-0127-491b-b20a-f2fd2c32b9df
public Vehicle getVehicle() { return vehicle; }
2cad1efb-2e00-4e9a-ae39-175ae9150beb
public void setVehicle(Vehicle vehicle) { this.vehicle = vehicle; }
3130e46f-0876-48ff-8777-5727e48846e4
public Collection<CellPhone> getCellPhoneCollection() { return cellPhoneCollection; }
5ebc9890-01b8-4c75-a905-10fec8c723ae
public void setCellPhoneCollection(Collection<CellPhone> cellPhoneCollection) { this.cellPhoneCollection = cellPhoneCollection; }
357d6413-ec8a-44c2-9c42-70ac7a965c73
public CellPhone() { }
187c1b72-8023-4b57-9676-a00cf67f4ff0
public int getCellPhoneId() { return cellPhoneId; }
9cd1f371-a5f5-43f0-81bc-24d5a8f6bd29
public void setCellPhoneId(int cellPhoneId) { this.cellPhoneId = cellPhoneId; }
53208b1d-1986-4a8a-b634-2acf8d361c86
public String getCellPhoneNumber() { return cellPhoneNumber; }
acbf1348-f507-4e5c-90e5-daafe83f9715
public void setCellPhoneNumber(String cellPhoneNumber) { this.cellPhoneNumber = cellPhoneNumber; }
729fc41a-c244-4ea9-82b4-3ff853fd76e0
public UserDetails getUserDetail() { return userDetail; }
bbc969b6-5be1-41b7-8c40-5a086d9c2a74
public void setUserDetail(UserDetails userDetail) { this.userDetail = userDetail; }
4eb7bfde-469a-4d3b-a3f5-fe60b6e12a02
public int getVehicleId() { return vehicleId; }
4e3cb531-1f30-449e-989c-ea10b7f77761
public void setVehicleId(int vehicleId) { this.vehicleId = vehicleId; }
9c1303a0-f2f8-4ae7-aa30-a62ae8514bb1
public String getVehicleName() { return vehicleName; }
c4b0ecd5-4b01-4631-a549-9dffcdfd1c09
public void setVehicleName(String vehicleName) { this.vehicleName = vehicleName; }
ac13b16e-f753-4f8d-b9ce-e2d463a346a5
public Address() { super(); }
278c22ba-1253-4018-9719-29c32d55eb02
public Address(String street, String city, int zipCode, String state) { super(); this.street = street; this.city = city; this.zipCode = zipCode; this.state = state; }
7ebb339e-f482-48ae-9a51-0fcbb18d93a8
public String getState() { return state; }
b7b604b4-4166-4d9b-9e01-669db2b2f531
public void setState(String state) { this.state = state; }
6bd955e0-ee23-4176-9269-078c3e956e0f
public String getStreet() { return street; }
19b0ad10-54c7-43cb-abc8-0c66a669bb55
public void setStreet(String street) { this.street = street; }
31ae1896-b28b-4384-9524-6df709d28aa0
public String getCity() { return city; }
b897c6e1-ff5b-457b-b2d7-5ee1f0149ccb
public void setCity(String city) { this.city = city; }
49235d88-e276-4979-ac3e-b79a094a9669
public int getZipCode() { return zipCode; }
6cd84670-c9fd-4ca7-9147-b51a20c9ecbf
public void setZipCode(int zipCode) { this.zipCode = zipCode; }
279d44a3-81c5-4857-8180-ddf7612c3586
private static void printHelp() { System.out .println("java -jar tp2.java <input-file> <output-file> <algorithm (1,2,3)>"); System.out.println("1 - Dynamic, 2 - Greedy, 3 - Backtracking"); }
a28e8b0c-5960-43f1-8d7c-c48654bf23d2
public static void main(String[] args) throws FileNotFoundException { if (args.length != 3) { printHelp(); return; } final String fileIn = args[0]; final String fileOut = args[1]; final int algorithm = Integer.valueOf(args[2]); Reader reader = new...
acffc89b-d54a-4e34-90ac-fd0d7f9be4cd
private static void printSolution(TwoCitiesSolution tcs, PrintWriter w) { w.println(Start.join(tcs.getA(), ",")); w.println(Start.join(tcs.getB(), ",")); w.println(tcs.getSumFromSet(tcs.getA())); w.println(tcs.getSumFromSet(tcs.getB())); w.close(); }
f7e3bd75-7a6b-49d2-94a8-ab7bbec7ba82
public static String join(SortedSet set, String sep) { String result = null; if(set != null) { StringBuilder sb = new StringBuilder(); Iterator it = set.iterator(); if(it.hasNext()) { sb.append(it.next().toString()); } while(it....
5a80db15-d202-4a46-8b16-ff8f69e78155
private static TwoCitiesSolution solve(int algorithm, DistanceMatrix dm) { OsDoisViajantes odv = null; switch(algorithm) { case 1: odv = new Dynamic(); break; case 2: odv = new Greedy(); break; default: ...
d2bd431c-9875-4379-acb0-32d886df247b
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + id; return result; }
09416c7e-8c36-4391-ac6b-0ccd1828992c
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; City other = (City) obj; if (id != other.id) return false; return true; }
a9f71ffe-ae1a-4a99-a1cd-f8baefbdc750
public City(int id) { this.id = id; }
0290c9b9-6f8f-4617-acaf-1e8dfbb49942
public int getId() { return id; }
0000b257-6029-4f49-a9d7-398e0cdc706d
public void setId(int id) { this.id = id; }
6f82fa5d-805c-498c-a36c-d1ce41db21da
@Override public int compareTo(City o) { return new Integer(this.getId()).compareTo(o.getId()); }
5efd0f73-b476-49c3-832b-ba9bdc5c0d36
@Override public String toString() { return ((Integer)this.getId()).toString(); }
3a9762a3-f067-45b7-ba73-78c49a6466f9
public DistanceMatrix(List<City> cities, double[][] distanceMatrix) { this.cities = new ArrayList<City>(cities); this.distanceMatrix = distanceMatrix.clone(); }
bf72827e-2b8e-40ee-a4f8-f0f4ce874306
private boolean checkValidId(City city) { return city.getId() >= 0 && city.getId() < distanceMatrix.length; }
a4223129-fe59-4eac-884c-0b2a7788ad4e
public double getDistance(City a, City b) { if (checkValidId(a) && checkValidId(b)) { return this.distanceMatrix[a.getId()][b.getId()]; } return -1; }
a9cbb2b5-c278-4af2-a9c4-03ccddccdf73
public List<City> getCities() { return cities; }
9cbaa631-cffc-446e-9939-bc7ee0288f28
public void setCities(List<City> cities) { this.cities = cities; }
aaec4271-40e4-46df-ae21-ea8579dd7372
public double[][] getDistanceMatrix() { return distanceMatrix; }
fe76661a-d36f-4706-8aee-e01f808c8232
public void setDistanceMatrix(double[][] distanceMatrix) { this.distanceMatrix = distanceMatrix; }