Skip to content

Instantly share code, notes, and snippets.

@altmind
altmind / cloudfront-createDistribution.groovy
Created August 13, 2012 16:13
cloudfront createDistribution
CreateDistributionResult distribution = cloudFrontClient.createDistribution(
new CreateDistributionRequest().withDistributionConfig(
new DistributionConfig()
.withCallerReference(System.nanoTime().toString())
.withAliases(
new Aliases()
.withQuantity(0)
)
.withDefaultRootObject("index.html")
.withOrigins(
@altmind
altmind / cloudfront-listdistributions.groovy
Created August 13, 2012 16:19
cloudfront-listdistributions
ListDistributionsResult distributions = cloudFrontClient.listDistributions(new ListDistributionsRequest().withMaxItems("1000"))
List<DistributionSummary> distributionsItems = distributions.distributionList.items
GetDistributionResult distribution = cloudFrontClient.getDistribution(new GetDistributionRequest().withId(distributionsItems[1].id))
@altmind
altmind / cloudfront-createDistribution-correct.groovy
Created August 13, 2012 16:23
cloudfront-createDistribution-correct
CreateDistributionResult distribution = cloudFrontClient.createDistribution(
new CreateDistributionRequest().withDistributionConfig(
new DistributionConfig()
.withCallerReference(System.nanoTime().toString())
.withAliases(
new Aliases()
.withQuantity(0)
)
.withDefaultRootObject("index.html")
.withOrigins(
@altmind
altmind / sample-changelog.groovy
Created August 15, 2012 09:58
sample-changelog.groovy
databaseChangeLog = {
changeSet(author: "alt (generated)", id: "1345021906578-1") {
renameTable(oldTableName: "ADMINS", newTableName: "USERS")
}
}
ProcessDocument = app.trustedFunction(function () {
app.beginPriv();
var newDoc = app.newDoc();
var p = app.response("Start with page(default 0 - process all pages)?", "Query", "0");
var startFrom = parseInt(p) || 0;
var i = 0;
while (i < this.numPages) {
newDoc.insertPages({
nPage: newDoc.numPages - 1,

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

<!--[if IE]> <html class="ie-any"> <![endif]-->
<!--[if !IE]><!--><html> <!--<![endif]-->
<script>
if(Function('/*@cc_on return typeof(document.documentMode)=="number" @*/')()){
document.getElementsByTagName("html")[0].className+=" ie-any";
}
</script>
function parseUrl(url) {
if ($.type(url) === "object") {
return url;
}
var matches = /^(((([^:\/#\?]+:)?(?:\/\/((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?]+)(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/.exec(url);
return matches ? {
href:matches[0] || "",
hrefNoHash:matches[1] || "",
hrefNoSearch:matches[2] || "",
domain:matches[3] || "",
todomvc\tests>mocha allTests.js --no-timeouts --reporter spec "--framework=rivets" "--framework=rivets" "--framework=rivets" "--framework=rivets" "--framework=rivets" "--framework=rivets"
TodoMVC - rivets
When page is initially opened
√ should focus on the todo input field (78ms)
No Todos
√ should hide #main and #footer (155ms)
New Todo
√ should allow me to add todo items (578ms)
@altmind
altmind / key.md
Created December 16, 2018 20:53
Twitter (un)official Consumer Key

Twitter Official Consumer Key

Twitter for Android

type:            PIN
Consumer key:    3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys

Twitter for iPhone

type:            PIN

Consumer key: IQKbtAYlXLripLGPWd0HUA