Skip to content

Instantly share code, notes, and snippets.

@ajorpheus
ajorpheus / jenkins-docker-slaves.groovy
Created April 4, 2019 12:54 — forked from adrianlzt/jenkins-docker-slaves.groovy
Automatically configure the docker cloud in Jenkins (/var/lib/jenkins/init.groovy.d/jenkins-docker-slaves.groovy).
#!groovy
/*
* Automatically configure the docker cloud in Jenkins.
* Tested with:
* - {name: 'docker-plugin' ver: '1.1.2'}
*
* Based on: https://gist.github.com/stuart-warren/e458c8439bcddb975c96b96bec3971b6
*/
import jenkins.model.*;
// ==UserScript==
// @name gist: replace title with filename
// @namespace http://d.hatena.ne.jp/youpy/
// @include http://gist.github.com/*
// @include https://gist.github.com/*
// @exclude http://gist.github.com/gists
// @exclude https://gist.github.com/gists
// @require https://gist.github.com/3242.txt
// ==/UserScript==
@ajorpheus
ajorpheus / jq-filters.sh
Created May 13, 2019 12:07 — forked from pedroxs/jq-filters.sh
jq - recursive search for keys containing "string" stripping empty results
# recursive search for keys containing "string" stripping empty results
jq '.. | objects | with_entries(select(.key | contains("ftp"))) | select(. != {})'
# same, but output propper array
jq '[ .. | objects | with_entries(select(.key | contains("ftp"))) | select(. != {}) ]'
# or
jq 'map( .. | objects | with_entries(select(.key | contains("ftp"))) | select(. != {}) )'
# transform input from {type: a, amount: 1} to {a: 1} and sum all values by type
jq '[ .[] | {(.type): .amount} ] | map(to_entries) | add | group_by(.key) | map({key: .[0].key, value: map(.value) | add}) | from_entries'
@ajorpheus
ajorpheus / ns-inet.sh
Created June 18, 2019 11:37 — forked from dpino/ns-inet.sh
Setup a network namespace with Internet access
#!/usr/bin/env bash
set -x
NS="ns1"
VETH="veth1"
VPEER="vpeer1"
VETH_ADDR="10.200.1.1"
VPEER_ADDR="10.200.1.2"
@ajorpheus
ajorpheus / AllowSSHFromIP.php
Created July 1, 2019 16:30 — forked from HSPDev/AllowSSHFromIP.php
Complementary code and IAM policy for "You don't need that Bastion host"
<?php
// For laravel 5 based systems
// /path/to/project/app/Console/Commands/AllowSSHFromIP.php
namespace App\Console\Commands;
use Aws\Ec2\Ec2Client;
use Carbon\Carbon;
use Illuminate\Console\Command;
@ajorpheus
ajorpheus / 0.12.tf
Created August 27, 2019 09:41 — forked from tuannvm/0.12.tf
#terraform #hashicorp #cheatsheet #0.12
# first class expresssion
variable "ami" {}
resource "aws_instance" "example" {
ami = var.ami
}
###
# list & map
resource "aws_instance" "example" {
@ajorpheus
ajorpheus / cloudTrailEventNames.list
Created September 5, 2019 14:39 — forked from pkazi/cloudTrailEventNames.list
List of values for parameter EventName in AWS Cloudtrail events
AbortDocumentVersionUpload
AbortEnvironmentUpdate
AbortMultipartUpload
AbortVaultLock
AcceptAccountMapping
AcceptCertificateTransfer
AcceptDelegate
AcceptDirectConnectGatewayAssociationProposal
AcceptFxPaymentCurrencyTermsAndConditions
AcceptHandshake
@ajorpheus
ajorpheus / terraforming-import-all
Created October 18, 2019 11:48 — forked from neurogenesis/terraforming-import-all
generate terraform templates from existing infrastructure (via terraforming)
#!/usr/bin/env ruby
# USAGE:
# gem install terraforming
# export AWS_PROFILE=xxx
# mkdir -p ~/projects/terraform
# cd ~/projects/terraform
# mkdir -p imports/[account]/[region]
# cd imports/[account]/[region]
# ../../../bin/terraforming-import-all
[Unit]
Description=sshuttle service
After=network.target
[Service]
User=sshuttle
Restart=always
Type=forking
WorkingDirectory=/home/sshuttle
ExecStart=/home/sshuttle/sshuttle.sh start

Note

Apple will reject apps that are using private url schemes (Ugh, Apple....) if they are pretty much obvius. Some apps are rejected and others are not, so, be aware of this issue before implementing any of those URL's in your app as a feature.

Updates

  • [UPDATE 4] iOS 10 update: apparently settings now can be reached using App-Pref instead of prefs
  • [UPDATE 3] For now you just can use url schemes to open your apps's settings with Swift 3.0 (Xcode 8). I'll keep you informed when OS preferences can be reached
  • [UPDATE 2] The openURL() method of UIApplication is now deprecated. You should use application(_:open:options:) instead
  • [UPDATE 1] Not yet tested in iOS 10. It will fail because of policies changes in URL scheme handling.