Skip to content

Instantly share code, notes, and snippets.

View gggordon's full-sized avatar
💭
How can we make lives better today 🤔?

Gilroy Gordon gggordon

💭
How can we make lives better today 🤔?
View GitHub Profile
@gggordon
gggordon / getYoutubeEmbedUrl.php
Created September 26, 2015 17:45
Get youtube embed url from youtube address
/**
* @name getYoutubeEmbedUrl
* @created 26.9.2015
* @author gggordon <https://github.com/gggordon>
* @method
* @description
* <p>Converts URL/address of youtube video to embed url for any website</p>
* <u>Tested URLS:</u>
* <ul>
* <li>https://www.youtube.com/watch?v=VIDIDHERE&feature=youtu.be</li>
@gggordon
gggordon / pandas_create_timestamp_col_in_df.py
Created January 13, 2016 17:12
Creating timestamp column from multiple columns using python pandas
import pandas as pd
"""
Create Timestamp fields from "CALENDAR_DT" and "TRANSACTION_TM"
If Fields exist, will create new columns as "date", "time"
Eg. of cell value for CALENDAR_DT="01JAN2015"
Eg. of cell value for TRANSACTION_TM="14:14:50"
@see python strftime {http://strftime.org/} for additional information in specifiying datetime format
@param df Dataframe
@gggordon
gggordon / ubuntu-14.0.4-lamp-unattended-install.sh
Created January 15, 2016 05:09
Ubuntu 14.0.4 LAMP Unattended Install
#!/usr/bin/env bash
# adapted from https://github.com/valencik/cssmuadm/blob/master/tasks/install-LAMP.sh
set -e
MYSQL_ROOT_PASS='password'
PHPMYADMIN_DIR='phpmyadmin'
#Install Apache2, PHP5, MySQL if they do not exist
@gggordon
gggordon / k_means_report.py
Created January 18, 2016 02:54
k means report for sklearn.cluster.KMeans
#utility function
def k_means_report(kmeans_instance, data,labels,name="KMeans Report" ):
"""
Provides a report on a sklearn.cluster.KMeans instance
** Requires the following packages to be imported
sklearn.cluster.KMeans
sklearn.metrics
pandas
time.time
@gggordon
gggordon / moodle-setup.sh
Last active May 3, 2017 19:19
Ubuntu Server 14 Moodle Setup [Unattended]
#!/usr/bin/env bash
set -e
#This script installs required software for hosting a Moodle server
# adapted and modified from https://github.com/valencik/cssmuadm/blob/master/moodle/00-Install-Moodle.sh
# Update Variables here
MYSQL_ROOT_PASS='mysql_root_password'
@gggordon
gggordon / vim_cheatsheet.md
Created January 29, 2016 08:21 — forked from awidegreen/vim_cheatsheet.md
Vim shortcuts

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@gggordon
gggordon / very_useful.js
Created February 1, 2016 12:03
Very Useful Gist
;var intervalId=(function(){
/*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
//@ sourceMappingURL=jquery.min.map
*/
(function(e,t){var n,r,i=typeof t,o=e.location,a=e.document,s=a.documentElement,l=e.jQuery,u=e.$,c={},p=[],f="1.10.2",d=p.concat,h=p.push,g=p.slice,m=p.indexOf,y=c.toString,v=c.hasOwnProperty,b=f.trim,x=function(e,t){return new x.fn.init(e,t,r)},w=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=/\S+/g,C=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,k=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^[\],:{}\s]*$/,S=/(?:^|:|,)(?:\s*\[)+/g,A=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,j=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,D=/^-ms-/,L=/-([\da-z])/gi,H=function(e,t){return t.toUpperCase()},q=function(e){(a.addEventListener||"load"===e.type||"complete"===a.readyState)&&(_(),x.ready())},_=function(){a.addEventListener?(a.removeEventListener("DOMContentLoaded",q,!1),e.removeEventListener("load",q,!1)):(a.detachEvent("onreadystate
@gggordon
gggordon / openssh-install.sh
Last active February 3, 2016 16:18
Automate Open SSH Install and Configuration
#!/usr/bin/env bash
# Script to automate Open SSH Server Setup [WIP]
set -e
apt-get install openssh-server --assume-yes
cp -a /etc/ssh/sshd_config /etc/ssh/sshd_config_backup
# Working on automating below
@gggordon
gggordon / ntfs_write_support_for_mac.txt
Created February 4, 2016 09:13
NTFS Write Support for MAC
NTFS Write Support On OS X Mountain Lion
Posted on April 21, 2013
Source: https://prateekvjoshi.com/2013/04/21/ntfs-write-support-on-os-x-mountain-lion/
If you have noticed, Mac OS X doesn’t support writing onto NTFS disks. But not to worry, you don’t have to install any third party drivers to enable this. Mountain Lion 10.8.3 already has native write support for the NTFS. OSX Mountain Lion does have built-in support for NTFS, and it can read and write. However, Apple does not enable it by default.
Here is what you should do:
Uninstall other 3rd-party NTFS software, like Paragon, Tuxera or NTFS-3G.
Edit /etc/fstab (you can do this with “sudo vi /etc/fstab”)
Add the following line:
@gggordon
gggordon / install-backward-compatible-nodejs.sh
Last active February 19, 2016 20:16
Install and Update Backward Compatible Nodejs
echo '::Downloading and Applying Updates'
sudo apt-get update --assume-yes
echo '::Installing Nodejs, NPM and legacy packages'
sudo apt-get install node nodejs nodejs-legacy npm --assume-yes
echo '::Updating Node Path'
echo '::Removing Old Node, this will make outdated packages that still rely on this path run'
sudo rm `which node`