Skip to content

Instantly share code, notes, and snippets.

@robertsky
robertsky / quick_directory_listing.rb
Created May 18, 2014 18:44
A quick cobbling of Ruby codes to do a directory listing of hard disk(s).
#name: quick_directory_listing.rb
#author: robertsky
#url: http://robertsky.com
#github: https://github.com/robertsky
#gem install sys-filesystem
#https://github.com/djberg96/sys-filesystem
require 'sys/filesystem'
curDir = Dir.pwd
@robertsky
robertsky / deploy.sh
Created October 13, 2015 07:59
Deploy WordPress plugin from git to wordpress.org repo. Adapted from https://github.com/pdclark/deploy-plugin-to-wordpress-dot-org
#! /bin/bash
# Source: https://raw.github.com/thenbrent/multisite-user-management/master/deploy.sh
# http://thereforei.am/2011/04/21/git-to-svn-automated-wordpress-plugin-deployment/
# A modification of Dean Clatworthy's deploy script as found here: https://github.com/deanc/wordpress-plugin-git-svn
# The difference is that this script lives in the plugin's git repo & doesn't require an existing SVN repo.
# main config
PLUGINSLUG=${PWD##*/} # returns basename of current directory
CURRENTDIR=`pwd`
MAINFILE="display-ssh.php" # this should be the name of your main php file in the wordpress plugin
@robertsky
robertsky / 30daysGoogleAnalytics.r
Created December 26, 2015 11:37
30 days look back from Google Analytics.
setwd("~/Documents/R/")
require(dplyr)
require(RGoogleAnalytics)
# Authorize the Google Analytics account
# This need not be executed in every session once the token object is created
# and saved
token <- Auth(client.id,client.secret)
# Save the token object for future sessions
@robertsky
robertsky / conf.d-site
Last active July 4, 2016 03:16
nginx wordpress
# Redirect everything to the main site. We use a separate server statement and NOT an if statement - see http://wiki.nginx.org/IfIsEvil
server {
server_name _;
rewrite ^ $scheme://example.com$request_uri redirect;
}
server {
listen 80;
server_name example.com www.example.com;
@robertsky
robertsky / SubstituteSpecialCharacters
Created December 7, 2018 07:18
URL encoding strings the manual way. Values to encode based on https://web.cs.dal.ca/~jamie/CS3172/examples/XHTML/entities/ASCII.html
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE("<><><text to convert here><><>", " ", "%20"), "!", "%21"), "CHAR(34)", "%22"), "#", "%23"), "$", "%24"), "%", "%25"), "&", "%26"), "'", "%27"), "(", "%28"), ")", "%29"), "*", "%2A"), "+", "%2B"), ",", "%2C"), "-", "%2D"), ".", "%2E"), "/", "%2F"), ":", "%3A"), ";", "%3B"), ">", "%3E"), "?", "%3F"), "@", "%40"), "[", "%5B"), "\", "%5C"), "]", "%5D"), "^", "%5E"), "_", "%5F"), "`", "%60"), "{", "%7B"), "}", "%7D"), "<", "%3C"), "=", "%3D"), "~", "%7E")
@robertsky
robertsky / timestamp.vb
Created December 11, 2018 06:16
Timestamp UDF Excel
Function Timestamp(Reference As Range)
If IsNumeric(Application.Caller.Text) = False Or Application.Caller.Text = "0" Then
If InStr(Reference.Value2, "generated correctly") > 0 Then
'Debug.Print (Application.Caller.Address & " test2")
Timestamp = CStr(DateDiff("s", "01/01/1970 00:00:00", Now()) * 1000 + Int(1000 * Rnd))
Else
'Debug.Print (Application.Caller.Address & " test1")
Timestamp = ""