Skip to content

Instantly share code, notes, and snippets.

@nappa32
nappa32 / Makefile
Created November 1, 2019 20:51 — forked from ryu1kn/Makefile
Encrypt/decrypt with AWS KMS using AWS cli
# How to encrypt/decrypt your text/blob secret with AWS KMS with AWS cli
KEY_ID=alias/my-key
SECRET_BLOB_PATH=fileb://my-secret-blob
SECRET_TEXT="my secret text"
ENCRYPTED_SECRET_AS_BLOB=encrypted_secret_blob
DECRYPTED_SECRET_AS_BLOB=decrypted_secret_blob # Result of decrypt-blob target
encrypt-text:
@nappa32
nappa32 / Terraform_functions.md
Created February 21, 2019 01:10 — forked from davewongillies/Terraform_functions.md
Terraform Functions

Supported built-in functions

  • abs(float) - Returns the absolute value of a given float. Example: abs(1) returns 1, and abs(-1) would also return 1, whereas abs(-3.14) would return 3.14. See also the signum function.

  • basename(path) - Returns the last element of a path.

  • base64decode(string) - Given a base64-encoded string, decodes it and returns the original string.

@nappa32
nappa32 / rake multitask
Created November 12, 2015 02:02
rake multitask example
task :task1 => [:big_db_task] do
sleep 1
puts "Task 1"
end
task :big_db_task do
puts "Big db task"
end
task :task3 => [:big_db_task] do
puts "Task 3"
end
@nappa32
nappa32 / nginx.conf
Last active August 29, 2015 14:19 — forked from Stanback/nginx.conf
server {
listen 80;
listen [::]:80;
server_name yourserver.com;
root /path/to/your/htdocs;
error_page 404 /404.html
index index.html;
class Sanitise
{
public function get($name, $filter, $options=null)
{
return $this->sanitise(INPUT_GET, $name, $filter, $options);
}
public function post($name, $filter, $options=null)
{
return $this->sanitise(INPUT_POST, $name, $filter, $options);
<?php
function get_param($key, $filter=FILTER_SANITIZE_STRING) {
if (!isset($_GET[$key])) {
return null;
}
return filter_var($_GET[$key], $filter);
}
function post_param($key, $filter=FILTER_SANITIZE_STRING) {
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
#!/bin/bash
#
# (Above line comes out when placing in Xcode scheme)
#
# Valid and working as of 11/4/2014
# Xcode 6.1, XCode Server 4
#
API_TOKEN="<Your TestFlight API Token>"
curl -D cookie1.txt blog.xrmplatform.org/wp-login.php
# step 1
# get default cookie of blog and write cookie to cookie1.txt
# step 2
# simulate browser Firefox( of course , you can use any browser agent<!--more--> what you want!) "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"
# input your username and also password
# write new cookie to cookie2.txt
curl -A "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6" -D cookie2.txt -b cookie1.txt -F log=username -F pwd=password -F testcookie=1 -F wp-submit="Log In" -F redirect_to=blog.xrmplatform.org/wp-admin -F submit=login -F rememberme=forever blog.xrmplatform.org/wp-login.php
# currently cookie2.txt stored all cookie info
@nappa32
nappa32 / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console