Skip to content

Instantly share code, notes, and snippets.

Michael Chen yuhua-chen

Block or report user

Report or block yuhua-chen

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
@DavidWells
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: 'https://google.com',
}
};
return callback(null, response);
}
@themanifold
themanifold / node-prune.sh
Last active Feb 7, 2019
Pruning useless node_modules with bash userland tools (find etc)
View node-prune.sh
#!/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
hassanazimi / .htaccess
Last active Aug 11, 2019
The Best .htaccess with browser caching and gzip
View .htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
@alexlee002
alexlee002 / xcplugin_update.sh
Created Apr 11, 2015
Auto update Xcode plugins to support new version of Xcode
View xcplugin_update.sh
#!/bin/sh
PLUGINS_DIR="$HOME/Library/Application Support/Developer/Shared/Xcode/Plug-ins"
XCODE_INFO_PATH=$(xcode-select -p)
XCODE_INFO_PATH=$(dirname "$XCODE_INFO_PATH")/Info
DVTPlugInCompatibilityUUID=$(defaults read "$XCODE_INFO_PATH" DVTPlugInCompatibilityUUID)
for plugin in "$PLUGINS_DIR"/*.xcplugin; do
plugin_info_path="$plugin/Contents/Info"
if [[ -f "$plugin_info_path.plist" ]]; then
@sburlot
sburlot / xc_ramdisk.sh
Created Mar 8, 2014
Creates a ramdisk and start Xcode with the DerivedData stored in ramdisk. Also deletes the ramdisk and reset Xcode prefs.
View xc_ramdisk.sh
#!/bin/bash
# Creates a ramdisk and start Xcode with the DerivedData stored in ramdisk. Also deletes the ramdisk and reset Xcode prefs.
# xc_ramdisk.sh
# - creates a ramdisk, set Xcode DerivedData to this disk and start Xcode.
# - umount a ramdisk, set Xcode DerivedData to default
# Stephan Burlot, Coriolis Technologies, http://www.coriolis.ch
#
# based on Alex Shevchenko xcode_ramdisk.sh script (https://gist.github.com/skeeet/2367298)
# based on Diego Freniche xc-launch.sh script (https://github.com/dfreniche/xc-launch)
@zrxq
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)+insets.top, CGRectGetWidth(rect)-insets.left-insets.right, CGRectGetHeight(rect)-insets.top-insets.bottom);
}
@wess
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;
@end
@incredimike
incredimike / country_list.js
Last active Sep 17, 2019
Country list as javascript array (alphabetical)
View country_list.js
// List of all countries. The & character has been converted into &amp; for you, in case you want to use this directly in HTML.
// Last updated June 11, 2018
var country_list = ["Afghanistan","Albania","Algeria","Andorra","Angola","Anguilla","Antigua &amp; Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas"
,"Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bosnia &amp; Herzegovina","Botswana","Brazil","British Virgin Islands"
,"Brunei","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Canada","Cape Verde","Cayman Islands","Chad","Chile","China","Colombia","Congo","Cook Islands","Costa Rica"
,"Cote D Ivoire","Croatia","Cruise Ship","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","Ecuador","Egypt","El Salvador","Equatorial Guinea"
,"Estonia","Ethiopia","Falkland Islands","Faroe Islands","Fiji","Finland","France","French Polynesia","French West Indies","Gabon","Gambia","Georgia",
@bdunogier
bdunogier / curl_progress.php
Created Jun 16, 2011
PHP/cURL download progress monitoring
View curl_progress.php
<?php
file_put_contents( 'progress.txt', '' );
$targetFile = fopen( 'testfile.iso', 'w' );
$ch = curl_init( 'http://ftp.free.org/mirrors/releases.ubuntu-fr.org/11.04/ubuntu-11.04-desktop-i386-fr.iso' );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $ch, CURLOPT_NOPROGRESS, false );
curl_setopt( $ch, CURLOPT_PROGRESSFUNCTION, 'progressCallback' );
curl_setopt( $ch, CURLOPT_FILE, $targetFile );
You can’t perform that action at this time.