Skip to content

Instantly share code, notes, and snippets.

View galak-fyyar's full-sized avatar
🍊

Anatoliy Sokolenko galak-fyyar

🍊
View GitHub Profile
@galak-fyyar
galak-fyyar / Throwable.java
Created July 29, 2012 14:35
Coherence PortableException
public class Throwable implements Serializable {
//...
public Throwable() {
fillInStackTrace();
}
//...
@galak-fyyar
galak-fyyar / gist:1994348
Created March 7, 2012 16:53
Receive real memory usage per process in Linux
PIDS=`ps auxh | awk '{print $2}'`; for pid in $PIDS; do mem=`pmap -d $pid | tail -n 1 | awk '{print $4}'`; echo "$pid $mem"; done
@galak-fyyar
galak-fyyar / stackDump.sh
Created November 16, 2011 19:41
Continiusly receiving stack trace dumps
#!/bin/bash
JAVA_PROCESS_ID=$1
LABEL=$2
if [[ -z "$JAVA_PROCESS_ID" ]]
then
echo >&2 "No Java process specified"
exit 1
fi
@galak-fyyar
galak-fyyar / checkout
Created October 19, 2011 12:49
Conflicts in Git
git checkout -b experiment
@galak-fyyar
galak-fyyar / A_Correct.java
Created October 19, 2011 12:24
Working with exceptions in Java
public String getUnreadMessages() {
List<Message> messages = service.getMessage().getUnreadMessage();
String result = convert( messages );
markMessagesUpdated( messages );
return result;
}
@galak-fyyar
galak-fyyar / gist:1298123
Created October 19, 2011 12:15
Platform dependent settings in Spring
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="nullValue" value="null"/>
<property name="ignoreResourceNotFound" value="true"/>
<property name="locations">
<list>
<value>classpath:/application.properties
<value>classpath:/application-#{ systemEnvironment[ 'SUPER_APP_ENV' ] }.properties
</list>
</property>
</bean>
@galak-fyyar
galak-fyyar / gist:1298111
Created October 19, 2011 12:07
GWT asynchromious load
GWT.runAsync( new RunAsyncCallback() {
public void onFailure( Throwable caught ) {
Window.alert( "Code download failed" );
}
public void onSuccess() {
Window.alert( "Hello, async callback" );
}
} );
@galak-fyyar
galak-fyyar / DateService.java
Created October 19, 2011 11:33
GWT and Spring Framework 3.0 integration
import java.util.Date;
public interface DateService {
Date getCurrentTime();
}
@galak-fyyar
galak-fyyar / ServiceFactoryImpl_Buggy.java
Created October 19, 2011 11:24
Wrong way to synchronize factory method
public class ServiceFactoryImpl_Buggy<T extends Service> {
protected Map<String, T> serviceMap = new HashMap<String, T>();
public T getService( String name ) {
T result = serviceMap.get( name );
if ( null == result ) {
synchronized ( this ) {
result = createService( name );
serviceMap.put( name, result );
@galak-fyyar
galak-fyyar / opends.ldif
Created October 19, 2011 09:39
Managing schemas of LDAP servers
dn: cn=schema
changetype: modify
add: objectClasses
objectClasses: ( 1.3.6.1.4.1.26037.1.999.2000
NAME ( 'blogger' )
DESC 'Someone who has a blog'
SUP inetOrgPerson
STRUCTURAL
MAY blog
X-ORIGIN 'OpenDS Directory Server'