Skip to content

Instantly share code, notes, and snippets.

View ichadhr's full-sized avatar
Focusing

Chad ichadhr

Focusing
View GitHub Profile
#!/usr/bin/env bash
if [ ! -f package.json ]; then
echo "This script must be run from the ghost blog directory"
exit 1
fi
ZIP_URL=https://ghost.org/zip/ghost-latest.zip
PROJ_DIR=$(pwd)
TMP_DIR=$(mktemp -d -t ghost)
@ichadhr
ichadhr / postgres.bat
Last active October 7, 2019 15:48
Batch script Postgresql service
@ECHO OFF
CLS
goto CHECK
:CHECK
net session >nul 2>&1
if %errorLevel% == 0 (
goto :MENU
) else (
echo Checking permission privilege...
ping 1.1.1.1 -n 1 -w 500 > nul
@ichadhr
ichadhr / toggleAttr.js
Created June 5, 2015 09:56
Toggle Attribute jQuery
$.fn.toggleAttr = function(a, b) {
var c = (b === undefined);
return this.each(function() {
if((c && !$(this).is("["+a+"]")) || (!c && b)) $(this).attr(a,a);
else $(this).removeAttr(a);
});
};
@ichadhr
ichadhr / attach-pull-request.sh
Last active October 7, 2019 15:51 — forked from ihanson/attach-pull-request
Attaching a pull request to an existing GitHub issue
#!/usr/bin/env bash
read -p "GitHub username: " -ei $(git config --get github.user) USERNAME
read -sp "GitHub password: " PASSWORD
echo
read -p "Submit pull request to user: " TO_USER
read -p "Submit pull request to repository: " TO_REPO
read -p "Submit pull request to branch: " -ei master TO_BRANCH
read -p "Submit pull request from user: " -ei $USERNAME FROM_USER
read -p "Submit pull request from branch: " FROM_BRANCH
@ichadhr
ichadhr / gulp.md
Created August 23, 2015 17:54
Gulp static server

package.json

"devDependencies": {
    "connect-livereload": "^0.5.3",
    "express": "^4.13.3",
    "gulp": "^3.9.0",
    "gulp-autoprefixer": "^2.3.1",
    "gulp-concat": "^2.6.0",
    "gulp-jshint": "^1.11.2",
    "gulp-minify-css": "^1.2.0",
@ichadhr
ichadhr / rm-old-kern.sh
Created November 10, 2015 17:37
Removing Old Kernel Ubuntu
#!/bin/bash
# Remove old linux
echo $(dpkg --list | grep linux-image | awk '{ print $2 }' | sort -V | sed -n '/'`uname -r`'/q;p') $(dpkg --list | grep linux-headers | awk '{ print $2 }' | sort -V | sed -n '/'"$(uname -r | sed "s/\([0-9.-]*\)-\([^0-9]\+\)/\1/")"'/q;p') | xargs sudo apt-get -y purge
@ichadhr
ichadhr / vm-resize-hard-disk.md
Last active February 5, 2017 18:56 — forked from christopher-hopper/vm-resize-hard-disk.md
Resize a Hard Disk for a Virtual Machine provisioned using Vagrant from a Linux base box to run using VirtualBox.

Resize a Hard Disk for a Virtual Machine

Our Virtual Machines are provisioned using Vagrant from a Linux base box to run using VirutalBox. If the Hard Disk space runs out and you cannot remove files to free-up space, you can resize the Hard Disk using some VirtualBox and Linux commands.

Some assumptions

The following steps assume you've got a set-up like mine, where:

@ichadhr
ichadhr / url_to_drive.js
Created December 15, 2015 16:44 — forked from denilsonsa/url_to_drive.js
Google Apps Script to upload a file from an URL directly to Google Drive.
// url_to_drive.gs
// Google Apps Script
// Allows uploading a URL directly to Google Drive.
//
// Live link:
// https://script.google.com/macros/s/AKfycbzvhbHS4hnWPVBDHjQzZHA0qWq0GR-6hY7TbYsNto6hZ0MeAFZt/exec
//
// Source-code:
// https://gist.github.com/denilsonsa/8134679
// https://script.google.com/d/1Ye-OEn1bDPcmeKSe4gb0YSK83RPMc4sZJt79SRt-GRY653gm2qVUptoE/edit
#!/usr/bin/env bash
#
# Originally from https://gist.github.com/IanVaughan/2902499
#
# authors: Ian Vaughan
# Jacob Zimmerman
#
# usage: uninstall_gems [<version> ...]
#
# examples:
@ichadhr
ichadhr / jekyll-post-thor.md
Last active February 8, 2024 10:27
Jekyll create post with command

CREATE JEKYLL POSTS FROM THE COMMAND LINE

I got tired on creating new files manually for each new post a write so I put together this little command line task with Thor.

It creates a new file in the _posts directory with today’s date, parses the parameters to command as the post’s title and adds that as a slug to the new file. It then writes a default yaml template to the file (as specified in the script).

Running thor jekyll:new New and shiny post will for example create the file _posts/2012-12-28-new-and-shiny-post.markdown, populate it with an yaml template and finally open the file in my favorite editor.

HOW TO

Add the following to your Gemfile: