Skip to content

Instantly share code, notes, and snippets.

View arufian's full-sized avatar
🌏
Working from home, cafe, hotel, etc

Alfian Busyro arufian

🌏
Working from home, cafe, hotel, etc
View GitHub Profile
@arufian
arufian / CustomNSCell.m
Created September 4, 2012 05:08
Click detection on button inside NSCell
- (BOOL) trackMouse:(NSEvent *)event inRect:(NSRect)cellFrame ofView:(NSView *)controlView untilMouseUp:(BOOL)flag
{
// Check if the button was hit.
int hitType = [self hitTestForEvent:[NSApp currentEvent] inRect:cellFrame ofView:controlView];
BOOL isButtonClicked = hitType == (NSCellHitContentArea | NSCellHitTrackableArea);
if (!isButtonClicked) return YES;
// Ignore events other than mouse down.
if ([event type] != NSLeftMouseDown) return YES;
@arufian
arufian / NSApplication+SelfRelaunch.m
Created November 27, 2012 02:13 — forked from cdfmr/NSApplication+SelfRelaunch.m
Self relaunch of Cocoa application
@implementation NSApplication (Relaunch)
- (void)relaunchAfterDelay:(float)seconds
{
NSTask *task = [[[NSTask alloc] init] autorelease];
NSMutableArray *args = [NSMutableArray array];
[args addObject:@"-c"];
[args addObject:[NSString stringWithFormat:@"sleep %f; open \"%@\"", seconds, [[NSBundle mainBundle] bundlePath]]];
[task setLaunchPath:@"/bin/sh"];
[task setArguments:args];
@arufian
arufian / test.html
Created April 12, 2013 09:11
Make a colorful combobox
<select id="test">
<option id="test1">test1</option>
<option id="test2">test2</option>
<option id="test3">test3</option>
<option id="test4">test4</option>
<option id="test5">test5</option>
</select>
@arufian
arufian / OptionController.cls
Last active August 29, 2015 14:06
Assigning List of Salesforce Object Value into SelectOption
public class OptionController {
public List<CustomObject__c> ListOfItems {get;set;}
public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
for(CustomObject__c sObj: ListOfItems) {
options.add(new SelectOption(sObj.Id, sObj.Name));
}
return options;
}
@arufian
arufian / gist:77ca9bcb3e78349703a2
Last active August 29, 2015 14:06
Create a selectlist in Visualforce page
<apex:selectList value="{!item}" size="1"> <!-- must have declared it with size=1 in order to become dropdown list -->
<apex:selectOptions value="{!itemList}"/> <!-- for detail see OptionController.cls.cls file -->
</apex:selectList>
@arufian
arufian / gist:272247ffb865b4d1cac2
Created September 17, 2014 01:14
Preparation for Salesforce ADM 201 Exam
Still new to Salesforce? First read some these good workbooks : https://wiki.developerforce.com/page/Force.com_workbook
Watch some Salesforce training videos : https://www.youtube.com/playlist?list=PL6747B4DAE356E17C
This tips is also good to read :
http://agilecloudconsulting.blogspot.jp/2013/10/how-to-become-certified-salesforcecom.html
http://salesforce-certification-notes.blogspot.jp/?view=magazine
Ready to go? Take some exam questions practice :
http://bulkified.com/Certifications/?certificationId=1
http://www.abetterstudyguide.com/ABSG/
And the last read carefully the study guide : http://certification.salesforce.com/SG_CertifiedAdministrator.pdf
If you still don't have a confidence, study more.
@arufian
arufian / CreateRenewal.trigger
Created September 29, 2014 07:02
A Solution for SFDC99 Opportunity Renewal challenge
trigger CreateRenewal on Opportunity (after insert, after update) {
List<Opportunity> renewals = new List<Opportunity>();
List<Opportunity> closedOpp = Trigger.new;
RecordType renewalRecordType = [SELECT Id FROM RecordType WHERE Name LIKE '%Renewal%'];
for(Opportunity opp: closedOpp){
if(opp.IsClosed){
Opportunity newOpp = new Opportunity();
newOpp.AccountId = opp.AccountId;
newOpp.Name = opp.Name+'Renewal';
@arufian
arufian / file0.java
Last active August 29, 2015 14:07
Apexトリガー上でYQLのデータを取得する ref: http://qiita.com/arufian/items/99a5e974549422ad0235
global class YQLBridge {
@future (callout=true)
public static void searchGoogleBooks(String bookId) {
Book__c book = [SELECT Name, Id FROM Book__c WHERE Id=:bookId];
Http http = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20google.books%20WHERE%20q%3D%22'
+book.Name+
'%22%20AND%20maxResults%3D1&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&format=json');
global with sharing class CommonClass {
global List<Object> selectAllFromTable(String objectName, String whereCondition, String order, String limit1){
String query = selectAllQuery(objectName, whereCondition);
query += ' ORDER BY '+order+' LIMIT '+limit1;
try {
return database.query(query);
} catch (QueryException e){
//perform exception handling
System.debug('failed to selectAllFromTable');
@arufian
arufian / withMethod.cls
Last active August 29, 2015 14:07
Select * in SOQL using Apex Class
String table = 'TableName'; // with __c if use Custom Object
Map<String, Schema.SObjectType> m = Schema.getGlobalDescribe() ;
Schema.SObjectType s = m.get(table) ;
Schema.DescribeSObjectResult r = s.getDescribe() ;
Map<String, Schema.SObjectField> fields = r.fields.getMap() ;
string soql = '';
for (String fieldName : fields.keyset()) {
if (soql != '') {
soql += ', ';
}