Skip to content

Instantly share code, notes, and snippets.

View Erutan409's full-sized avatar

Michael Keyser Erutan409

  • Grand Rapids, MI
View GitHub Profile
@Erutan409
Erutan409 / MimeType.php
Last active February 15, 2022 18:10
Mime Type Function for PHP
<?php
function mime_type($file) {
// there's a bug that doesn't properly detect
// the mime type of css files
// https://bugs.php.net/bug.php?id=53035
// so the following is used, instead
// src: http://www.freeformatter.com/mime-types-list.html#mime-types-list
@Erutan409
Erutan409 / Miscellaneous.psm1
Last active January 17, 2016 00:59
Miscellaneous Powershell functions for making my life easier
Function Get-AbsolutePath {
<#
.SYNOPSIS
Get the absolute path.
.DESCRIPTION
Provides a simple way for transforming any path, relative or not,
into an absolute path. If no path is specified, the current working
@Erutan409
Erutan409 / pma-db-select-bookmarklet.js
Last active July 25, 2016 01:59
phpMyAdmin - Bookmarklet for quickly selecting database(s) on a search string
/**
* Will not select system databases (greyed out)
* Works with regular expressions:
* '^te' -> matches 'test' database
* '^est' -> will NOT match 'test' database
*
* I created this to easily drop numerous databases
* that are part of a large system, such as 'phabricator.'
*/
@Erutan409
Erutan409 / vpnserver.conf
Last active August 15, 2021 22:59 — forked from ann0see/vpnserver.conf
Fail2ban filter for SoftEther VPN server
# Fail2Ban filter for SoftEther authentication failures
# Made by quixrick and jonisc
# Thanks to quixrick from Reddit! https://reddit.com/u/quixrick
# Further reference: http://www.vpnusers.com/viewtopic.php?f=7&t=6375&sid=76707e8a5a16b0c9486a39ba34763901&view=print
[INCLUDES]
# Read common prefixes. If any customizations available -- read them from
# common.local
before = common.conf
@Erutan409
Erutan409 / object-watch.js
Last active March 14, 2018 13:43 — forked from eligrey/object-watch.js
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
* Modified by Michael Keyser
* 2018-03-14
@Erutan409
Erutan409 / grid-push-pull.less
Last active May 11, 2018 14:20 — forked from Evanion/grid-push-pull.less
Responsive push/pull for uikit
/* Small */
@media (min-width: 480px) {
[class*='uk-push-small-'],
[class*='uk-pull-small-'] { position: relative; }
/*
* Push
*/
@Erutan409
Erutan409 / git_submodules.md
Created June 30, 2018 18:08 — forked from gitaarik/git_submodules.md
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of advantages of using submodules:

  • You can separate the code into different repositories.
@Erutan409
Erutan409 / gist:0da019b0da9e56f2972c23d78d11404e
Created July 16, 2018 16:18 — forked from jimkutter/gist:1370525
List of US States in a PHP array
<?php
array(
'AL' => 'Alabama',
'AK' => 'Alaska',
'AZ' => 'Arizona',
'AR' => 'Arkansas',
'CA' => 'California',
'CO' => 'Colorado',
'CT' => 'Connecticut',
@Erutan409
Erutan409 / wp_insert_attachment_from_url.php
Created September 17, 2018 20:08 — forked from m1r0/wp_insert_attachment_from_url.php
WP: Insert attachment from URL
<?php
/**
* Insert an attachment from an URL address.
*
* @param String $url
* @param Int $parent_post_id
* @return Int Attachment ID
*/
function crb_insert_attachment_from_url($url, $parent_post_id = null) {
@Erutan409
Erutan409 / gist:cb21f0f4967c2ce32258108c1f0b76a4
Created September 18, 2018 20:42 — forked from hissy/gist:7352933
[WordPress] Add file to media library programmatically
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,