Skip to content

Instantly share code, notes, and snippets.

View cafeasp's full-sized avatar

Victor Pacheco cafeasp

View GitHub Profile
@cafeasp
cafeasp / RestletExample.js
Created May 19, 2019 16:21
NetSuite Restlet Template
/**
* @NApiVersion 2.x
* @NScriptType Restlet
* @NModuleScope SameAccount
*/
define(['N/search', 'N/record'],
/**
* @param {search} search
* @param {record} record
*/
@cafeasp
cafeasp / appSettings.config
Created August 10, 2018 18:46
Any mvc web app can use this file to set your private settings on a different path in your computer.
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<add key="AppId" value="your_app_id" />
<add key="AppSecret" value="your_app_secret" />
<add key="AppScope" value="read_orders,write_orders" />
</appSettings>
@cafeasp
cafeasp / CreateFolder.cs
Created March 20, 2017 17:23
Google Drive API C# - Create a folder
private static void CreateFolder(string folderName,DriveService service)
{
var fileMetadata = new Google.Apis.Drive.v3.Data.File()
{
Name = folderName,
MimeType = "application/vnd.google-apps.folder"
};
var request = service.Files.Create(fileMetadata);
request.Fields = "id";
var file = request.Execute();
@cafeasp
cafeasp / IsWebHookAuthentic.cs
Created March 10, 2017 12:53
Is web hook authentic
public bool IsAuthenticWebhook(NameValueCollection requestHeaders, string requestBody, string shopifySecretKey)
{
string hmacHeader = requestHeaders.Get("X-Shopify-Hmac-SHA256");
if (string.IsNullOrEmpty(hmacHeader))
{
return false;
}
HMACSHA256 hmac = new HMACSHA256(Encoding.UTF8.GetBytes(shopifySecretKey));
@cafeasp
cafeasp / SqlBackup.cs
Created February 28, 2017 20:50
C# SQL Backup
public class BackupService
{
private readonly string _connectionString;
private readonly string _backupFolderFullPath;
private readonly string[] _systemDatabaseNames = { "master", "tempdb", "model", "msdb" };
public BackupService(string connectionString, string backupFolderFullPath)
{
_connectionString = connectionString;
_backupFolderFullPath = backupFolderFullPath;