Skip to content

Instantly share code, notes, and snippets.

View dwcdev's full-sized avatar

David dwcdev

View GitHub Profile
@dwcdev
dwcdev / concentric_circle_spinner.html
Last active June 26, 2021 04:12
Trippy Concentric Circle Spinner
// Trippy concentric circle spinner
// code from: frontend.horse
// https://frontend.horse/articles/concentric-circle-spinner
<style type="text/css">
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
@dwcdev
dwcdev / block_region_preproces_example.php
Created May 6, 2019 21:19
Pull a block's region in a preprocess function.
<?php
use Drupal\block\Entity\Block;
function yourtheme_preprocess_block(&$vars) {
// we expect a block ID
if (empty($vars['elements']['#id'])) {
return;
}
@dwcdev
dwcdev / same_data_types_example_arrays.php
Last active February 24, 2019 03:13
Always return the same data types - arrays.
<?php
// array of food items
$foods = [
'fruits' => ['banana', 'apple', 'lemon'],
'veggies' => ['celery', 'spinach', 'kale']
];
// return an array
function get_foods($food_type = '') {
@dwcdev
dwcdev / same_data_types_example_strings.php
Created February 23, 2019 18:04
Always return the same data types - strings.
<?php
// return a full name
function fmt_name($first_name = '', $last_name = '') {
if (!strlen($first_name) && !strlen($last_name)) {
return '';
}
return $first_name . ' ' . $last_name;
}
@dwcdev
dwcdev / interfaces
Created February 5, 2019 04:26
interfaces config
# The primary network interface
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid MY-OFFICE-WIFI-SSID-HERE
wpa-psk MY-WIFI-PASSWORD-HERE
@dwcdev
dwcdev / snazzy_maps_demo.js
Created December 6, 2018 09:36
Snazzy Maps demo
var initMap = function() {
google.maps.visualRefresh = true;
var map_opts = {
zoom: 11,
// Centered to Indianapolis...
center: new google.maps.LatLng(39.768403, -86.158068),
// The style is pasted into a member of a gmap_styles literal. You can
@dwcdev
dwcdev / geocoder.php
Last active February 23, 2019 02:04
Make a call to the geocoding API for lat/lng.
<?php
function _geocode($api = NULL, $key = NULL, $address = NULL) {
// make sure we have all the parameters
if (!$api || !$key || !$address) {
return NULL;
}
// fmt api call with key and url encoded address
$geocode_url = $api . '?address=' . urlencode($address) . '&key=' . $key;
@dwcdev
dwcdev / cf_htaccess.txt
Last active April 28, 2021 17:53
CloudFlare rules for .htaccess
# Only allow from CloudFlare IPs
Order Deny,Allow
Deny from all
Allow from 103.21.244.0/22
Allow from 103.22.200.0/22
Allow from 103.31.4.0/22
Allow from 104.16.0.0/13
Allow from 104.24.0.0/14
Allow from 108.162.192.0/18
Allow from 131.0.72.0/22

Keybase proof

I hereby claim:

  • I am dwcdev on github.
  • I am dwcdev (https://keybase.io/dwcdev) on keybase.
  • I have a public key ASDKsQUjaTuhI_dZcVhyEuFQBcRY57WS3Tf7I2kb6GAxGAo

To claim this, I am signing this object: