Skip to content

Instantly share code, notes, and snippets.

View dragon788's full-sized avatar

dragon788 dragon788

View GitHub Profile
@JosephPecoraro
JosephPecoraro / shell-execution.rb
Last active September 10, 2023 10:12
Shell Execution in Ruby
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Synchronous (blocking)
# Returns the output of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
@mitchellh
mitchellh / gist:1277049
Created October 11, 2011 01:30
Configure Vagrant VM to use Host DNS for VPN
Vagrant::Config.run do |config|
# ...
config.vm.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
@wpivotto
wpivotto / gist:3993502
Created November 1, 2012 13:02
Maximize VMWare images performance
Insert the following code into the *.VMX file:
sched.mem.pshare.enable = "FALSE"
mainMem.useNamedFile = "FALSE"
prefvmx.minVmMemPct = "100"
prefvmx.useRecommendedLockedMemSize = "TRUE"
mainMem.partialLazySave = "FALSE"
mainMem.partialLazyRestore = "FALSE"
priority.grabbed = "high"
priority.ungrabbed = "normal"
@TemporaryJam
TemporaryJam / Howto convert a PFX to a seperate .key & .crt file
Last active April 4, 2024 10:52
How to convert a .pfx SSL certificate to .crt/key (pem) formats. Useful for NGINX
source: http://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/
`openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]`
What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file. This is the password that you used to protect your keypair when you created your .pfx file. If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!. Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file.
Now let’s extract the certificate:
`openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]`
@P7h
P7h / tmux__CentOS__build_from_source.sh
Last active November 22, 2023 11:28
tmux 2.0 and tmux 2.3 installation steps for Ubuntu. Or build from tmux source v2.5 for Ubuntu and CentOS.
# Steps to build and install tmux from source.
# Takes < 25 seconds on EC2 env [even on a low-end config instance].
VERSION=2.7
sudo yum -y remove tmux
sudo yum -y install wget tar libevent-devel ncurses-devel
wget https://github.com/tmux/tmux/releases/download/${VERSION}/tmux-${VERSION}.tar.gz
tar xzf tmux-${VERSION}.tar.gz
rm -f tmux-${VERSION}.tar.gz
cd tmux-${VERSION}
@mattgray
mattgray / .kitchen.local.yml
Created December 23, 2014 17:10
Test Kitchen .kitchen.local.yml to enable Virtualbox Vagrant backend to use Host DNS for VPN
driver:
name: vagrant
customize:
natdnshostresolver1: 'on'
@PuKoren
PuKoren / digicert_to_aws.sh
Created January 10, 2015 14:20
Upload Digicert certificate to Amazon Web Services (AWS)
#!/bin/sh
# $1: certificate name on AWS
# $2: certificate file (crt)
# $3: private key file (pem)
# $4: DigicertCA2 path
# $5: TrustedRoot path
# Download certificates on Digicert (Other formats > Individual crt files with a .cer extension)
# Generate intermediate cert for AWS (not an option, many browsers requires it it). Intermediate is concatenation of CA and Root certs
(openssl x509 -inform PEM -in $4; openssl x509 -inform PEM -in $5) > Intermediate.cer
@dfinke
dfinke / ConvertFrom-JsonToCsv.ps1
Created February 16, 2015 14:28
Using PowerShell to Convert From JSON to CSV format
function ConvertFrom-JsonToCsv {
param(
[Parameter(ValueFromPipeline)]
$json
)
Process {
($json | ConvertFrom-Json) | ConvertTo-Csv -NoTypeInformation
}
}
@weipah
weipah / import-portatour.ps1
Last active March 4, 2024 22:34
PowerShell V3 Multipart/formdata example with REST-API (Invoke-RestMethod)
function Import-Portatour {
param (
[parameter(Mandatory=$True,Position=1)] [ValidateScript({ Test-Path -PathType Leaf $_ })] [String] $FilePath,
[parameter(Mandatory=$False,Position=2)] [System.URI] $ResultURL
)
# CONST
$CODEPAGE = "iso-8859-1" # alternatives are ASCII, UTF-8
# We have a REST-Endpoint
$RESTURL = "https://my.portatour.net/a/api/ImportCustomers/"
@jamesallen-cm
jamesallen-cm / DSCBoxstarter
Last active August 17, 2016 18:53
DSC Boxstarter Links
Open a Powershell prompt and paste one of the following commands.
SERVER:
START http://boxstarter.org/package/nr/url?https://gist.githubusercontent.com/jamesallen-cm/2d08e881944da3cbcca6/raw/99c57af98e8966ff9b04dde7ba68fefd9681e647/DSCPullServerBootstrap-February
NODE:
START http://boxstarter.org/package/nr/url?https://gist.githubusercontent.com/jamesallen-cm/627f076abeea333f520b/raw/63e15135a68129d3216910400b236b2cdc0b29e0/DSCNodeBootstrap-February