Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View lobster1234's full-sized avatar
🎯
Focusing

Manish Pandit lobster1234

🎯
Focusing
View GitHub Profile
@lobster1234
lobster1234 / StringUtilsFixDecimalNegative.java
Created March 25, 2011 09:52
Apache StringUtils isNumeric() fails for strings that have numbers with a period or negative value. Here is a simple fix to handle it.
String string = "-12.49";
boolean isNumeric = string!=null && string.length() > 0 && string.toUpperCase().equals(string.toLowerCase());
@lobster1234
lobster1234 / fabric_yammer.py
Created April 28, 2011 10:44
Fabric task to send build status to Yammer
import oauth2 as oauth
import urllib
def yam():
consumer_key = YOUR_CONSUMER_KEY
consumer_secret= YOUR_CONSUMER_SECRET
access_token = YOUR_ACCESS_TOKEN
access_token_secret = YOUR_ACCESS_TOKEN_SECRET
consumer = oauth.Consumer(consumer_key, consumer_secret)
token = oauth.Token(access_token,access_token_secret)
client = oauth.Client(consumer,token)
@lobster1234
lobster1234 / gist:960029
Created May 6, 2011 23:55
Add a cluster name to Elasticsearch Java TransportClient
Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name",your_cluster_name).build();
TransportClient client = new TransportClient(settings);
@lobster1234
lobster1234 / pom.xml
Created September 6, 2011 06:34
Maven pom.xml compatible with Scala 2.9.1 with updated dependency versions. This is needed because the archetype:generate for scala-archetype-simple will be 2.8 and the tests will fail with 2.9.1.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.manish</groupId>
<artifactId>scala-simple</artifactId>
<version>1.0-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>My wonderfull scala app</description>
<inceptionYear>2010</inceptionYear>
<licenses>
<license>
@lobster1234
lobster1234 / redis
Created February 16, 2012 22:44
Startup Script for Redis
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@lobster1234
lobster1234 / TrafficManager.java
Created September 17, 2012 20:35
Oauth2 Authorization with Google APIs - A quick verification script
package com.ign.traffic;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
@lobster1234
lobster1234 / PalindromeCheck.java
Last active December 14, 2015 05:39
Test for a Palindrome...
public class PalindromeCheck {
public final boolean isPalindrome(String s) {
boolean isPalindrome = true;
for (int i = 0; i < s.length(); i++) {
if (!(s.charAt(i) == s.charAt(s.length() - i - 1))) {
isPalindrome = false;
break;
}
}
@lobster1234
lobster1234 / ReverseString.scala
Last active February 21, 2018 22:37
Reverse a String - Scala
def reverseString(s:String) = (for(i<-s.length-1 to 0 by -1) yield s(i)).mkString
//Java Version here:
public class Test {
public final String reverse(String s) {
StringBuffer b = new StringBuffer(s.length());
for(int i = s.length()-1; i >=0; i--){
b.append(s.charAt(i));
@lobster1234
lobster1234 / LinkedList.java
Last active October 12, 2021 22:24
A generic, singly LinkedList Implementation
public class LinkedList<T> {
private LinkedListNode<T> first = null;
/**
* Insert at the front of the list
* @param node
*/
public void insert(LinkedListNode<T> node) {
node.setNext(first);
@lobster1234
lobster1234 / ConcurrentModificationExceptionGenerator.java
Created March 4, 2013 23:41
ConcurrentModificationException - How to get one.
public class Map {
public static void main(String[] args) {
HashMap<Integer,Long> map = new HashMap<Integer,Long>();
for(int i = 0;i<100;i++){
map.put(i,System.nanoTime());
}
Iterator<Integer> it = map.keySet().iterator();
while(it.hasNext()){
map.remove(it.next());