Skip to content

Instantly share code, notes, and snippets.

@lizthegrey
lizthegrey / attributes.rb
Last active February 24, 2024 14:11
Hardening SSH with 2fa
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
@ElJefeDSecurIT
ElJefeDSecurIT / boxstarter.ps1
Last active September 27, 2023 17:33 — forked from jessfraz/boxstarter.ps1
Boxstarter Commands for a new Windows box.
# Description: Boxstarter Script
# Author: ElJefeDSecurIT
# Last Updated: 2017-10-10
#
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
#
# You might need to set: Set-ExecutionPolicy RemoteSigned
#
# Run this boxstarter by calling the following from an **elevated** command-prompt:
@jessfraz
jessfraz / boxstarter.ps1
Last active April 11, 2024 16:02
Boxstarter Commands for a new Windows box.
# Description: Boxstarter Script
# Author: Jess Frazelle <jess@linux.com>
# Last Updated: 2017-09-11
#
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
#
# You might need to set: Set-ExecutionPolicy RemoteSigned
#
# Run this boxstarter by calling the following from an **elevated** command-prompt:
1. Setup a project
2. Add groovy SDK support:
https://www.bonusbits.com/wiki/HowTo:Add_Groovy_SDK_to_IntelliJ_IDEA
3. Download http://(yourjenkinsurl)/job/(yourpipelinejob)/pipeline-syntax/gdsl
- this will give you the .gdsl file - download this to the src folder of your project.
4. Finally follow this step - right click on the src folder -> Mark directory as -> Sources Root
@vladfau
vladfau / post.groovy
Last active July 15, 2021 06:35
Sending POST + JSON Body + Auth - Libs in Java/Groovy (e.g. create tag on GitHub)
import groovy.json.JsonOutput
import java.io.BufferedWriter
import java.io.OutputStreamWriter
import java.net.URL
import java.util.Scanner
def url = new URL("https://${github}/api/v3/repos/${org}/${repo}/git/refs")
def urlConnection = url.openConnection()
urlConnection.setDoOutput(true)
@thorntonrose
thorntonrose / RestClient.groovy
Last active August 12, 2022 08:45
Simple Groovy REST client
class RestClient {
def proxy = Proxy.NO_PROXY
def basicAuth
// ???: Bake this into request()?
static def encodePath(path) {
path.replaceAll(" ", "%20")
}
def getContent(String url) {
@mgrebenets
mgrebenets / bitbucket-branches-job-dsl.groovy
Created June 8, 2015 01:02
Jenkins Job DSL Example - Bitbucket Branches
//
// Jenkins Job DSL example to create build projects for Bitbucket branches
//
// Imports
import java.text.DateFormat
import java.text.SimpleDateFormat
import groovy.time.TimeCategory
// URL components
@mattjbarlow
mattjbarlow / gist:242b66cdae6938d34419
Created December 22, 2014 15:40
Chef Shell in Test Kitchen
cd into /tmp/kitchen.
/opt/chef/embedded/bin/gem install chef-zero
/opt/chef/embedded/bin/chef-zero -d
knife cookbook upload -a -c client.rb
chef-shell -z -c client.rb -o '<YOUR RECIPE>'
@dmkash
dmkash / br.sh
Created April 10, 2012 22:44
Shell Script for tmux setup
#!/bin/sh
SESSION_NAME="big_red"
cd ~/Sites/within3/big_red
tmux has-session -t ${SESSION_NAME}
if [ $? != 0 ]
then
@jbgo
jbgo / git-recover-branch.md
Last active March 29, 2024 05:04
How to recover a git branch you accidentally deleted

UPDATE: A better way! (August 2015)

As pointed out by @johntyree in the comments, using git reflog is easier and more reliable. Thanks for the suggestion!

 $ git reflog
1ed7510 HEAD@{1}: checkout: moving from develop to 1ed7510
3970d09 HEAD@{2}: checkout: moving from b-fix-build to develop
1ed7510 HEAD@{3}: commit: got everything working the way I want
70b3696 HEAD@{4}: commit: upgrade rails, do some refactoring