Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Aalaap Ghag aalaap

🎯
Focusing
View GitHub Profile
@aalaap
aalaap / App.js
Last active May 28, 2021
Creating a custom authentication flow from scratch with AWS Amplify and React - sample code
View App.js
/**
* This code is based on Nader Dabit's tutorial for custom Cognito authentication
* using AWS Amplify and React: https://www.youtube.com/watch?v=JaVu-sS3ixg&t=24s
*
* It's 99% the same as the video, but I've sprinkled a few niceties here and there.
*/
import React, { useEffect, useState } from "react";
import Amplify, { Auth, Hub } from "aws-amplify";
@aalaap
aalaap / flaskserver.py
Created Feb 5, 2019
Run a Flask app in production or development/debug from the command line
View flaskserver.py
"""
Run a Flask app in production or development/debug from the command line
If you wish to run a Flask app with Python instead of the `flask run` command,
this code provides an easier way to decide if you want to run it in production
or debug mode.
Usage:
python flaskserver.py dev # runs with debug set to True
python flaskserver.py # production mode
@aalaap
aalaap / fn.StripTagsOnly.php
Last active Jul 6, 2018
Strip Tags Only - An implemention of the PHP strip_tags function that only removes specified tags
View fn.StripTagsOnly.php
<php
/**
* Strip Tags Only
*
* Just like strip_tags, but only removes the HTML tags specified and not all of
* them.
*
* @param String $text The text to strip the tags from.
* @param String|Array $allowedTags This can either be one tag (eg. 'p') or an
* array, (eg. ['p','br','h1']).
View keybase.md

Keybase proof

I hereby claim:

  • I am aalaap on github.
  • I am aalaap (https://keybase.io/aalaap) on keybase.
  • I have a public key whose fingerprint is F267 4132 B0A1 3A35 2D5F ECDE 2968 DF2C 0D0F 5E20

To claim this, I am signing this object:

@aalaap
aalaap / strdoge.cpp
Last active Aug 29, 2015
strdoge(): inspired by strcat(). such wow, much code.
View strdoge.cpp
#include <iostream>
#include <sstream>
using namespace std;
/* supply words and strdoge() will echo the doge and strdog() will return the doge */
string strdog(string so, string such, string very, string much);
void strdoge(string so, string such, string very, string much);
@aalaap
aalaap / fn.quickYouTubeId.php
Last active Feb 5, 2019
Easy little function to get the video ID from any YouTube URL.
View fn.quickYouTubeId.php
<php
/**
* quickYouTubeId: Easy little function to get the video ID from any YouTube
* URL.
*
* I went through a lot of snippets that perform various kinds of RegEx and
* parse_url and what not, but I thought, since most YouTube video IDs are 11
* characters, why not just look for the only 11-character string and extract
* that? I can't think of a YouTube URL that'll foil this match. Can you?
*
@aalaap
aalaap / gist:3066704
Created Jul 7, 2012
Sample HTML page with Twitter's Bootstrap, Ryan Fait's Sticky Footer, and a full-width footer, fixed for responsive layouts by Aalaap Ghag
View gist:3066704
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="author" content="Aalaap Ghag" />
<title>Twitter&rsquo;s Bootstrap with Ryan Fait&rsquo;s Sticky Footer and Aalaap Ghag&rsquo;s Responsive Padding Fix</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<style>
html, body {
@aalaap
aalaap / desopafy.html
Created Jan 18, 2012 — forked from timraymond/desopafy.js
Remove SOPA overlay from Wikipedia pages via a bookmarklet
View desopafy.html
<a href="javascript:(function(){$('body>div').toggle();})();">DeSOPAFy</a>