Skip to content

Instantly share code, notes, and snippets.

View alexpchin's full-sized avatar

Alex Chin alexpchin

View GitHub Profile
@alexpchin
alexpchin / LICENSE
Created July 15, 2016 12:41 — forked from ifraixedes/LICENSE
AWS lambda handler which download images from S3, resizes them and upload the new ones to S3; tested with mocha, chai, sinon and proxyquire
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004
(http://www.wtfpl.net/about/)
Copyright (C) 2015 Mario Mendes (@hyprstack)
Copyright (C) 2015 Ivan Fraixedes (https://ivan.fraixed.es)
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
@alexpchin
alexpchin / What_Is_Rest.md
Created May 8, 2014 09:12
What is REST?

What is REST?

REST stands for Representional State Transfer and is defined on Wikipedia as:

Representational state transfer (REST) is a software architectural style consisting of a coordinated set of architectural constraints applied to components, connectors, and data elements, within a distributed hypermedia system. REST ignores the details of component implementation and protocol syntax in order to focus on the roles of components, the constraints upon their interaction with other components, and their interpretation of significant data elements.

I think the second part of that explanation sounds like it could be quite interesting... but to me that all seems super complicated! So I've decided to try to simplify it for my own understanding. (If I have not understood something in this gist, please TELL ME!)

##Saving & Retrieving information For this section, think of a web application as a piece of software built to help people to store and access information online.

@alexpchin
alexpchin / S3-Static-Sites.md
Created July 16, 2020 06:50 — forked from bradwestfall/S3-Static-Sites.md
Use S3 and CloudFront to host Static Single Page Apps (SPAs) with HTTPs and www-redirects. Also covers deployments.

S3 Static Sites

What this will cover

  • Host a static website at S3
  • Redirect www.website.com to website.com
  • Website can be an SPA (requiring all requests to return index.html)
  • Free AWS SSL certs
  • Deployment with CDN invalidation

Resources

@alexpchin
alexpchin / Session.js
Created May 5, 2021 18:58 — forked from JamesTheHacker/Session.js
Log into Facebook using cookies
'use strict'
let Promise = require('bluebird');
let fs = Promise.promisifyAll(require('fs'));
let Cheerio = require('cheerio');
let Request = require('request');
let ToughCookie = require('tough-cookie');
class Session {
@alexpchin
alexpchin / mongo-autostart-osx.md
Created January 7, 2018 00:34 — forked from subfuzion/mongo-autostart-osx.md
mongo auto start on OS X

Install with Homebrew

brew install mongodb

Set up launchctl to auto start mongod

$ ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents

/usr/local/opt/mongodb/ is a symlink to /usr/local/Cellar/mongodb/x.y.z (e.g., 2.4.9)

watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache verify && yarn install && yarn start -- --reset-cache
@alexpchin
alexpchin / tags.js
Created February 28, 2019 13:26
Trying to get the tags to be highlighted
import React from "react";
import { StyleSheet, View, FlatList, Text } from "react-native";
import { connectInfiniteHits, connectHighlight } from "react-instantsearch-native";
import { uniqBy } from "lodash";
const Highlight = connectHighlight(
({ highlight, attribute, hit, highlightProperty }) => {
const parsedHit = highlight({
attribute,
hit,
@alexpchin
alexpchin / screen-gif.sh
Created January 4, 2021 16:37 — forked from julesjans/screen-gif.sh
Capture iOS Simulator to animated gif
# Turn on the simulator screen capture
xcrun simctl io booted recordVideo ~/simulator.mov
# Convert the iPhone 6s screen shot into a gif:
ffmpeg -i ~/simulator.mov -vf scale=320:-1 -r 6 -f gif -y simulator.gif
@alexpchin
alexpchin / Generating_Migrations.md
Last active April 21, 2021 15:01
Generating Migrations

Generating Migrations

Migrations are a feature of Active Record that allows you to evolve your database schema over time. Rather than write schema modifications in pure SQL, migrations allow you to use an easy Ruby DSL to describe changes to your tables.

Another way of thinking about them is like a kind of version control (like git) for your application's database - only not as cool as Git (because Git rules).

##Each database starts empty Every database starts empty. Adding information to a database can be described as a series of steps, one after another... Migrations allow developers to save the most important steps like creating tables or adding columns. Later you can rollback to before these changes if something goes wrong, although you might lose data if you do this!

@alexpchin
alexpchin / gist:8e2bb81ca0067b824a08fdc7e9b3711e
Created January 28, 2021 13:00
Delete all node_modules
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +