Skip to content

Instantly share code, notes, and snippets.

View serverhorror's full-sized avatar

serverhorror serverhorror

  • Earth
View GitHub Profile
@serverhorror
serverhorror / golang-buildTime-information.md
Last active July 26, 2019 13:59
How to embed information at build time
# PowerShell
go run `
  -ldflags="
    -X 'main.version=$(git name-rev --tags --name-only --always --no-undefined $(git rev-parse HEAD))' `
    -X 'main.commitInfo=$(if (git status --porcelain=v2 --untracked-files=no) {Write-Output "*"} else {Write-Output "clean"})' `
    -X 'main.buildTime=tomorrow.afternoon'" `
  .\playground\versionInject\main.go
python .\aws\test_templateIteration.py
Outputs:
Output0:
Description: Output0
Value: Output0
Output1:
Description: Output1
Value: Output1
Output2:
Description: Output2
#!/bin/bash
aws --no-verify-ssl ssm get-parameters-by-path --path /aws/service/ami-amazon-linux-latest
aws --no-verify-ssl ssm get-parameters-by-path --path /aws/service/ami-amazon-linux-latest --query 'Parameters[?Name==`/aws/service/ami-amazon-linux-latest/amzn2-ami-minimal-hvm-x86_64-ebs`]'
aws --no-verify-ssl ssm get-parameters-by-path --path /aws/service/ami-amazon-linux-latest --query 'Parameters[]|[?contains(Name, `ami-amazon-linux-latest/amzn2`)]'
aws --no-verify-ssl ssm get-parameters-by-path --path /aws/service/ami-amazon-linux-latest --query 'Parameters[]|[?contains(Name, `ami-amazon-linux-latest/amzn2`)]|[?Value==`ami-09693313102a30b2c`]'
aws --no-verify-ssl ssm get-parameters-by-path --path /aws/service/ami-amazon-linux-latest --query 'Parameters[]|[?contains(Name, `ami-amazon-linux-latest/amzn2`)]|[?Value!=`ami-09693313102a30b2c`]'
aws --no-verify-ssl ssm get-parameters-by-path --path /aws/service/ami-amazon-linux-latest --query 'Parameters[]|[?contains(Name, `ami-amazon-linux-latest/amzn2`)]|
@serverhorror
serverhorror / main.go
Created March 18, 2018 00:52 — forked from julz/main.go
containersched minicontainer
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
)
func main() {
WITH
sel AS (SELECT id, key, value FROM labels WHERE (key = 'sequencing_strandness' AND value = 'paired-end')),
ins AS (
INSERT INTO "labels"(key, value)
SELECT key, value
WHERE NOT EXISTS (SELECT 1 FROM sel)
RETURNING "id", key, value
)
SELECT * FROM ins UNION ALL SELECT * FROM sel
;
@serverhorror
serverhorror / jdk_download.sh
Created October 12, 2017 21:04 — forked from P7h/jdk_download.sh
Script to download JDK / JRE / Java binaries from Oracle website from terminal / shell / command line / command prompt
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
### Shell script to download Oracle JDK / JRE / Java binaries from Oracle website using terminal / command / shell prompt using wget.
### You can download all the binaries one-shot by just giving the BASE_URL.
### Script might be useful if you need Oracle JDK on Amazon EC2 env.
### Script is updated for every JDK release.
### Features:-
# 1. Resumes a broken / interrupted [previous] download, if any.
# 2. Renames the file to a proper name with including platform info.
This file has been truncated, but you can view the full file.
== 2017-06-23 07:58:18,322 easyblock.py:262 INFO This is EasyBuild 3.2.1 (framework: 3.2.1, easyblocks: 3.2.1) on host ip-10-4-79-235.localdomain.
== 2017-06-23 07:58:18,322 easyblock.py:268 INFO This is easyblock EB_R from module easybuild.easyblocks.r.r (/apps/prod/easybuild/software/EasyBuild/3.2.1/lib/python2.7/site-packages/easybuild_easyblocks-3.2.1-py2.7.egg/easybuild/easyblocks/r/r.pyo)
== 2017-06-23 07:58:18,323 easyblock.py:753 INFO Build dir set to /apps/prod/easybuild/build/R/3.4.0/foss-2015a-bare.perftest2
== 2017-06-23 07:58:18,323 easyblock.py:792 INFO Software install dir set to /apps/prod/easybuild/software/R/3.4.0-foss-2015a-bare.perftest2
== 2017-06-23 07:58:18,323 easyblock.py:797 INFO Module install dir set to /apps/prod/easybuild/modules/all
== 2017-06-23 07:58:18,323 easyblock.py:247 INFO Init completed for application name R version 3.4.0
== 2017-06-23 07:58:18,323 easyblock.py:2508 INFO Obtained application instance of for R (easyblock: None)
== 2017-06-23 07:58:18,324 build_log.py:22
@serverhorror
serverhorror / linecount.py
Created May 17, 2017 13:06
MemoryError -- But WHY!
import csv
import gzip
import os.path as path
for obj in fileObjects:
fObj = gzip.GzipFile(fileobj=obj, mode='rb')
csvWriter.writerow((path.basename(obj.name), sum(itertools.imap(bool, fObj))))
// Unsupported Pattern because of negative look-ahead
// PATTERN = "(.*?)((BI)-(\w+)-(\d{4}-\d{4}-\d{4}(?!-\d{4})))"
// Workaround?
for _, line := range lines {
// If we have 3 digit groups we found a candidate!
if match, _ := regexp.MatchString("(.*?)((BI)-(\w+)-(\d{4}-\d{4}-\d{4}", text); match == true {
// But if we have 4 digit groups this shouldn't be handled!
// This is what the negative lookahead would prevent in the first place
if match, _ := regexp.MatchString("(.*?)((BI)-(\w+)-(\d{4}-\d{4}-\d{4}-\d{4}", text); match == true {
package main
import (
"fmt"
"log"
"sync"
)
var (
wg sync.WaitGroup