Skip to content

Instantly share code, notes, and snippets.

@angstwad
angstwad / test_split_jinja_ansible.yml
Created March 31, 2014 14:24
Splitting in Jinja2/Ansible
---
- name: Test split
hosts: localhost
gather_facts: false
vars:
- facter_blockdevices: "sda,sdb,sdc,sdd,sde,sdf"
tasks:
- name: Let's split
debug: var=item
with_items: "facter_blockdevices.split(',')"
@phylake
phylake / openssl.md
Last active February 4, 2019 20:25
openssl help
@guillaumebort
guillaumebort / Secured.scala
Created April 7, 2012 12:05
HTTP Basic Authorization for Play 2.0
def Secured[A](username: String, password: String)(action: Action[A]) = Action(action.parser) { request =>
request.headers.get("Authorization").flatMap { authorization =>
authorization.split(" ").drop(1).headOption.filter { encoded =>
new String(org.apache.commons.codec.binary.Base64.decodeBase64(encoded.getBytes)).split(":").toList match {
case u :: p :: Nil if u == username && password == p => true
case _ => false
}
}.map(_ => action(request))
}.getOrElse {
Unauthorized.withHeaders("WWW-Authenticate" -> """Basic realm="Secured"""")
@RulerOf
RulerOf / zfs-on-oracle-linux-7.md
Last active June 7, 2019 19:46
Installing ZFS on Linux on Oracle Linux 7

Installing ZFS on Linux on Oracle Linux 7

We're going to add ZFS support to our Oracle Linux installation. We'll just add the ZFS on Linux Repo, verify the binary signature from GitHub, install the files, ensure the driver loads properly, and verify that it's functional. We'll save things like array creation for another document.

This is mostly a transcription of the process from the CentOS/RHEL ZoL installation manual.

Note

This will install ZFS v0.7 release on OEL 7.7 and earlier, and ZFS 0.8 on OEL 7.8 and later.

Install the repo file

@mattbornski
mattbornski / stdout.py
Created August 8, 2012 21:41
Streaming stdout from a Python subprocess in Python 2.6-2.7
#!/usr/bin/env python
# I was frustrated that no matter what buffer setting I passed to communicate,
# I could not get stdout from my subprocess until the process had completed.
# I googled around and came up with this, which illustrates the problem and a
# solution.
# http://stackoverflow.com/questions/2804543/read-subprocess-stdout-line-by-line
# http://bugs.python.org/issue3907
# http://docs.python.org/library/io.html
@jaytaylor
jaytaylor / WIP--auto-unrar-updated-for-2020.sh
Last active March 18, 2020 18:06
Busy-box compatible automatic RAR extraction system.
#!/usr/bin/env bash
##
#
# @author Jay Taylor [@jtaylor]
#
# @date
#
# @description Busy-box compatible automatic RAR extraction system.
#
@elwinar
elwinar / snake.go
Created November 18, 2014 11:30
ToSnake function for golang, convention-compliant
package main
import (
"unicode"
)
// ToSnake convert the given string to snake case following the Golang format:
// acronyms are converted to lower-case and preceded by an underscore.
func ToSnake(in string) string {
runes := []rune(in)
@agemooij
agemooij / SnakifiedSprayJsonSupport.scala
Last active November 18, 2020 14:34
An example of how to customize the field mapping in spray-json to do generic transformation, in this case translating between camelcased Scala attributes and snakecase JSON attributes
/**
* The MIT License (MIT)
*
* Copyright (c) 2013-2015 Andrew Snare, Age Mooij
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@DavidVaini
DavidVaini / round.go
Created April 9, 2014 19:58
Arggh Golang does not include a round function in the standard math package. So I wrote a quick one.
package main
import (
"log"
"math"
)
func Round(val float64, roundOn float64, places int ) (newVal float64) {
var round float64
pow := math.Pow(10, float64(places))
@belminf
belminf / aws-cli.sh
Last active August 6, 2021 23:27
AWS CLI command to find latest RHEL and Ubuntu images using JMESPath
# Both are limited to HVM-based 64-bit AMIs backed by EBS
# Red Hat's latest GA images
alias ami_rhel="aws ec2 describe-images \
--filters \
'Name=root-device-type,Values=ebs' \
'Name=architecture,Values=x86_64' \
'Name=virtualization-type,Values=hvm' \
'Name=name,Values=*GA*' \
--owners 309956199498 \