Skip to content

Instantly share code, notes, and snippets.

... building the future.

jaswrks jaswrks

... 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 / config
Created May 2, 2019
View config
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 'Network Trash Folder' 'Temporary Items' .LSOverride .Spotlight-V100 .VolumeIcon.icns .TemporaryItems .fseventsd .DS_Store .Trashes .apdisk Icon?
# 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 / 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 / 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 ( [
View .gitattributes
# Text/Binary ---
# Default
* text=auto
# Text
*.md text
*.txt text
jaswrks / .gitignore
Last active Apr 16, 2018
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 /
Created Mar 21, 2018
Fun Facts about Alaska

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 / wp-config-ngrok.php
Last active Mar 5, 2018
View wp-config-ngrok.php
&& stripos( $_SERVER['HTTP_X_FORWARDED_PROTO'], 'https' ) !== false ) {
$_SERVER['HTTPS'] = 'on';
jaswrks /
Last active Feb 14, 2018
Type Declarations

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
* 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.