This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# You can modify files on instance progmatically using the WebDAV protocol. | |
# First create an Account Manager API Client, noting its ID and secret. | |
# Then on your instance, grant that client access to the WebDAV API in WebDAV Client Permissions page. | |
# Finally, use the ID and secret to get an access token from Account Manager and use that to call WebDAV on your instance. | |
set -euo pipefail | |
HOST='YOUR-INSTANCE-HOSTNAME' # eg. zzrf-001.dx.commercecloud.salesforce.com | |
CLIENT='YOUR-AM-CLIENT-ID' | |
SECRET='YOUR-AM-CLIENT-SECRET' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Trusted Agent on Behalf of Demo: | |
# | |
# https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=getTrustedAgentAuthorizationToken | |
# SLAS Client requires `sfcc.ta_ext_on_behalf_of` scope. | |
set -eou pipefail | |
CODE='kv7kzm78' | |
ORG='f_ecom_zzrf_001' | |
CLIENT='8eefe333-cac4-4cbe-ad1c-a7336693acbc' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Print the headers of URL. | |
alias curl-headers='curl ${CURL_ARGS[@]} --dump-header -' | |
# Print Time to First Byte of URL. | |
alias curl-ttfb='curl ${CURL_ARGS[@]} --write-out "%{time_starttransfer}\n"' | |
# Print bytes file size of URL. | |
alias curl-size='curl ${CURL_ARGS[@]} --write-out "%{size_download}\n"' | |
# https://ec.haxx.se/usingcurl-writeout.html | |
alias curl-timing='curl ${CURL_ARGS[@]} --write-out " | |
namelookup: %{time_namelookup} Start to name resolving | |
connect: %{time_connect} Start to TCP connect to host |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Archive channels with no new messages in the last two months. | |
// Usage: npm install slack async | |
// SLACK_TOKEN=XYZ node slack-cleanup.js | |
// Get your Slack Token: https://api.slack.com/docs/oauth-test-tokens | |
"use strict" | |
const readline = require('readline') | |
const slack = require('slack') | |
const async = require('async') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Outputs JSON key / value pairs of objects in an S3 bucket which redirect. | |
* http://boto3.readthedocs.org/en/latest/guide/migrations3.html | |
* http://boto3.readthedocs.org/en/latest/reference/services/s3.html#S3.Object.get | |
''' | |
import csv | |
import json | |
import boto3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 'Google OAuth2' | |
echo '' | |
echo 'This script generates refresh token to retrieve an' | |
echo 'access token, to allows access to Google APIs :)' | |
echo '' | |
echo '--> Application Credentials: https://console.developers.google.com/projectselector/apis/credentials' | |
read -p 'Client ID: ' CLIENT_ID | |
read -p 'Client Secret: ' CLIENT_SECRET | |
echo '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# ./tinypng.sh <filename> <filename> <filename> | |
# | |
# Upload the files to shrink and then save them locally under the same name. | |
# Only works with JPEG and PNG. | |
# | |
# Uses the TinyPNG API: https://tinypng.com/developers/reference | |
# Inspired by this Gist: https://gist.github.com/s4l1h/553d00b71d4ab14c17d9 | |
# | |
# TODO: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mock | |
import requests | |
import unittest | |
def get(): | |
# Retrieves data from an external service eg. Twitter, Google | |
try: | |
return requests.get('http://external-service.com/') | |
except requests.RequestException: | |
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/questions/16888285/overriding-gos-default-http-sever-redirect-behaviour/16891953?noredirect=1#16891953 | |
package main | |
import ( | |
"fmt" | |
"net/http" | |
) | |
type Handler struct {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"testing" | |
"net/http" | |
"net/http/httptest" | |
) | |
func TestMergeSlashes(t *testing.T) { | |
req, _ := http.NewRequest("GET", "http://foo.com/", nil) |
NewerOlder