Skip to content

Instantly share code, notes, and snippets.

View jasenmichael's full-sized avatar

Jasen Michael jasenmichael

View GitHub Profile
@jasenmichael
jasenmichael / repo-reset.md
Created March 24, 2022 14:55 — forked from heiswayi/repo-reset.md
GitHub - Delete commits history with git commands

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A
@jasenmichael
jasenmichael / simple-map-defer.php
Last active August 7, 2021 21:51 — forked from nfsarmento/simple-map-defer.php
WordPress defer javascript filter
/**
* defer javascript!
*
*/
function defer_parsing_of_js($url)
{
if (FALSE === strpos($url, '.js')) return $url;
if (strpos($url, 'jquery.js')) return $url;
return "$url' defer ";
}
@jasenmichael
jasenmichael / script-template.sh
Created July 11, 2021 04:53 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@jasenmichael
jasenmichael / reverse-ip-lookup.js
Created June 19, 2021 16:11 — forked from eugenehp/reverse-ip-lookup.js
node.js IP reverse lookup
var dns = require('dns');
function reverseLookup(ip) {
dns.reverse(ip,function(err,domains){
if(err!=null) callback(err);
domains.forEach(function(domain){
dns.lookup(domain,function(err, address, family){
console.log(domain,'[',address,']');
console.log('reverse:',ip==address);
@jasenmichael
jasenmichael / download-site.md
Created June 1, 2021 01:08 — forked from pmeinhardt/download-site.md
download an entire page (including css, js, images) for offline-reading, archiving… using wget

If you ever need to download an entire website, perhaps for off-line viewing, wget can do the job — for example:

$ wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows --domains website.org --no-parent  www.website.org/tutorials/html/

This command downloads the website www.website.org/tutorials/html/.

The options are:

  • --recursive: download the entire website
  • --domains website.org: don't follow links outside website.org
@jasenmichael
jasenmichael / paginated.js
Created March 22, 2020 22:39 — forked from jstott/paginated.js
lodash paginated items
function getPaginatedItems(items, page, pageSize) {
var pg = page || 1,
pgSize = pageSize || 100,
offset = (pg - 1) * pgSize,
pagedItems = _.drop(items, offset).slice(0, pgSize);
return {
page: pg,
pageSize: pgSize,
total: items.length,
total_pages: Math.ceil(items.length / pgSize),
@jasenmichael
jasenmichael / github-ssh-setup.md
Last active November 23, 2019 06:50 — forked from developius/README.md
Setup SSH keys for use with GitHub/GitLab/BitBucket etc

Create a new repository, or reuse an existing one.

Generate a new SSH key:

ssh-keygen -t rsa -C "[email protected]"

Copy the contents of the file ~/.ssh/id_rsa.pub to your SSH keys in your GitHub account settings.

Test SSH key:

@jasenmichael
jasenmichael / javascript-random-string
Created September 12, 2019 20:26 — forked from 6174/Random-string
Generate a random string in JavaScript In a short and fast way!
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15)