git diff --name-status origin/master...remotes/origin/2.0.0
git diff master remotes/origin/2.0.0 -- app/../File.name
git diff master remotes/origin/2.0.0 -- app/../File.name
public with sharing class CommonController { private ApexPages.StandardController standardController; public Account account { get; private set; } public CommonController (ApexPages.StandardController standardController) { this.standardController = standardController; Id recordId = standardController.getId(); account = (Account) standardController.getRecord(); } public PageReference doSomething() { //after some tasks return to Account details view return standardController.view(); } public PageReference cancel() { // return to account details view return standardController.view(); } }
<apex:page standardController="Account" extensions="CommonController"> Account_Selected=<b>{!Account.Name}</b><br/> <apex:form > <apex:commandButton value="Do something in CommonController.doSomething()" action="{!doSomething}"/> <apex:commandButton value="Cancel this process & return to details view" action="{!cancel}"/> </apex:form> </apex:page>
public class CustomController { public Account account { get; private set; } public NewAndExistingController() { Id id = ApexPages.currentPage().getParameters().get('id'); account = (id == null) ? new Account() : [SELECT Name, Phone, Industry FROM Account WHERE Id = :id]; } public PageReference save() { try { upsert(account); } catch(System.DMLException e) { ApexPages.addMessages(e); return null; } // After successful Save, navigate to the default view page PageReference r = new ApexPages.StandardController(Account).view(); return (r); } }
<apex:page controller="CustomController" tabstyle="Account"> <apex:form> <apex:pageBlock mode="edit"> <apex:pageMessages/> <apex:pageBlockSection> <apex:inputField value="{!Account.name}"/> <apex:inputField value="{!Account.phone}"/> <apex:inputField value="{!Account.industry}"/> </apex:pageBlockSection> <apex:pageBlockButtons location="bottom"> <apex:commandButton value="Save" action="{!save}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
<apex:outputLabel escape="false" Value="{!html}" ></apex:outputLabel>
public class ApexClass_1 { @Future(callout=true) public static void c1(String Account_ID) { String name = ''; try { HttpRequest req = new HttpRequest(); req.setEndpoint('http://www.yahoo.com'); req.setMethod('POST'); req.setBody('Account_ID='+EncodingUtil.urlEncode(Account_ID, 'UTF-8')+'&other_param='+EncodingUtil.urlEncode('OTHER PARAM VALUE', 'UTF-8')); req.setCompressed(true); /* If you want to send basic authentication */ String username = 'myname'; String password = 'mypwd'; Blob headerValue = Blob.valueOf(username + ':' + password); String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue); req.setHeader('Authorization', authorizationHeader); Http http = new Http(); HTTPResponse res = http.send(req); name = 'Status_Code=' + res.getStatusCode(); String responseBody = res.getBody(); } catch(System.CalloutException e) { System.debug('Callout error: '+ e); name = ('Error=' + e.getMessage()).substring(0, 20); } /* Reading account object */ Account account = [SELECT Id FROM Account WHERE Id = :Account_ID]; account.Name = name; update op; } }
trigger TriggerActionName on Account (before insert, after insert, after delete) { if (Trigger.isInsert) { if (Trigger.isAfter) { for (Account a : Trigger.New) { ApexClass_1.c1(a.Id); } } } }
package com.pritom.kumar; import java.io.File; import java.io.FileInputStream; /** * Created by pritom on 28/06/2016. */ public class ReadFileAsByteArray { public static void main (String[] args) throws Exception { File file = new File("x1.zip"); FileInputStream fileInputStream = new FileInputStream(file); byte[] toByte = new byte[(int) file.length()]; fileInputStream.read(toByte); fileInputStream.close(); System.out.println("File_Length=" + file.length() + ", Byte_Length=" + toByte.length + ", Both_Are_Equal=" + (file.length() == toByte.length ? "True" : "False")); } }
package com.pritom.kumar; import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; import java.io.ByteArrayOutputStream; import java.util.zip.Deflater; import java.util.zip.Inflater; /** * Created by pritom on 27/06/2016. */ public class CompressString { public static final String encoding = "UTF-8"; public static void main (String[] args) throws Exception { String s = "123456789 a s d f g h j k l ; ' q w e r t y u i o p [ ] \\ 1 2 3 4 5 6 7 8 9 0 - = as df gh jk l; zx cv bn m, ./ qw y ui op []" + "qwe rty uio p[] asd fgh jkl zxc vbn m,. 123 456 789 1234 5678 90-= qwer tyui op[] asdf ghjk l;zx cvbn m,./" + "12345 67890 qwert yuiop asdfg hjklz xcvbn m,khg er xcgvdst 453 gd fyrt634 5 dg e653 545u7r ydf dgfsd fsart sdgdsg" + "sd fsdjf;sjduw[r sldfjsl;djrf2345203v sdfs'wse[rftu 2[3r50 j;lgjks'drf 2354-0u sadfas';dfmka][ ert02u9wsd's;lad fa'sdfjasdgf" + "4 wr[w09u jsd' af32 'QWRJE ajfsdj :ejwkiiuUUSJ W[9230 U'SFJKS JFJSF 'ASDP;GF SDFAW435]2 JKSD';GDALSJ GF'SDAGJFMA'L 2UWQ 'PS;DGJM" + "ju=[0a9 u0wr w435r]2345ru]2tu s'adgjfa'sgf2uq]34u]23'g jfq4323o4 23w 52]5-2t4ewsjtrg'qwpe[fa7 2 03r/ dshgf" + "djl3r4 sjdf ;wq3r q3ra[d0aw'tj3 wr[w09u asd fgh zxc er gd swser9[0345r]2 3dfjsdfsd ]23-qg';gvas 'dgawejrt ]23trwasdg;mas'fgsnkd gasf " + "[w90rtusdmgkf zxc sadfs fa fsart sdgdsg wr JFJSF GF fgh xcgvdst dfmka SDAGJFMA 2345ru wse[rftu 2[3r50 j;l af32 sdfjasdgf jks'drf 2354-" + "djrf2345203v KSD';GDALSJ GF'"; String compressed = compress(s); Integer savedLength = s.length() - compressed.length(); Double saveRatio = (new Double(savedLength) * 100) / s.length(); String ratioString = saveRatio.toString() + "00000000"; ratioString = ratioString.substring(0, ratioString.indexOf(".") + 4); println("Original_String_Length=" + s.length()); println("Compressed_String_Length=" + compressed.length() + ", Compression_Ratio=" + ratioString + "%"); String decompressed = decompress(decodeBase64(compressed)); println("Decompressed_String_Length=" + decompressed.length() + " == Original_String_Length (" + s.length() + ")"); println("Original_String == Decompressed_String=" + (s.equals(decompressed) ? "True" : "False")); } public static String compress(String str) throws Exception { return compress(str.getBytes(encoding)); } public static String compress(byte[] bytes) throws Exception { Deflater deflater = new Deflater(); deflater.setInput(bytes); deflater.finish(); ByteArrayOutputStream bos = new ByteArrayOutputStream(bytes.length); byte[] buffer = new byte[1024]; while(!deflater.finished()) { int count = deflater.deflate(buffer); bos.write(buffer, 0, count); } bos.close(); byte[] output = bos.toByteArray(); return encodeBase64(output); } public static String decompress(byte[] bytes) throws Exception { Inflater inflater = new Inflater(); inflater.setInput(bytes); ByteArrayOutputStream bos = new ByteArrayOutputStream(bytes.length); byte[] buffer = new byte[1024]; while (!inflater.finished()) { int count = inflater.inflate(buffer); bos.write(buffer, 0, count); } bos.close(); byte[] output = bos.toByteArray(); return new String(output); } public static String encodeBase64(byte[] bytes) throws Exception { BASE64Encoder base64Encoder = new BASE64Encoder(); return base64Encoder.encodeBuffer(bytes).replace("\r\n", "").replace("\n", ""); } public static byte[] decodeBase64(String str) throws Exception { BASE64Decoder base64Decoder = new BASE64Decoder(); return base64Decoder.decodeBuffer(str); } public static void println(Object o) { System.out.println("" + o); } }