Skip to content

Instantly share code, notes, and snippets.


Michael Chen yuhua-chen

View GitHub Profile
DavidWells / aws-lambda-redirect.js
Created Jun 28, 2018
How to do a 301 redirect from an AWS lambda function
View aws-lambda-redirect.js
exports.handler = (event, context, callback) => {
const response = {
statusCode: 301,
headers: {
Location: '',
return callback(null, response);
themanifold /
Last active May 8, 2020
Pruning useless node_modules with bash userland tools (find etc)
#!/usr/bin/env bash
find node_modules \( -name '__tests__' -o \
-name 'test' -o \
-name 'tests' -o \
-name 'powered-test' -o \
-name 'docs' -o \
-name 'doc' -o \
-name '.idea' -o \
-name '.vscode' -o \
-name 'website' -o \
hassanazimi / .htaccess
Last active Mar 8, 2021
The Best .htaccess with browser caching and gzip
View .htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
alexlee002 /
Created Apr 11, 2015
Auto update Xcode plugins to support new version of Xcode
PLUGINS_DIR="$HOME/Library/Application Support/Developer/Shared/Xcode/Plug-ins"
XCODE_INFO_PATH=$(xcode-select -p)
DVTPlugInCompatibilityUUID=$(defaults read "$XCODE_INFO_PATH" DVTPlugInCompatibilityUUID)
for plugin in "$PLUGINS_DIR"/*.xcplugin; do
if [[ -f "$plugin_info_path.plist" ]]; then
sburlot /
Created Mar 8, 2014
Creates a ramdisk and start Xcode with the DerivedData stored in ramdisk. Also deletes the ramdisk and reset Xcode prefs.
# Creates a ramdisk and start Xcode with the DerivedData stored in ramdisk. Also deletes the ramdisk and reset Xcode prefs.
# - creates a ramdisk, set Xcode DerivedData to this disk and start Xcode.
# - umount a ramdisk, set Xcode DerivedData to default
# Stephan Burlot, Coriolis Technologies,
# based on Alex Shevchenko script (
# based on Diego Freniche script (
zrxq / gist:5363610
Last active Feb 3, 2016
CGRect inset with UIEdgeInsets
View gist:5363610
inline static CGRect CGRectEdgeInset(CGRect rect, UIEdgeInsets insets) {
return CGRectMake(CGRectGetMinX(rect)+insets.left, CGRectGetMinY(rect), CGRectGetWidth(rect)-insets.left-insets.right, CGRectGetHeight(rect);
wess / UIButton+Addition.h
Created Jan 21, 2012
added setBackground for event to UIButton
View UIButton+Addition.h
#import <UIKit/UIKit.h>
@interface UIButton(WCButton)
@property (nonatomic, retain) NSMutableDictionary *backgrounds;
- (void) setBackgroundColor:(UIColor *)bgColor forState:(UIControlState)state;
incredimike / variousCountryListFormats.js
Last active Sep 16, 2021
List of Countries in various Javascript data structures: Alphabetical country lists & Country data objects.
View variousCountryListFormats.js
// Lists of countries with ISO 3166 codes, presented in various formats.
// Last Updated: July 30, 2020
// If you're using PHP, I suggest checking out:
// or Laravel:
// JS developers can check out:
bdunogier / curl_progress.php
Created Jun 16, 2011
PHP/cURL download progress monitoring
View curl_progress.php
file_put_contents( 'progress.txt', '' );
$targetFile = fopen( 'testfile.iso', 'w' );
$ch = curl_init( '' );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $ch, CURLOPT_NOPROGRESS, false );
curl_setopt( $ch, CURLOPT_PROGRESSFUNCTION, 'progressCallback' );
curl_setopt( $ch, CURLOPT_FILE, $targetFile );