Skip to content

Instantly share code, notes, and snippets.

View YarGnawh's full-sized avatar

Ray Hwang YarGnawh

View GitHub Profile
@YarGnawh
YarGnawh / lamp.sh
Last active June 15, 2018 17:22
Initialization script for CodeAnywhere container
sudo DEBIAN_FRONTEND=noninteractive apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get --yes --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
sudo DEBIAN_FRONTEND=noninteractive apt-get --yes --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install language-pack-en-base
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install python-software-properties
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install software-properties-common
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install bzip2 build-essential apt-transport-https
# Install node
<!DOCTYPE html>
<html>
<head>
<title>Puppet</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.3/TweenMax.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.3/TimelineMax.min.js"></script>
<style>
.window {
position: relative;
@YarGnawh
YarGnawh / upgrade.sh
Created August 10, 2017 17:40
Upgrade PHP 5.6 to PHP 7.0 on Ubuntu Apache
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php -y
sudo apt-get update
sudo apt-get install -y php7.0 libapache2-mod-php7.0 php7.0-cli php7.0-mcrypt php7.0-mysql php7.0-mbstring php7.0-gd php7.0-curl php7.0-mcrypt
sudo a2dismod php5
sudo a2enmod php7.0
sudo service apache2 restart
@YarGnawh
YarGnawh / eq.js
Last active February 17, 2017 05:06
Equation Solver using Map/Reduce
function parse(eq) {
var nest = 0;
eq = eq.reduce(function(acc, val) {
if (val == '(') {
nest++;
} else if (val == ')') {
nest--;
}
if (val == '(' && nest == 1) {
@YarGnawh
YarGnawh / sorts.js
Created October 20, 2016 16:44
Sorts in Javascript
// Helper function to clone array
function cloneArray(arr) {
return arr.slice();
}
// Helper function to generate random number array
function randomArray(min, max, len) {
// Set default values
min = min || 0;

Programming Setup Tutorial

JavaScript (node.js for mac and windows)

Setup

@YarGnawh
YarGnawh / sample.html
Created August 25, 2016 07:47
Sample page of overlay scrolling with "locked" body
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.noscroll {
overflow: hidden;
}
@YarGnawh
YarGnawh / script.sh
Last active February 19, 2016 16:51
Setup LAMP & Wordpress for AWS EC2 Ubuntu 14.04
# Always run this line first
sudo apt-get update
# Almost always install a web server
sudo apt-get install -y apache2
# Install PHP + Apache PHP Module
sudo apt-get install -y php5 libapache2-mod-php5 php5-mcrypt
sudo apt-get install -y php5-gd libssh2-php
@YarGnawh
YarGnawh / reverseAuth.m
Last active May 19, 2017 15:10
Twitter Reverse Auth API Request
- (void)reserveAuth
{
NSString * http_method = @"POST";
NSString * request_url = @"https://api.twitter.com/oauth/request_token";
NSString * oauth_consumer_key = @"bcn3PUKI0PZoxfPTqEDkMru9A";
NSString * oauth_consumer_secret = @"YiVeSteQBplk8xzAtuoulA7i2vLkVF5kIwc5x1A6ZaxmugdmXg";
NSString * oauth_nonce = [[NSUUID UUID] UUIDString];
NSString * oauth_signature = @"";
NSString * oauth_signature_method = @"HMAC-SHA1";
@YarGnawh
YarGnawh / ec2-host-update.sh
Last active February 21, 2017 09:26
AWS EC2 Route53 Update CNAME using JSON USER_DATA
#!/bin/bash
# Write to /usr/local/ec2/ec2-host-update.sh
# Execute chmod 755 ec2-host-update.sh
# Append /usr/local/ec2/ec2-host-update.sh to /etc/rc.local
# Referenced: http://realguess.net/2013/12/06/amazon-route-53-via-command-line/
if ! type "aws" > /dev/null; then