Skip to content

Instantly share code, notes, and snippets.

View aruld's full-sized avatar
🎯
Focusing

Arul Dhesiaseelan aruld

🎯
Focusing
View GitHub Profile
class TheCompanyProcess {
public static String cleanUpNames(List listOfNames) {
listOfNames
.findAll {it.length() > 1}
.collect {it.capitalize()}
.join(',')
}
}
public class TheCompanyProcess {
public String cleanNames(List<String> listOfNames) {
StringBuilder result = new StringBuilder();
for(int i = 0; i < listOfNames.size(); i++) {
if (listOfNames.get(i).length() > 1) {
result.append(capitalizeString(listOfNames.get(i))).append(",");
}
}
return result.substring(0, result.length() - 1).toString();
}
val employees = List("neal", "s", "stu", "j", "rich", "bob")
val result = employees
.filter(_.length() > 1)
.map(_.capitalize)
.reduce(_ + "," + _)
@aruld
aruld / ChunkFactory
Last active December 31, 2015 21:09
Chunk factory to override default chunk size in Apache HttpClient.
import org.apache.http.Consts;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.config.ConnectionConfig;
import org.apache.http.conn.HttpConnectionFactory;
import org.apache.http.conn.ManagedHttpClientConnection;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.entity.ContentLengthStrategy;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
@aruld
aruld / customdialog.js
Last active December 21, 2015 16:49
Custom modal dialog using bootbox.js
bootbox.dialog("This message goes into modal body!",
[
{
"label": "Cancel",
"class": "btn-primary",
"callback": function () {
bootbox.hideAll();
}
},
{
@aruld
aruld / kernel_task.sh
Last active December 16, 2015 08:39
top -o cpu -pid 0 -> if kernel_task indicates heavy CPU use, you should consider applying kext changes for Mountain Lion 10.8.3 Source : “Fixing” kernel_task CPU Problems in MacOS Mountain Lion 10.8 [http://www.rdoxenham.com/?p=259]
arul:~ arul$ system_profiler -detailLevel mini | grep "Model Identifier:"
Model Identifier: MacBookPro8,3
arul:~ arul$ sh
sh-3.2$ kextstat | grep IOPlatformPluginFamily
84 5 0xffffff7f80dfa000 0xa000 0xa000 com.apple.driver.IOPlatformPluginFamily (5.3.0d51) <9 7 6 5 4 3>
sh-3.2$ sudo su -
Password:
arul:~ root# cd /System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns/ACPI_SMC_PlatformPlugin.kext/Contents/Resources/
arul:Resources root# ls
MacBook1_1.plist MacBookAir2_1.plist MacBookPro3_1.plist MacBookPro7_1.plist Macmini3_1.plist iMac11_3.plist
@aruld
aruld / Item10.java
Created March 31, 2013 22:41
Ad-hoc queries over collections (LINQ in Java) https://github.com/aruld/java-oneliners
// Print the names of albums that have at least one track rated four or higher, sorted by name.
albums.stream()
.filter(a -> a.tracks.stream().anyMatch(t -> (t.rating >= 4)))
.sorted(comparing((Album album) -> album.name))
.forEach(album -> System.out.println(album.name));
// Merge tracks from all albums
List<Track> allTracks = albums.stream()
.flatMap((Album album) -> album.tracks.stream())
.collect(toList());
students.parallelStream().forEach(student -> {
student.GradePointAverage = student.Tests.parallelStream().mapToDouble(test -> test.Grade * test.Weight).sum();
});
@aruld
aruld / install_jdk5_mtn_lion.sh
Last active December 13, 2015 18:49 — forked from bric3/install_jdk5_post_lion.sh
This is a fork from https://gist.github.com/bric3/1163008 # 2013/06/10 Tested on Mountain Lion 10.8.4 # 2013/02/14 Updated to run on Mountain Lion 10.8.2
#!/bin/bash
# This script is edited by Brice Dutheil.
# See there in french http://blog.arkey.fr/2012/07/30/script-pour-installer-le-jdk-5-sur-macosx-lion/
# Translate button is broken for now, please use Google to translate this website.
# 2013/06/10 Tested on Mountain Lion 10.8.4
# 2013/02/14 Updated to run on Mountain Lion 10.8.2
#
# 2012/08/25 This script didn't behave correctly when ran on 10.8.1
# Added recommendation to always run this script after updates such as Java, XCode, OSX, etc.
addresses.parallelStream().forEach(address -> sendMail(address));