Skip to main content

Posts

Showing posts from May, 2016

Kiva - microfinancing to people

Kiva is a nonprofit organization that leverages a network of microfinance institutions on five continents in order to provide microfinancing to people who do not have access to traditional banking systems. Since Kiva’s launch in 2005, the total amount lent through Kiva is $718,839,975, the repayment rate is 98.71%, and the average loan size is $415.86.kiva.org

Open Exchange Rates provides real-time and historical (back to 1999) rates for about 165 world currencies

The data is collected from various sources then combined, normalized, and converted to JSON format which can be retrieved using the Open Exchange Rates API. The API is free to use for personal use and there are paid plans for developers that would like to use the API for commercial projects.API Documentation URLhttps://openexchangerates.org/documentation

Stripe, a leading digital payment solutions provider

Stripe publicly launched in September 2011 and initially served customers in the United States. Since the launch, Stripe has expanded its digital payment services to 20 countries including Australia, Canada, Denmark, Finland, Ireland, and the United Kingdom. According to a recent Bloomberg Business article, Stripe has formed several key partnerships with companies including Apple, China-based Alibaba, and Twitter. Stripe is now integrated with Apple Pay, has added support for Alipay to Stripe Checkout, and provides digital payments services for Twitter. In addition, Stripe and Braintree (owned by PayPal), will be handling the payments for Pinterest’s newly launched Buy Button feature.

Google Blogger API Example

// Get the stored credentials using the Authorization Flow
AuthorizationCodeFlow authFlow = initializeFlow();
Credential credential = authFlow.loadCredential(getUserId(req));
// Build the Plus object using the credentials

Blogger blogger =newBlogger.Builder(Utils.HTTP_TRANSPORT, Utils.JSON_FACTORY, credential).setApplicationName("").build();


// Make the API call
com.google.api.services.blogger.model.Blog blog = blogger.blogs().getByUrl("http://it.i88.ca").execute();

resp.setContentType("text/html");
resp.setStatus(200);
Writer writer = resp.getWriter();
writer.append( blog.getDescription());
writer.close();

Alpine Linux is a security-oriented, lightweight Linux distribution

 Alpine Linux is based on musl libc and busybox.
Alpine Linux is an independent stripped down flavour of Linux that’s based on musl libc (pronounce ‘muscle’) and busybox. Apart from being lightweight, it’s also security oriented and uses grsec/Pax which is a security enhancement to the Linux kernel. Simply having less packages and utilities that are otherwise added by default in other distributions also adds to its security.

In addition, Alpine uses its own package manager called apk which is fast and pretty straightforward to use. And Another cool perk is its run-from-RAM feature.

HtmlCleaner - an open-source HTML parser written in Java

HTML found on Web is usually dirty, ill-formed and unsuitable for further processing. For any serious consumption of such documents, it is necessary to first clean up the mess and bring the order to tags, attributes and ordinary text. For the given HTML document, HtmlCleaner reorders individual elements and produces well-formed XML. By default, it follows similar rules that the most of web browsers use in order to create Document Object Model. However, user may provide custom tag and rule set for tag filtering and balancing.

Features Summary
HtmlCleaner parses input HTML and generates tree-structure suitable for programmatic manipulation.Serializers are responsible for outputting the DOM structure to XML, HTML, DOM or JDom.Parsing phase relies on tag descriptions which can be customized by the user.HtmlClaner's behaviour can be configured through number of parameters.HtmlClaner is thread safe, meaning that single instance can clean multiple html sources at the same time.HtmlClaner c…

Difference between a tag and a branch in Git

A tag represents a version of a particular branch at a moment in time. A branch represents a separate thread of development that may run concurrently with other development efforts on the same code base. Changes to a branch may eventually be merged back into another branch to unify them.

You tag a particular version so that you can recreate it, e.g., this is the version we deploy to server #1, that is another version we deploy to server #2. A branch is more of a strategy to provide on-going updates on a particular version of the code while continuing to do development on it. You'll make a branch of the delivered version, continue development on the main line, but make bug fixes to the branch that represents the delivered version. Eventually, you'll merge these bug fixes back into the main line.

It is common to mix both branching and tagging. You'll have various tags that may apply to different branches. You can't however have same tag name across different branches.

From 

How to get the parameters of a running JVM

jps -lvm
jps - Java Virtual Machine Process Status Tool

-qSuppress the output of the class name, JAR file name, and arguments passed to the main method, producing only a list of local VM identifiers.-mOutput the arguments passed to the main method. The output may be null for embedded JVMs.-lOutput the full package name for the application's main class or the full path name to the application's JAR file.-vOutput the arguments passed to the JVM.-VOutput the arguments passed to the JVM through the flags file (the .hotspotrc file or the file specified by the -XX:Flags=<filename> argument).

How to analyze Java Thread dump

How to solve Disk Full problem of servers

There are 2 scenarios when disk full happens in servers. One is running out of disk space, another is exceeding the limits of inode.

For the 1st case, to produce a list of all the folders in /path/to/folder and their sizes

du -cks * | sort -rn | head$ du -h --max-depth=1 /path/to/folderTo sort it
$ sudo du --max-depth=1 / | sort -nrTo find files larger than certain size:
$ sudo find / -type f -size +100MTo exclude some folders, for example, not to find in folder "/backup" and "/mnt"

$ sudo find / -type f -not -path "/backup/*" -not -path "/mnt/*" -size +50M$ sudo ls -lh `sudo find / -type f -size +100M`$ sudo du -h / -d 1 --exclude=/backup --exclude=/mnt See also:
How to find the largest file in a directory and its subdirectories using the find commandIf it is the 2nd case. first find out which partition is running out of inodes:

$ df -hiFilesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda1 88.8G 88.8G 0 100% …

How to register and un-register an MXBean

After you register an MXBean, you can start the jconsole or jmc etc and query the exposed MXBean for the values it contains.
staticpublicObjectName register(String serviceName, String nameName, Object theMbean) {
finalMBeanServer mbs =ManagementFactory.getPlatformMBeanServer();
ObjectName name = getMBeanName(serviceName, nameName);
if (name !=null) {
try {
mbs.registerMBean(theMbean, name);
LOG.debug("Registered "+ name);
return name;
} catch (InstanceAlreadyExistsException iaee) {
if (LOG.isTraceEnabled()) {
LOG.trace("Failed to register MBean \""+ name +"\"", iaee);
} else {
LOG.warn("Failed to register MBean \""+ name +"\": Instance already exists.");
}
} catch (Exception e) {
LOG.warn("Failed to register MBean \""+ name +"\"", e);
}
}
returnnull;
}
staticpublicvoid unregister(ObjectName mbeanName) {
LOG.debug("Unregistering "+ mbea…

JConsole - a monitoring tool that complies to the Java Management Extensions (JMX) specification

The JConsole graphical user interface uses the extensive instrumentation of the Java Virtual Machine (Java VM) to provide information about the performance and resource consumption of applications running on the Java platform.

You start JConsole by typing the following command at the command line.

% jconsole
Once you have connected JConsole to an application, JConsole is composed of six tabs.
Overview: Displays overview information about the Java VM and monitored values.Memory: Displays information about memory use.Threads: Displays information about thread use.Classes: Displays information about class loading.VM: Displays information about the Java VM.MBeans: Displays information about MBeans.

Blogger variables examples

/* Variable definitions
====================
<Variablename="keycolor"description="Main Color"type="color"default="#ffffff"/>
<Groupdescription="Page"selector="body">
<Variablename="body.font"description="Font"type="font"
default="normal normal 13px Arial, Tahoma, Helvetica, FreeSans, sans-serif"/>
<Variablename="body.background.color"description="Background Color"type="color"default="#000000"/>
<Variablename="body.text.color"description="Text Color"type="color"default="#ffffff"/>
</Group>
<Groupdescription="Links"selector=".main-inner">
<Variablename="link.color"description="Link Color"type="color"default="#888888"/>
<Variablename="link.visited.color"description="Visited Color"type="co…