Skip to content

Instantly share code, notes, and snippets.

@recalde
recalde / jQueryTemplateDemo.html
Created June 10, 2011 19:02
jQuery Templates with Salesforce Ajax Toolkit
<apex:page title="jQuery Template Demo">
<!-- Get the session for connection.js -->
<script type="text/javascript">
var __sfdcSessionId = '{!GETSESSIONID()}';
</script>
<!-- Script references -->
<apex:includeScript value="{!URLFOR($Resource.jQueryTemplateBeta, 'jquery-1.4.4.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.jQueryTemplateBeta, 'jquery.tmpl.js')}"/>
@recalde
recalde / jQueryGridDemo.html
Created June 10, 2011 19:10
jQuery Grid with Salesforce Ajax Toolkit
<apex:page title="jQuery Grid Demo">
<!-- Get the session for connection.js -->
<script type="text/javascript">
var __sfdcSessionId = '{!GETSESSIONID()}';
</script>
<!-- jQueryUI Theme -->
<link rel="stylesheet" href="{!URLFOR($Resource.jQueryGridPre19, '/jquery-jquery-ui-b5c4529/themes/base/jquery.ui.all.css')}"/>
@recalde
recalde / gist:1068037
Created July 6, 2011 18:55
CPP_Builder_Rob_Controller
global with sharing class CPPBuilderRob {
public CPPBuilderRob() {
// Remember: @RemoteActions are static, hence no controller has no state
}
@RemoteAction
global static CPP_Report_Poller GetReportGroups(string opportunityId) {
// Query from CPP_Report_Request__c
@recalde
recalde / gist:1068038
Created July 6, 2011 18:56
CPP_Builder_Rob_Page
<apex:page title="CPP Builder (Rob)" controller="CPPBuilderRob" sidebar="false">
<!-- Get the session for connection.js -->
<script type="text/javascript">
var __sfdcSessionId = '{!GETSESSIONID()}';
</script>
<!-- jQueryUI Theme -->
<link rel="stylesheet" href="{!URLFOR($Resource.jQueryGridPre19, '/jquery-jquery-ui-b5c4529/themes/base/jquery.ui.all.css')}"/>
@recalde
recalde / Controller.cs
Created July 20, 2011 17:38
Salesforce_JQuery_Remoting
global with sharing class CPPBuilderRob {
public CPPBuilderRob() {
// Remember: @RemoteActions are static, hence controller has no state
}
@RemoteAction
global static CPP_Report_Poller GetReportGroups(string opportunityId) {
// Query from CPP_Report_Request__c
@recalde
recalde / gist:1253878
Created September 30, 2011 14:22
Salesforce showFilePreview
<!-- This is an example of how to use the function -->
<a id="Title_069Q00000006bam" href="javascript:showPreviewDialog('069Q00000006bam', 'Title_069Q00000006bam', 'PDF');">Cover Sheet</a>
<!-- This is the javascript -->
<script type="text/javascript">
function showPreviewDialogForContentDocument(contentDocumentId, titleElementId) {
var query = "SELECT Id, ContentDocumentId, FileType, CreatedDate ";
query += "FROM ContentVersion ";
query += "WHERE ContentDocumentId = '" + contentId + "' ";
@recalde
recalde / csv_to_sqlserverdb.md
Last active January 25, 2024 14:52
ChatGPT - Upload CSV to SQL Server

CSV to SQL Python

User write me a python program that will open a very large csv file, and insert the data to a microsoft sql server database. the program should create a temporary table using the columns in the first row of the file, then insert the remaining rows from the file in batches of 1000.

ChatGPT To write a Python program that can handle the task you've described, we will use the pandas library for processing the CSV file, and pyodbc or sqlalchemy for interacting with the Microsoft SQL Server. The program will:

  1. Read the CSV file in chunks.
  2. Connect to the SQL Server database.
@recalde
recalde / chat_gtp_test_sql.md
Created January 25, 2024 15:11
chat_gtp_test_sql

To modify the program to write the results to a markdown file with a table, we'll adjust the script to collect the results in a list and then write this list to a markdown file at the end. Each row in the markdown table will contain the SQL file name and the output status.

Here's the updated script:

import os
import psycopg2

# Database configuration
db_config = {
To integrate an AWS Lambda function with an on-premises IIS server using Windows authentication and cache HTTP responses, follow these streamlined instructions focusing on authentication and caching strategies:
Handling Windows Authentication
HTTP Client: Utilize a Python HTTP client library that supports Windows authentication, such as requests-ntlm for NTLM or requests-negotiate-sspi for Kerberos, alongside the standard requests library.
Implementing Caching
You can choose from several caching strategies based on your requirements:
Amazon S3: Suitable for storing large JSON responses. Serialize the response and store it in an S3 bucket with a unique key for each entry to facilitate easy retrieval.
Amazon DynamoDB: Ideal for structured data caching, allowing queries based on response attributes. Use a TTL attribute for automatic expiration of old entries.
Amazon ElastiCache: Offers high-performance, low-latency caching suitable for frequently accessed data. Choose between Redis and Memcached based on your
import boto3
import requests
import json
import datetime
from dateutil import parser
from requests_ntlm import HttpNtlmAuth
# AWS clients
s3 = boto3.client('s3')
ssm = boto3.client('ssm')