This file contains hidden or 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
# This code is taken from: https://stackoverflow.com/a/2573715 | |
# Use python 2.7 | |
# Install Bencode package: https://pypi.org/project/BitTorrent-bencode/5.0.8/#files | |
# Usage: python torrent-verify.py <torrent-file> | |
import sys | |
import os | |
import hashlib | |
import bencode | |
import StringIO |
This file contains hidden or 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
(ns clj-handlebars.http-loader | |
(:gen-class | |
:init init | |
:state state | |
:name com.github.jknack.handlebars.io.HTTPCljLoader | |
:implements [com.github.jknack.handlebars.io.TemplateLoader] | |
:constructors {[String] []} | |
:prefix "-") | |
(:import [com.github.jknack.handlebars.io URLTemplateSource] | |
[java.net URL])) |
This file contains hidden or 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
(ns ... | |
(:import [com.github.jknack.handlebars.io TemplateLoader URLTemplateSource] | |
[java.net URL])) | |
(defn http-loader-reify | |
[base-url] | |
(reify TemplateLoader | |
(resolve [this filename] | |
(str base-url filename (. this getSuffix))) |
This file contains hidden or 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
function renderEmail(context) { | |
var template = HtmlService.createTemplateFromFile("emailTemplate"); | |
template.context = context; | |
return template.evaluate().getContent(); | |
} | |
function sendEmail(order) { | |
var context = { | |
message: "Your order has been accepted! Please find the details as follow:", | |
customerName: order[1], |
This file contains hidden or 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"> | |
<head> | |
<!--[if gte mso 9]> | |
<xml> | |
<o:OfficeDocumentSettings> | |
<o:AllowPNG/> | |
<o:PixelsPerInch>96</o:PixelsPerInch> | |
</o:OfficeDocumentSettings> | |
</xml> |
This file contains hidden or 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
public class HTTPTemplateLoader extends URLTemplateLoader { | |
public HTTPTemplateLoader(String baseUrl) { | |
setPrefix(normalize(baseUrl)); | |
} | |
public String resolve(final String filename) { | |
return getPrefix() + filename + getSuffix(); | |
} |
This file contains hidden or 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
;; Util to convert Clojure map to Java Hashmap | |
(defn clj-map->java-map | |
[data] | |
(postwalk | |
#(cond | |
(map? %) (java.util.HashMap. ^java.util.Map %) | |
(keyword? %) (name %) | |
:else %) | |
data)) |
This file contains hidden or 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
(defn http-loader | |
[base-url-prefix] | |
(doto (proxy | |
[URLTemplateLoader] [] | |
(^String resolve [^String path] | |
(str (proxy-super getPrefix) | |
path | |
(.getSuffix this))) |
NewerOlder