View s3_secure_file.rb
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
require 'aws-sdk-s3' | |
# When there's something wrong with the s3 | |
class S3StorageError < StandardError | |
def initialize(data) | |
@data = data | |
end | |
end | |
class S3File |
View enable-rata-rest-api.php
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
<?php | |
/** | |
* Add REST API support to an already registered post type. | |
*/ | |
add_action( 'init', 'rata_post_type_rest_support', 25 ); | |
function rata_post_type_rest_support() { | |
global $wp_post_types; | |
// Be sure to set this to the name of your post type! | |
$post_type_name = 'rata'; |
View append-only-s3.tf
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
## | |
# Asks the bucket name | |
## | |
variable "aws_bucket_name" {} | |
provider "aws" { | |
alias = "west" | |
region = "eu-west-1" | |
} |
View curl.txt
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
$ curl -i https://www.metabase.com/docs/ | |
HTTP/1.1 200 OK | |
Content-Type: text/html; charset=utf-8 | |
Content-Length: 426 | |
Connection: keep-alive | |
Date: Thu, 26 Oct 2017 10:20:14 GMT | |
Last-Modified: Wed, 04 Oct 2017 01:39:52 GMT | |
ETag: "e377a2b0a454fded1058c86690d70473" | |
Server: AmazonS3 | |
Age: 9573 |
View iban_generator.rb
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
# Module for generating random Iban account numbers | |
module IBAN | |
# Calculates the mandatory checksum of 3..4 characters in iban | |
def iban_checksum(account, cc) | |
# Converts letters to numbers according the iban rules, A=10..Z=35 | |
iban_to_num = "#{account}#{cc}00".upcase.chars.map { |d| | |
d.match(/[A-Z]/) ? (d.ord - 55).to_s : d | |
}.join.to_i | |
# Calculate checksum with reverse modulo |
View finnish_bank_reference.rb
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
# Array#sum is needed for nice code outside rails projects | |
require 'active_support' | |
require 'active_support/core_ext' | |
# Module for creating valid Finnish bank references | |
module FinnishBankRefence | |
# Generates reference from a input or a random number | |
def self.generate( base = rand(10**3..(10**19-1)) ) | |
if base < 10**3 or base >= 10**19 |
View gist:1428963860b6172744644d7f58b3ebb1
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
$ curl -sSL https://get.rvm.io | bash -s stable --ruby | |
Downloading https://github.com/rvm/rvm/archive/1.29.2.tar.gz | |
Downloading https://github.com/rvm/rvm/releases/download/1.29.2/1.29.2.tar.gz.asc | |
gpg: Signature made Thu Jun 22 19:18:38 2017 EEST using RSA key ID BF04FF17 | |
gpg: Good signature from "Michal Papis (RVM signing) <mpapis@gmail.com>" [unknown] | |
gpg: aka "Michal Papis <michal.papis@toptal.com>" [unknown] | |
gpg: aka "[jpeg image of size 5015]" [unknown] | |
gpg: WARNING: This key is not certified with a trusted signature! | |
gpg: There is no indication that the signature belongs to the owner. | |
Primary key fingerprint: 409B 6B17 96C2 7546 2A17 0311 3804 BB82 D39D C0E3 |
View terraform_digitalocean_dokku.tf
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
variable "digitalocean_token" { | |
description = "This is the Digitalocean API-token which is used to setup the machines." | |
} | |
variable "digitalocean_region" { | |
description = "For example: nyc1, nyc2, ams2, ams3, fra2" | |
default = "fra1" | |
} | |
variable "digitalocean_dokku_size" { | |
description = "Instance size: 512mb, 1gb, 2gb, 4gb ..." | |
default = "2gb" |
View 0_reuse_code.js
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
View sendmail
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 | |
## | |
# This is custom wrapper for msmtp which acts like good old sendmail | |
# - It is used for php and cron | |
# - This is easier to configure for external mail server than sendmail | |
# - sendmail is just the default binary which other services will use | |
# - It needs following env: SMTP_HOST, SMTP_PASSWORD, SMTP_PORT, SMTP_AUTH, SMTP_USER | |
## | |
# This script gives itself as a parameter for msmtp |
NewerOlder