Skip to content

Instantly share code, notes, and snippets.

View Satak's full-sized avatar

Sami Koskivaara Satak

View GitHub Profile
'''Dynamic templates'''
# -*- coding: utf-8 -*-
import os
import locale
from string import Template
class Car:
'''Class Car'''
import crypt
def crypt_test(password, salt, checksum='my43charchecksum'):
'''Test only the logic without crypt library'''
correct = 'iCeCream9999'
if password == correct:
return 'prefix {} suffix'.format(checksum)
return 'prefix something else suffix'
@Satak
Satak / env.py
Last active March 28, 2018 06:56
'''
This script parses environment variables and gets set of three variables at the time.
It then calls function with those arguments (database, username, password) based on pattern:
DB_<UNIQUENAME>_DATABASE
DB_<UNIQUENAME>_USERNAME
DB_<UNIQUENAME>_PASSWORD
'''
import re
package main
import (
"encoding/base64"
"fmt"
"math/rand"
"time"
"golang.org/x/crypto/bcrypt"
)
@Satak
Satak / cf-template.yaml
Created February 15, 2019 13:20
AWS CloudFormation Template
Resources:
MyInstance:
Type: 'AWS::EC2::Instance'
Properties:
AvailabilityZone: eu-west-1a
ImageId:
Ref: ImageId
KeyName: !Ref KeyName
InstanceType:
Ref: InstanceType
param(
[string]$version,
$AllowRemoteExecution = $True
)
# install AV
$path = 'C:\av'
$fileName = 'output.txt'
$fullFilePath = (Join-Path -Path $path -ChildPath $fileName)
New-Item -ItemType Directory -Path $path
New-Item -ItemType File -Path $fullFilePath
Get-Disk | Where-Object {$_.PartitionStyle -eq 'RAW'} | Initialize-Disk -PassThru | New-Partition -AssignDriveLetter -UseMaximumSize | Format-Volume
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"containerName": {
"type": "string"
},
"dnsNameLabel": {
"type": "string"
},
@Satak
Satak / Invoke-GistDeployment.ps1
Created December 1, 2019 11:25
Gets file content from repository and deploys that as a Gist
<#
.Synopsis
Gets file content from repository and deploys that as a Gist.
.DESCRIPTION
Used in a GitHub action that automatically deploys your private repository file content as a secret Gist for example.
You must provide GitHub Personal access Token, target Gist ID and Gist filename
.PARAMETER Token
GitHub Personal Access Token with Gist scope
.PARAMETER GistID
GitHub Gist ID
@Satak
Satak / github_action.md
Created December 4, 2019 12:24
GitHub action dev guide