Skip to content

Instantly share code, notes, and snippets.

Avatar
👾
machinelabs.com

Will Wright willwright82

👾
machinelabs.com
View GitHub Profile
@willwright82
willwright82 / ag-search-replace.sh
Created Jan 31, 2020
Search and Replace using AG — The Silver Surfer
View ag-search-replace.sh
ag -l "search string" | xargs sed -i '' -e 's/from/to/g'
View Readme-template.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

View contributing-template.md

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a
@willwright82
willwright82 / git-deployment.md
Created Jul 22, 2019 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks
View git-deployment.md

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

@willwright82
willwright82 / safari-flicker-fix.css
Created Mar 7, 2019
To fix Safari flickering force GPU acceleration by adding transform translate3d(0,0,0) to your element (via https://muffinman.io/ios-safari-scroll-position-fixed/)
View safari-flicker-fix.css
/*
If you ever had to fix element on scroll,
you probably had an issue on iOS Safari
(and other mobile devices). Element will
usually flicker, and disappear until scrolling
has stopped completely.
Just force GPU acceleration by adding transform:
translate3d(0,0,0); to your element.
*/
@willwright82
willwright82 / mobileCheck.js
Last active Jan 29, 2019
Detects mobile devices — Usage: if ( mobileCheck.ios ) { // Code }
View mobileCheck.js
var mobileCheck = {
ios: (function(){
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
}()),
android: (function(){
return navigator.userAgent.match(/Android/i);
}()),
blackBerry: (function(){
return navigator.userAgent.match(/BB10|Tablet|Mobile/i);
}()),
@willwright82
willwright82 / chmod.sh
Created Dec 12, 2017
Recursive chmod for files or folders
View chmod.sh
# To recursively give directories read&execute privileges:
chmod 755 $(find /path/to/base/dir -type d)
# To recursively give files read privileges:
chmod 644 $(find /path/to/base/dir -type f)
#Or, to reduce chmod spawning:
find /path/to/base/dir -type d -print0 | xargs -0 chmod 755
find /path/to/base/dir -type f -print0 | xargs -0 chmod 644
@willwright82
willwright82 / getLanguage.js
Created Nov 28, 2017
Get user language based on Locale
View getLanguage.js
// To get the language of your visitor:
var language = window.navigator.userLanguage || window.navigator.language;
console.log(language);
@willwright82
willwright82 / randomSHA1.js
Created Oct 26, 2017
Generate a random SHA1 token in browser
View randomSHA1.js
// str byteToHex(uint8 byte)
// converts a single byte to a hex string
function byteToHex(byte) {
return ('0' + byte.toString(16)).slice(-2);
}
// str generateId(int len);
// len - must be an even number (default: 40)
function generateId(len) {
var arr = new Uint8Array((len || 40) / 2);