Random query recipes of JMESPath for the AWS CLI tools that I might have written or stumbled upon.
This file contains hidden or 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
import sys | |
import csv | |
tabin = csv.reader(sys.stdin, dialect=csv.excel_tab) | |
commaout = csv.writer(sys.stdout, dialect=csv.excel) | |
for row in tabin: | |
commaout.writerow(row) |
This file contains hidden or 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
packer build packer.json 2>&1 | sudo tee output.txt | |
tail -2 output.txt | head -2 | awk 'match($0, /ami-.*/) { print substr($0, RSTART, RLENGTH) }' > sudo ami.txt |
This file contains hidden or 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
#!/usr/bin/env python | |
############### // gelfListener 0.2 // ############### | |
# | |
# Listens on UDP 12201 for Gelf messages | |
# Extracts the event data and writes the message to disk | |
# updated to handle both zlib (nxlog) and gzip (graylog server) compressed events | |
# not perfect, but works okay | |
# | |
# Bugs: |
This file contains hidden or 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
namespace Analogy | |
{ | |
/// <summary> | |
/// This example shows that a library that needs access to target .NET Standard 1.3 | |
/// can only access APIs available in that .NET Standard. Even though similar the APIs exist on .NET | |
/// Framework 4.5, it implements a version of .NET Standard that isn't compatible with the library. | |
/// </summary>INetCoreApp10 | |
class Example1 | |
{ | |
public void Net45Application(INetFramework45 platform) |
This file contains hidden or 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
set -o pipefail | |
_exit_error() { | |
message=$1 | |
code=$2 | |
echo "$message" >&2 | |
exit $code | |
} | |
_exit_ok() { |
This file contains hidden or 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
using System.Collections.Generic; | |
using Microsoft.AspNetCore.Mvc; | |
using System.IO; | |
namespace Asseco.Content.Controllers | |
{ | |
[Route("api/v1/content/")] | |
public class FolderController : Controller | |
{ | |
private JsonResult GetFileByPath(string repo, string folder, string file) |
This is a slightly stripped down version from our internal bug tracker. The point of posting this publicly is part FYI, part peer review. I'm hoping someone can look at this, disagree, and tell me all the downsides of using the C
locale or point out things I've misunderstood. The Recommendations
section in particular is contextualized by our database serving a SaaS product for users from many different locales, thus making locale a render level concern. YMMV, caveat emptor, etc.
Collation defines the character ordering for textual data. For Postgres, https://www.postgresql.org/docs/current/static/locale.html:
The locale settings influence the following SQL features:
- Sort order in queries using ORDER BY or the standard comparison operators on textual data
- The
upper
,lower
, andinitcap
functions
This file contains hidden or 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
// IMPORTANT | |
using System.Text; | |
// This gist was created thanks to this comment from Alexander on StackOverflow: | |
// https://stackoverflow.com/questions/249087/how-do-i-remove-diacritics-accents-from-a-string-in-net#comment86833005_34272324 | |
// This is a derivative work. The logic of this function comes from a switch statement found inside the | |
// Lucene.Net library. The documentation of the conversion of characters is quite impressive | |
// (thank you @NightOwl888 and @synhershko !!!): | |
// https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ASCIIFoldingFilter.cs |