Skip to content

Instantly share code, notes, and snippets.

Avatar
👩‍💻

Shruti Sridharan shrutis22

👩‍💻
View GitHub Profile
View TesselServices.cls
@RestResource( urlMapping = '/tesselservices/*' )
global class TesselServices {
public static final String MODEL_ID = 'INSERT MODEL ID HERE';
@HttpPost
global static String upload() {
RestRequest req = RestContext.request;
RestResponse res = Restcontext.response;
Blob picture = req.requestBody;
View LightningLookup.css
.THIS label.slds-form-element__label {
display: none;
}
.THIS .fieldLabel {
font-size: .75rem;
}
View LightningLookup.design
<design:component>
<design:attribute name="objectApiName" />
<design:attribute name="fieldLabel" />
<design:attribute name="fieldName" />
<design:attribute name="selectedRecordId" />
</design:component>
View LightningLookupController.js
({
handleOnChange : function(component, event, helper) {
component.set( "v.selectedRecordId", event.getParams( "fields" ).value );
}
})
View LightningLookup.cmp
<aura:component implements="lightning:availableForFlowScreens,flexipage:availableForRecordHome,force:hasRecordId" access="global">
<aura:attribute name="objectApiName" type="String" access="public" />
<aura:attribute name="fieldLabel" type="String" access="public" />
<aura:attribute name="fieldName" type="String" access="public" />
<aura:attribute name="selectedRecordId" type="String" access="public" />
<lightning:recordEditForm objectApiName="{!v.objectApiName}">
<label class="fieldLabel">{!v.fieldLabel}</label>
<lightning:inputField fieldName="{!v.fieldName}" onchange="{!c.handleOnChange}" />
</lightning:recordEditForm>
View ShowEmotionsHelper.js
({
getGiphyImage : function( emotion, callback ) {
var xhr = new XMLHttpRequest();
xhr.open( "GET", "https://api.giphy.com/v1/gifs/search?api_key=B9pfrx9wtMXmdLnVaJ6vllAW7uTqaHvO&q=" + emotion + "&limit=1", false )
xhr.onreadystatechange = function() {
if( this.readyState === 4 ) {
var jsonResp = JSON.parse( this.response );
var gifUrl = jsonResp.data[0].images.downsized.url;
View ShowEmotionsController.js
({
showEmotion : function(component, event, helper) {
var toneAnalyzeResponse = component.get( "v.toneAnalyzeResponse" );
var standardTones = [ "joy", "sadness", "anger", "fear" ];
var emotion;
for( var i = 0; i <= standardTones.length - 1; i++ ) {
if( toneAnalyzeResponse.indexOf( standardTones[i] ) !== -1 ) {
emotion = standardTones[i];
View ShowEmotions.cmp
<aura:component implements="lightning:availableForFlowScreens" access="global">
<aura:attribute name="toneAnalyzeResponse" type="string" access="global"></aura:attribute>
<aura:handler name="init" value="{!this}" action="{!c.showEmotion}"></aura:handler>
<aura:attribute name="gifUrl" type="string" access="private"></aura:attribute>
<aura:attribute name="detectedEmotion" type="string" access="private"></aura:attribute>
Detected Image: {!v.detectedEmotion}
<br/>
<img src="{!v.gifUrl}" />
</aura:component>
@shrutis22
shrutis22 / BitlySwagger.json
Created Feb 8, 2018
Swagger Specification for Bitly
View BitlySwagger.json
{
"swagger" : "2.0",
"info" : {
"description" : "Shorten URL API",
"version" : "1.0.0",
"title" : "Bit.ly"
},
"host" : "api-ssl.bitly.com",
"schemes" : [ "https" ],
"paths" : {
View Pushtopic.cls
PushTopic pt = new PushTopic();
pt.Name = 'Announcements';
pt.Query = 'SELECT Id, Name, Details__c FROM Announcement__c';
pt.ApiVersion = 41.0;
pt.NotifyForOperationCreate = true;
pt.NotifyForOperationUpdate = true;
pt.NotifyForFields = 'Referenced';
INSERT pt;