Skip to content

Instantly share code, notes, and snippets.

View ai7ch's full-sized avatar
💭
I may be slow to respond.

ai7ch ai7ch

💭
I may be slow to respond.
View GitHub Profile
@ai7ch
ai7ch / require_all_helper.php
Created March 15, 2018 08:25 — forked from pwenzel/require_all_helper.php
Recursively include all PHP files
<?php
/**
* Scan the api path, recursively including all PHP files
*
* @param string $dir
* @param int $depth (optional)
*/
protected function _require_all($dir, $depth=0) {
if ($depth > $this->max_scan_depth) {
@ai7ch
ai7ch / gist:550a17306db4274b4c60441ba09f73a3
Created March 28, 2018 11:03 — forked from snowman-repos/gist:3825198
JavaScript: Detect Orientation Change on Mobile Devices
// Listen for orientation changes
window.addEventListener("orientationchange", function() {
// Announce the new orientation number
alert(window.orientation);
}, false);
// Listen for resize changes
window.addEventListener("resize", function() {
// Get screen size (inner/outerWidth, inner/outerHeight)
@ai7ch
ai7ch / ssh.txt
Created July 9, 2018 11:43 — forked from bradtraversy/ssh.md
SSH & DevOps Crash Course Snippets
# Login via SSH with password (LOCAL SERVER)
> ssh brad@192.168.1.29
# Create folder, file, install Apache (Just messing around)
mkdir test
cd test
touch hello.txt
sudo apt-get install apache2
# Generate Keys
@ai7ch
ai7ch / csv_to_array.php
Created July 27, 2018 14:47 — forked from jaywilliams/csv_to_array.php
Convert a comma separated file into an associated array.
<?php
/**
* Convert a comma separated file into an associated array.
* The first row should contain the array keys.
*
* Example:
*
* @param string $filename Path to the CSV file
* @param string $delimiter The separator used in the file
* @return array
@ai7ch
ai7ch / webdev_online_resources.md
Created September 28, 2018 16:49 — forked from bradtraversy/webdev_online_resources.md
Online Resources For Web Developers (No Downloading)
@ai7ch
ai7ch / blog-webpack-2.md
Created November 12, 2018 17:06 — forked from xjamundx/blog-webpack-2.md
From Require.js to Webpack - Part 2 (the how)

This is the follow up to a post I wrote recently called From Require.js to Webpack - Party 1 (the why) which was published in my personal blog.

In that post I talked about 3 main reasons for moving from require.js to webpack:

  1. Common JS support
  2. NPM support
  3. a healthy loader/plugin ecosystem.

Here I'll instead talk about some of the technical challenges that we faced during the migration. Despite the clear benefits in developer experience (DX) the setup was fairly difficult and I'd like to cover some of the challanges we faced to make the transition a bit easier.

@ai7ch
ai7ch / gist:42148552ac23155267fba320d9c741d2
Created November 19, 2018 16:46
r.js sample configurations
/*
* This is an example build file that demonstrates how to use the build system for
* require.js.
*
* THIS BUILD FILE WILL NOT WORK. It is referencing paths that probably
* do not exist on your machine. Just use it as a guide.
*
*
* SOURCE: https://github.com/requirejs/r.js/blob/master/build/example.build.js
*
@ai7ch
ai7ch / gist:facf45465d2244bf612fa029e4d40f65
Created March 18, 2021 21:25 — forked from jtdp/gist:5443297
See changes before pulling from remote git repository
# fetch the changes from the remote
git fetch origin
# show commit logs of changes
git log master..origin/master
# show diffs of changes
git diff master..origin/master
# apply the changes by merge..
@ai7ch
ai7ch / gist:224ccc94f60ea1ca9f3e6161c8b9bc6a
Created March 20, 2021 13:24 — forked from aludvigsen/gist:647d31d9ddbc37e96345
Git post-receive hook deployment using node, npm and PM2
#!/bin/sh
export GIT_WORK_TREE="/var/www/project"
echo "--> Checking out..."
git --work-tree=$GIT_WORK_TREE --git-dir=/var/repos/myrepo.git checkout -f
echo "--> NPM install..."
cd "$GIT_WORK_TREE"
npm install
@ai7ch
ai7ch / git-bundle-hook.md
Created March 20, 2021 13:25 — forked from stefansundin/git-bundle-hook.md
Git post-checkout and post-merge hooks to simplify bundling and other tasks.

Make bundleing and npm installing easy

These git hooks runs bundle or npm install automatically whenever you:

  • git checkout a new branch with a different Gemfile or package.json.
  • git pull a change to Gemfile or package.json.

How to install

  1. cd awesome_git_repo