Skip to content

Instantly share code, notes, and snippets.

@nom3ad
nom3ad / ForkMITLicensedProject.md
Created April 30, 2021 07:16 — forked from fbaierl/ForkMITLicensedProject.md
HOWTO fork a MIT licensed project

No, you are not allowed to change the copyright notice. Indeed, the license text states pretty clearly:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

But you are allowed to add a copyright notice.

If you want to keep the MIT license, which is what I would advise you to do, you only need to add a single line to the license file, before or after Copyright (c) 2012 Some Name with your own copyright notice. The final LICENSE file will look like this:

The MIT License (MIT)

@nom3ad
nom3ad / parseJson.groovy
Created April 11, 2021 08:31 — forked from mig82/parseJson.groovy
How to parse json into a serializable HashMap in Jenkins Groovy
@NonCPS
def parseJson(txt){
def lazyMap = new groovy.json.JsonSlurper().parseText(txt)
def map = [:]
for ( prop in lazyMap ) {
map[prop.key] = prop.value
}
return map;
}
@nom3ad
nom3ad / Jenkinsfile.groovy
Created April 9, 2021 16:35 — forked from Faheetah/Jenkinsfile.groovy
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"
#!/bin/bash
# Run in go using -
# <exec command="bash">
# <arg>-c</arg>
# <arg>curl -s https://gist.githubusercontent.com/ketan/2866a236596636311d64/raw/ansi-color-test.sh | bash</arg>
# </exec>
echo "<script>console.log('42')</script>"
@nom3ad
nom3ad / translate.go
Created February 20, 2021 03:56 — forked from hvoecking/translate.go
Golang reflection: traversing arbitrary structures
// Traverses an arbitrary struct and translates all stings it encounters
//
// I haven't seen an example for reflection traversing an arbitrary struct, so
// I want to share this with you. If you encounter any bugs or want to see
// another example please comment.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Heye Vöcking
//

Sometimes you want to retrieve EC2 insntances' region information.

You can query that information through instance metadata(169.254.169.254).

$ curl --silent http://169.254.169.254/latest/dynamic/instance-identity/document
{
  "privateIp" : "172.31.2.15",
  "instanceId" : "i-12341ee8",
  "billingProducts" : null,
 "instanceType" : "t2.small",
@nom3ad
nom3ad / deploy.sh
Created October 28, 2020 07:41 — forked from jed/deploy.sh
Using AWS CloudFormation to deploy an edge lambda
#!/bin/sh
aws cloudformation deploy \
--template-file stack.yaml \
--stack-name edge-lambda-test \
--capabilities CAPABILITY_IAM \
--parameter-overrides Nonce=$RANDOM
# serverless.yml
service:
name: myService
awsKmsKeyArn: arn:aws:kms:us-east-1:XXXXXX:key/some-hash # Optional KMS key arn which will be used for encryption for all functions
frameworkVersion: ">=1.0.0 <2.0.0"
provider:
name: aws
@nom3ad
nom3ad / bulk-move-gitlab-issues-snippet.js
Last active October 18, 2020 16:24
bulk move issues in gitlab
var time = 500;
jQuery(".issues-list > li").each(function(index, element) {
setTimeout(function() {
var url = jQuery(element).attr('url');
$.ajax({
type: "POST",
url: "https://repo.forgottenlands.eu"+url+"/move", // Replace with your base url
data: { move_to_project_id: 28 }, // replace with your project id
success: function() { console.log('OK'); }
properties [
[
$class: 'ParametersDefinitionProperty', parameterDefinitions: [
[
$class: 'ChoiceParameterDefinition', choices: ['plan', 'apply'], description: 'When this job is invoked directly, action that TF will perform', name: 'tf_action'
],
[
$class: 'GitParameterDefinition', branch: '', branchFilter: '.*', defaultValue: 'master', description: 'Branch to use for plan when this job is invoked directly. This is ignored and always "master" when tf_action is apply', name: 'git_branch', quickFilterEnabled: true, sortMode: 'ASCENDING_SMART', tagFilter: '*', type: 'PT_BRANCH'
]