Skip to content

Instantly share code, notes, and snippets.

:octocat:
... building the future.

jaswrks jaswrks

:octocat:
... building the future.
Block or report user

Report or block jaswrks

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jaswrks
jaswrks / config
Created May 2, 2019
.subversion/config
View config
[miscellany]
enable-auto-props = yes
global-ignores = .#* ._* .~* *.log *~ .*~ *.bak *.rej *.orig *.patch *.diff .vagrant/ typings/ .idea/ *.sublime-project *.sublime-workspace *.nbproject *.code-workspace vendor/ node_modules/ jspm_packages/ bower_components/ .sass-cache/ .elasticbeanstalk/ *.ctags *.tags .git/ .svn/ _svn/ CVS/ .cvsignore .bzr/ .bzrignore .hg/ .hgignore SCCS/ RCS/ $RECYCLE.BIN/ Desktop.ini Thumbs.db ehthumbs.db .AppleDB .AppleDouble .AppleDesktop .com.apple.timemachine.donotpresent 'Network Trash Folder' 'Temporary Items' .LSOverride .Spotlight-V100 .VolumeIcon.icns .TemporaryItems .fseventsd .DS_Store .Trashes .apdisk Icon?
[auto-props]
# Text
*.md = svn:mime-type=text/plain;; charset=utf-8; svn:eol-style=native
*.txt = svn:mime-type=text/plain;; charset=utf-8; svn:eol-style=native
@jaswrks
jaswrks / flush-dns-script.bash
Created Jul 5, 2018
Bash script intended for macOS that flushes DNS cache and also flushes Chrome's host cache and socket pool automatically.
View flush-dns-script.bash
#!/usr/bin/env bash
# Flush DNS cache.
sudo dscacheutil -flushcache;
sudo killall -HUP mDNSResponder;
# Clear Chrome's DNS cache.
osascript <<EOD
tell application "Google Chrome"
tell front window
@jaswrks
jaswrks / delete_all_data.php
Created Jul 3, 2018
protected function delete_all_data()
View delete_all_data.php
/**
* Deletes all data.
*/
protected function delete_all_data() : void {
global $wpdb;
foreach ( [
$wpdb->posts,
$wpdb->postmeta,
$wpdb->comments,
View .gitattributes
# Text/Binary ---
# Default
* text=auto
# Text
*.md text
*.txt text
@jaswrks
jaswrks / .gitignore
Last active Apr 16, 2018
.gitignore
View .gitignore
# Ignore ---------------------------------------------------------------------------------------------------------------
# Local
#*
.#*
._*
.~*
# Logs
View strict-mode.bash
#!/usr/bin/env bash
# Strict mode.
set -o nounset;
set -o errexit;
set -o errtrace;
set -o pipefail;
# Shell options.
@jaswrks
jaswrks / alaska-fun-facts.md
Created Mar 21, 2018
Fun Facts about Alaska
View alaska-fun-facts.md

Fun Facts About Alaska 🏔

  • Alaska is a really big place, check this.
  • More than half the world’s glaciers can be found Alaska.
  • There are 3 million lakes in Alaska and more than 3,000 rivers.
  • Only 700k people live here (approx. one person per square mile).
  • In contrast, there are 175k moose in Alaska. We see them everywhere.
  • Alaska contains about 98% of the total U.S. brown bear population and 70% of the total North American population. There are 30k brown bears here. That's in addition to 100k black bears and about 4,500 polar bears.
  • We have earthquakes on a daily basis. Each year Alaska has about 5,000 earthquakes including 1,000 that measure above 3.5 on the Richter scale. Of these, I feel an average of about one earthquake each week.
  • Alaska is the only U.S. state name you can type on one row of a keyboard.
@jaswrks
jaswrks / wp-config-ngrok.php
Last active Mar 5, 2018
wp-config-ngrok.php
View wp-config-ngrok.php
if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] )
&& stripos( $_SERVER['HTTP_X_FORWARDED_PROTO'], 'https' ) !== false ) {
$_SERVER['HTTPS'] = 'on';
}
@jaswrks
jaswrks / type-declarations.md
Last active Feb 14, 2018
Type Declarations
View type-declarations.md

Type Declarations

Type Declarations aren't required, nor are they appropriate in all cases. However, type declarations do make code more readable. They also protect code, because type declarations are a way of enforcing data types in the parameters passed to a function. For example, you can force callers to pass an array, or a specific type of object, such as a WP_REST_Request. If a caller doesn't pass the data type expected, PHP throws a recoverable fatal error or exception. This is advantageous because type declarations produce improved error messages that catch problems right away.

When are type declarations appropriate?

When you're writing a function or class method that expects to receive an array or a specific object type, and there is no reason to accept anything other than that specific data type.

protected function foo( Bar $bar, array $items ) {
View is_content_empty.php
<?php
/**
* Checks if comment content is empty.
*
* @param string $content Content to check.
*
* @return bool True if empty or not a string.
*/
function is_content_empty( $content ) {
if ( ! is_string( $content ) ) {
You can’t perform that action at this time.