Skip to content

Instantly share code, notes, and snippets.

View nithesh1992's full-sized avatar

Nithesh Nekkanti nithesh1992

View GitHub Profile
@nithesh1992
nithesh1992 / Main.java
Created August 21, 2016 23:30
Decimal Compliment (Binary)
import java.util.ArrayList;
import java.util.Scanner;
/**
* Created by Nithesh on 8/9/2016.
* Get an Integer Compliment.
*/
public class Main {
public static void main(String[] args) {
@nithesh1992
nithesh1992 / colors.xml
Created August 22, 2016 17:04
Color Codes for Android Developers
<?xml version="1.0" encoding="utf-8"?>
<!--
Basic Color Palette for Android
Nithesh C Nekkanti
https://github.com/nithesh1992
-->
<resources>
@nithesh1992
nithesh1992 / reNamer.py
Created September 6, 2016 01:11
renaming multiple files in python
# reNamer - By Nithesh. Customize the Name part as you like to rename your bulk files in a directory
import os
os.chdir("D:/filerename")
i=0
for f in os.listdir():
name, ext = os.path.splitext(f)
i = i + 1
print(f)
hname, extra = name.split('_')
// SalesForce Apex Code
List<Schema.SObjectType> AllSobjects = Schema.getGlobalDescribe().Values(); // Getting All sObjects available.
List<String> AllSobjectsNames = new List<String>();
for(Schema.SObjectType sObj : AllSobjects) {
AllSobjectsNames.add(sObj.getDescribe().getName());
} // Getting All sObjects Names available.
@nithesh1992
nithesh1992 / metaDataUtils
Last active December 12, 2016 20:02
utils class to get a list of all fields of an object, all required fields of an object etc... and more to come
public class metaDataUtils {
public static Map<String, Schema.DescribeFieldResult> getFieldMetaData(String obj) {
Map<String,Schema.DescribeFieldResult> finalMap = new Map<String, Schema.DescribeFieldResult>();
Map<String, Schema.SObjectField> objectFields = Schema.getGlobalDescribe().get(obj).getDescribe().fields.getMap();
// getting a specific object fields
for(String fieldName: objectFields.keySet()){
finalMap.put(fieldName, objectFields.get(fieldName).getDescribe());
}
return finalMap;
}
@nithesh1992
nithesh1992 / copyOppItemHelper.apxc
Created February 22, 2017 14:58
Helper Class for copyOppLineItems Trigger
public class copyOppItemHelper {
public static List<Id> getOppIds(List<Order> orderList) {
List<Id> oppIds = new List<Id>();
for(Order newOrder: orderList) {
oppIds.add(newOrder.OpportunityId);
}
return oppIds;
}
@nithesh1992
nithesh1992 / copyOppLineItems.apxt
Created February 22, 2017 14:59
Whenever order is created,This needs to copy related opportunity line items to order line items.
/**
* TriggerName : copyOppLineItems
* @description : Whenever order is created,
* This needs to copy related opportunity line items to order line items.
*/
trigger copyOppLineItems on Order (after insert) {
List<OrderItem> orderItemList = new List<OrderItem>();
List<Order> orderList = [SELECT Id, OpportunityId, EffectiveDate, EndDate, IsDeleted,
IsReductionOrder, Name, OrderNumber, OrderReferenceNumber,
<apex:page standardController="Lead" extensions="ConvertExt" sidebar="false">
<apex:pageBlock title="Custom Lead Conversion" tabStyle="Lead" id="LeadBlock">
<apex:pageBlockSection title="Lead Details">
<apex:outputField value="{!lead.LastName}"/>
<apex:outputField value="{!lead.OwnerId}"/>
<apex:outputField value="{!lead.Company}"/>
<apex:outputField value="{!lead.Id}"/>
<apex:outputField value="{!lead.Status}" id="leadStatus"/>
</apex:pageBlockSection>
<apex:form >
public class ConvertExt {
public Lead lead = new Lead();
public Id Lid, accId, conId, oppId;
public Boolean isConverted = false;
public ConvertExt(ApexPages.StandardController stdController){
Lid = (Id)stdController.getRecord().id;
lead = (Lead)stdController.getRecord();
<apex:page standardController="Lead">
<apex:pageBlock title="Lead Conversion Status!" id="LeadBlock">
<apex:pageBlockSection title="Lead Details">
<apex:outputField value="{!lead.ConvertedContactId}"/>
<apex:outputField value="{!lead.Status}"/>
<apex:outputField value="{!lead.ConvertedAccountId}"/>
<apex:outputField value="{!lead.Id}"/>
<apex:outputField value="{!lead.ConvertedOpportunityId}"/>
</apex:pageBlockSection>
</apex:pageBlock>