Skip to content

Instantly share code, notes, and snippets.

Avatar

Mohamad Purbo mpurbo

View GitHub Profile
View StompInboundChannelInterceptor.java
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
import org.springframework.messaging.support.ChannelInterceptorAdapter;
public class StompInboundChannelInterceptor extends ChannelInterceptorAdapter {
static final Log LOG = LogFactory.getLog(StompInboundChannelInterceptor.class);
@mpurbo
mpurbo / android-aar-maven-local.sh
Last active Jun 14, 2019
Installing Facebook SDK as aar to local maven repository
View android-aar-maven-local.sh
export ANDROID_HOME=/Applications/Android\ Studio.app/sdk/
cd facebook-android-sdk-3.14
gradle facebook:build
mv facebook/build/libs/facebook.aar facebook/build/libs/facebook-3.14.aar
mvn install:install-file -Dfile=facebook/build/libs/facebook-3.14.aar -DgroupId=com.facebook -DartifactId=android-sdk -Dversion=3.14 -Dpackaging=aar
View CustomFtpServer.py
__author__ = 'purbo'
import os
import time
import threading
import urllib
import re
import logging
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
@mpurbo
mpurbo / create_framework_ws.sh
Created Aug 30, 2013
XCode .framework build script for xcworkspace based projects (works for CocoaPods projects as well).
View create_framework_ws.sh
# adapted from following sources:
# https://github.com/jverkoey/iOS-Framework
# http://codefriend.blogspot.jp/2011/09/creating-ios-framework-with-xcode4.html
# http://www.cocoanetics.com/2010/04/making-your-own-iphone-frameworks/
# "No architecture.." error resolved by trying some of these:
# http://stackoverflow.com/questions/6151549/how-can-i-build-a-specific-architecture-using-xcodebuild
set -e
set +u
@mpurbo
mpurbo / create_framework_prj.sh
Created Aug 30, 2013
XCode .framework build script for xcodeproj based projects.
View create_framework_prj.sh
# adapted from following sources:
# https://github.com/jverkoey/iOS-Framework
# http://codefriend.blogspot.jp/2011/09/creating-ios-framework-with-xcode4.html
# http://www.cocoanetics.com/2010/04/making-your-own-iphone-frameworks/
# "No architecture.." error resolved by trying some of these:
# http://stackoverflow.com/questions/6151549/how-can-i-build-a-specific-architecture-using-xcodebuild
set -e
set +u
@mpurbo
mpurbo / gist:5132544
Created Mar 11, 2013
Integer bits of double/float
View gist:5132544
#include <stdint.h>
uint64_t doubleToBits(double x) {
const union { double f; uint64_t i; } xUnion = { .f = x };
return xUnion.i;
}
uint32_t floatToBits(float x) {
const union { float f; uint32_t i; } xUnion = { .f = x };
return xUnion.i;
@mpurbo
mpurbo / gist:5131291
Created Mar 11, 2013
GCD for static array of objects.
View gist:5131291
static NSArray *objectRegistry;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
objectRegistry = [[NSArray alloc] initWithObjects:obj1, obj2, nil];
});
return objectRegistry[index];
@mpurbo
mpurbo / gist:5104750
Created Mar 7, 2013
Disable horizontal auto-rotation on iOS >= 6.0
View gist:5104750
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
@mpurbo
mpurbo / gist:5087295
Created Mar 5, 2013
Generic methods for fetching rows from table using Core Data.
View gist:5087295
- (NSArray *)fetchRecordsForEntity:(NSString *)entityName
{
return [self fetchRecordsForEntity:entityName orderBy:nil];
}
- (NSArray *)fetchRecordsForEntity:(NSString *)entityName orderBy:(NSString *)column
{
NSError *error = nil;
NSManagedObjectContext *managedObjectContext = [self managedObjectContext];
@mpurbo
mpurbo / gist:1875511
Created Feb 21, 2012
geomon-client-ios: ユーザーの登録(非同期のリクエスト)
View gist:1875511
/**
* 非同期的にユーザーを登録する。
*/
- (void)registerUserUsingClient:(MMGClient *)client
{
[client registerUserWithId:@"baabaa"
name:@"Baa Baa Black Sheep"
email:@"baabaa@blacksheep.com"
password:@"moomoo"
delegate:self];