Skip to content

Instantly share code, notes, and snippets.

@alsmola
alsmola / cloudtrail_partition_create_athena_table.sql
Last active August 23, 2023 10:28
cloudtrail_partition_create_athena_table
CREATE EXTERNAL TABLE cloudtrail_logs (
eventversion STRING,
userIdentity STRUCT<
  type:STRING,
  principalid:STRING,
  arn:STRING,
  accountid:STRING,
  invokedby:STRING,
  accesskeyid:STRING,
userName:STRING,
@eferro
eferro / _aws_golang_examples.md
Last active July 21, 2023 09:35
golang aws: examples

AWS Golang SDK examples

@varemenos
varemenos / 1.README.md
Last active April 21, 2024 23:21
Git log in JSON format

Get Git log in JSON format

git log --pretty=format:'{%n  "commit": "%H",%n  "abbreviated_commit": "%h",%n  "tree": "%T",%n  "abbreviated_tree": "%t",%n  "parent": "%P",%n  "abbreviated_parent": "%p",%n  "refs": "%D",%n  "encoding": "%e",%n  "subject": "%s",%n  "sanitized_subject_line": "%f",%n  "body": "%b",%n  "commit_notes": "%N",%n  "verification_flag": "%G?",%n  "signer": "%GS",%n  "signer_key": "%GK",%n  "author": {%n    "name": "%aN",%n    "email": "%aE",%n    "date": "%aD"%n  },%n  "commiter": {%n    "name": "%cN",%n    "email": "%cE",%n    "date": "%cD"%n  }%n},'

The only information that aren't fetched are:

  • %B: raw body (unwrapped subject and body)
  • %GG: raw verification message from GPG for a signed commit
@crazybyte
crazybyte / encrypt_openssl.txt
Created November 25, 2012 10:10
File encryption using OpenSSL
For symmetic encryption, you can use the following:
To encrypt:
openssl aes-256-cbc -salt -a -e -in plaintext.txt -out encrypted.txt
To decrypt:
openssl aes-256-cbc -salt -a -d -in encrypted.txt -out plaintext.txt
For Asymmetric encryption you must first generate your private key and extract the public key.
@stefanoverna
stefanoverna / app.rb
Created April 21, 2011 12:28
Sinatra GIT/SVN repository viewer (http://goo.gl/q4iiS)
%w(sinatra grit).each { |gem| require gem }
mime_type :binary, 'binary/octet-stream'
set :repo, Grit::Repo.new('/Users/steffoz/dev/richcomments')
before %r{^/(\w+)} do
commit_id = params[:captures].first[0..10]
@commit = settings.repo.commits(commit_id).first
halt "No commit exists with id #{commit_id}" if @commit.nil?
end
require "rubygems"
require "nokogiri"
class PlainTextExtractor < Nokogiri::XML::SAX::Document
attr_reader :plaintext
# Initialize the state of interest variable with false
def initialize
@interesting = false
@lackac
lackac / imstatus
Created March 19, 2010 10:57
Simple ruby script to set iChat/Adium/Skype status and status message
#!/usr/bin/env ruby
#
# Update iChat/Adium/Skype status
#
# USAGE: imstatus <online|available|offline|away|dnd|invisible> [message]
# (supports partial status identifiers like 'on' or 'aw')
#
# László Bácsi <lackac@icanscale.com>
# http://github.com/lackac
@gavinheavyside
gavinheavyside / trivial_file_upload_service.rb
Created November 3, 2009 20:09
Trivial file upload service using Sinatra
require 'rubygems'
require 'sinatra'
require 'fileutils'
# upload with:
# curl -v -F "data=@/path/to/filename" http://localhost:4567/user/filename
post '/:name/:filename' do
userdir = File.join("files", params[:name])
@denniskong
denniskong / check_memcache.rb
Created November 1, 2009 12:32
Nagios plugin to check memcached written in ruby
#!/usr/bin/env ruby
# check_memcached.rb ko.de.r.de@googlemail.com 20091101 v0.1
# Copyright 2009, Dennis Kong
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#