Skip to content

Instantly share code, notes, and snippets.

View CelesteComet's full-sized avatar

Bruce Wong CelesteComet

View GitHub Profile
<html>
<head>
<title></title>
<script type="text/javascript">
INTRO_TO_ALGS = 9789650603533;
document.addEventListener('DOMContentLoaded', function() {
let form = document.querySelector('form');
form.onsubmit = function(e) {
e.preventDefault();
@CelesteComet
CelesteComet / Outliner.js
Created June 5, 2019 21:23 — forked from arieh/Outliner.js
Cross-Lib accessible outline removal
/*!
Copyright (c) <2012> <Arieh Glazer>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE

#Setting up Nginx on Your Local System ###by Keith Rosenberg

##Step 1 - Homebrew The first thing to do, if you're on a Mac, is to install homebrew from http://mxcl.github.io/homebrew/

The command to type into terminal to install homebrew is:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
const axios = require('axios');
const moment = require('moment');
function Logger(url){
this.uniqueClients = 0;
this.sessions = 0;
this.serverErrors = 0;
this.clicks = [];
this.sessions = [];
@CelesteComet
CelesteComet / how-to-copy-aws-rds-to-local.md
Created May 19, 2019 06:41 — forked from syafiqfaiz/how-to-copy-aws-rds-to-local.md
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@CelesteComet
CelesteComet / credit-card-regex.md
Created February 25, 2019 20:20 — forked from michaelkeevildown/credit-card-regex.md
Credit Card Regex Patterns

Credit Card Regex

  • Amex Card: ^3[47][0-9]{13}$
  • BCGlobal: ^(6541|6556)[0-9]{12}$
  • Carte Blanche Card: ^389[0-9]{11}$
  • Diners Club Card: ^3(?:0[0-5]|[68][0-9])[0-9]{11}$
  • Discover Card: ^65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})$
  • Insta Payment Card: ^63[7-9][0-9]{13}$
  • JCB Card: ^(?:2131|1800|35\d{3})\d{11}$
  • KoreanLocalCard: ^9[0-9]{15}$
@CelesteComet
CelesteComet / cpfValidator.js
Created May 3, 2018 23:46
CPF Validation for Brazil
function cpfValidate(str) {
let match = str.match(/^(\d{9})-(\d{2})$/);
if (!match) { return false }
// If in the correct format
let firstSetString = match[1];
let secondSetString = match[2];
let sum = 0;
for (let i = 0; i < firstSetString.length; i++) {
def googleCard(cards):
end = None
dic = {}
for card in cards:
currentCard = card
if end is None:
end = currentCard + 5
require_relative "heap"
class Array
def heap_sort!
# Create a heap
heap = BinaryMinHeap.new
# make an array to keep the sorted elements
sorted = []
class ChannelChannel < ApplicationCable::Channel
def subscribed
stream_from "channel_#{params[:channel_name]}"
end
end