Skip to content

Instantly share code, notes, and snippets.

View ultimagriever's full-sized avatar
🏠
Working from home

Pamela Argentino ultimagriever

🏠
Working from home
View GitHub Profile
APP_DEV=static.intermail.dev.$1.jp7.com.br
echo "Creating S3 development bucket " $APP_DEV"...\n"
aws s3api create-bucket --bucket $APP_DEV --region us-east-1
echo "Setting Static Web Hosting...\n"
aws s3api put-bucket-website --bucket $APP_DEV --website-configuration file://website-config.json
echo "Bucket" $APP_DEV "created, visit AWS Console to create IAM user for said bucket.\n"
APP_QA=static.intermail.qa.$1.jp7.com.br
<?php
// php -f export-aws-s3-wordpress.php <host> <db> <user> <password> <url> <bucket> [ --dry-run]
array_shift($argv);
list($host, $db, $user, $pass, $url, $bucket, $dryrun) = $argv;
$cmd = 'wp search-replace "' . $url . '/wp-content/uploads" "' . $bucket . '/wp-content/uploads" --url=' . $url . ' --network ' . $dryrun;
echo $cmd . PHP_EOL;
echo shell_exec($cmd) . PHP_EOL;
@ultimagriever
ultimagriever / nginx.sh
Created June 28, 2016 18:54
Automatic Nginx Server Block Generation
# sh nginx.sh <app name>
APP=$1
if [[ $APP == "" ]]; then
echo "Please provide app name."
exit;
fi
NGINX_PATH=/usr/local/etc/nginx
cp $NGINX_PATH/sites-enabled/template.dev $NGINX_PATH/sites-enabled/$APP.dev
sed -i '' "s/app/$APP/g" $NGINX_PATH/sites-enabled/$APP.dev
echo "Config created for $APP"
@ultimagriever
ultimagriever / nginx.sh
Last active June 29, 2016 13:31
nginx-new.sh
NGINX_PATH=/usr/local/etc/nginx
for f in ~/Sites/*; do
if [ -d $f ]; then # Is a directory
NGINX_CONF="$NGINX_PATH/sites-enabled/$(basename $f).dev"
echo $NGINX_CONF
cp $NGINX_PATH/template.dev $NGINX_CONF
@ultimagriever
ultimagriever / install.sh
Last active October 6, 2017 18:16
Start PhantomJS server as a Linux service
export TMPDIR=/tmp/
cd /usr/local/lib
mkdir phantom
cd phantom
wget https://gist.githubusercontent.com/ultimagriever/72fcb3e4446460638d65aecd2fbee98c/raw/9d915c60921219900b60c64cf5379c54d63ca43c/restart.sh
wget https://gist.githubusercontent.com/ultimagriever/72fcb3e4446460638d65aecd2fbee98c/raw/9d915c60921219900b60c64cf5379c54d63ca43c/start.sh
wget https://gist.githubusercontent.com/ultimagriever/72fcb3e4446460638d65aecd2fbee98c/raw/9d915c60921219900b60c64cf5379c54d63ca43c/status.sh
wget https://gist.githubusercontent.com/ultimagriever/72fcb3e4446460638d65aecd2fbee98c/raw/9d915c60921219900b60c64cf5379c54d63ca43c/stop.sh
chmod +x *.sh
ln -s /usr/local/lib/phantom/restart.sh /usr/local/bin/phantom-restart
@ultimagriever
ultimagriever / self-signed-certificate.sh
Last active August 7, 2020 18:44
Generate self-signed certificate in Mac OS
# sh self-signed-certificate.sh [domain_name]
DOMAIN_NAME=$1
openssl req -new -subj "/C=/ST=/O=/localityName=/commonName=$DOMAIN_NAME/organizationalUnitName=/emailAddress=/" \
-addext "subjectAltName = DNS:www.$DOMAIN_NAME" \
-newkey rsa:4096
-keyout $DOMAIN_NAME.key -out $DOMAIN_NAME.csr
openssl x509 -req -days 365 -in $DOMAIN_NAME.csr -signkey $DOMAIN_NAME.key -out $DOMAIN_NAME.crt
openssl rsa -in $DOMAIN_NAME.key -out $DOMAIN_NAME.key
@ultimagriever
ultimagriever / migrate.js
Created August 26, 2016 15:33
Migrate Mongo -> Firebase
/**
* Migrate MongoDB database to Firebase.
* Syntax: node migrate.js [-c || --collection=]<MongoDB Collection> [ [-h || --host=]<MongoDB URI>]
* If no args are provided, the MONGODB_URI
* env variable declared in the .env file
* will be used instead.
*/
const env = require('dotenv');
const firebase = require('firebase');
@ultimagriever
ultimagriever / configuration.sh
Created September 28, 2016 20:09
Automatically start Countdown development servers
chmod +x countdown.sh
ln -s $HOME/countdown.sh /usr/local/bin/countdown
@ultimagriever
ultimagriever / parse.sh
Last active October 18, 2016 15:57
Parse environment files
ENV_FILE=$1
while read -r line
do
IFS="=" read -ra keys <<< "$line"
travis env set ${keys[0]} ${keys[1]} --private --no-interactive
done < $ENV_FILE
@ultimagriever
ultimagriever / export.php
Last active December 2, 2016 20:17
Export WordPress Multisite to Single Site
<?php
define("GLOBAL_URL", "insert your wordpress master url here, e.g. master domain");
// Export master blog without comments - handled by Facebook plugin
exec('wp export --url="' . GLOBAL_URL . '" --skip_comments --filename_format="{site}.{date}.xml"');
$sites = shell_exec("wp site list --url=\"" . GLOBAL_URL . "\" --field=url");
$sites = explode(PHP_EOL, $sites);
foreach ($sites as $site) {
$url = str_replace("http://", "", $site);