Skip to content

Instantly share code, notes, and snippets.

View jalbertbowden's full-sized avatar

albert jalbertbowden

View GitHub Profile
@jalbertbowden
jalbertbowden / domIsReady.js
Created August 6, 2019 12:32 — forked from devbyray/domIsReady.js
Vanilla JavaScript Document Ready (Cross-Browser)
var domIsReady = (function(domIsReady) {
var isBrowserIeOrNot = function() {
return (!document.attachEvent || typeof document.attachEvent === "undefined" ? 'not-ie' : 'ie');
}
domIsReady = function(callback) {
if(callback && typeof callback === 'function'){
if(isBrowserIeOrNot() !== 'ie') {
document.addEventListener("DOMContentLoaded", function() {
return callback();
@jalbertbowden
jalbertbowden / php_mailer.php
Created August 5, 2019 06:13 — forked from andrewflash/php_mailer.php
Using PHP Mailer to Send HTML Emails with Images
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp1.example.com;smtp2.example.com";
$mail->SMTPAuth = true;
$mail->Username = 'smtpusername';
$mail->Password = 'smtppassword';
$mail->From="[email protected]";
import os
import urllib.request
import urllib.parse
SLACK_API_ENDPOINT = 'https://slack.com/api/users.admin.invite'
HEADERS = {
'Access-Control-Allow-Origin': os.environ['ALLOWED_ORIGIN'],
'Access-Control-Allow-Credentials': 'true'
}
@jalbertbowden
jalbertbowden / php-style-guide.md
Created July 2, 2019 01:32 — forked from ryansechrest/php-style-guide.md
PHP style guide with coding standards and best practices.

PHP Style Guide

All rules and guidelines in this document apply to PHP files unless otherwise noted. References to PHP/HTML files can be interpreted as files that primarily contain HTML, but use PHP for templating purposes.

The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Most sections are broken up into two parts:

  1. Overview of all rules with a quick example
  2. Each rule called out with examples of do's and don'ts
@jalbertbowden
jalbertbowden / make_gdrive_index.py
Created June 26, 2019 02:57 — forked from cmungall/make_gdrive_index.py
Generate HTML index of a synced google drive folder. For me this is faster to search and navigate than the clunky slow google web interface. Pretty hacky code but it works for me
#!/usr/bin/env python3
import os
import re
import logging
import click
# don't index these
excludes = {
'single_files',
'Icon',
// original from: http://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
// original gist: https://gist.github.com/willpatera/ee41ae374d3c9839c2d6
function doGet(e){
return handleResponse(e);
}
// Enter sheet name where data is to be written below
var SHEET_NAME = "Sheet1";
<form id="test-form">
<div>
<label>Field 1</label>
<input type="text" name="form_field_1" placeholder="Field 1"/>
</div>
<div>
<label>Field 2</label>
<input type="text" name="form_field_2" placeholder="Field 2"/>
@jalbertbowden
jalbertbowden / url-to-domain.php
Created March 29, 2019 23:22
Get the domain name from a URL for display purposes in PHP
<?php
// This is PHP function to convert a user-supplied URL to just the domain name,
// which I use as the link text.
// Remember you still need to use htmlspecialchars() or similar to escape the
// result.
function url_to_domain($url)
{
@jalbertbowden
jalbertbowden / js-object-length.js
Created March 29, 2019 23:19
Get object length by checking the key
// http://stackoverflow.com/a/18560314
// if condition is for old IE
if (!Object.keys) {
Object.keys = function (obj) {
var arr = [],
key;
for (key in obj) {
if (obj.hasOwnProperty(key)) {
arr.push(key);
}

AirDrop Shortcut

  1. Put this command in Terminal cd /System/Library/CoreServices/Finder.app/Contents/Applications && open .
  2. Drag "AirDrop" to Dock