Skip to content

Instantly share code, notes, and snippets.

View hussainanjar's full-sized avatar
🎯
Focusing

Hussain Fakhruddin hussainanjar

🎯
Focusing
View GitHub Profile
@bradtraversy
bradtraversy / pipenv_cheat_sheet.md
Last active March 27, 2024 13:26
Pipenv cheat sheet for common commands

Pipenv Cheat Sheet

Install pipenv

pip3 install pipenv

Activate

pipenv shell
@vdbelt
vdbelt / cloudflare-purge-cache-service-worker.js
Created August 21, 2018 11:43
A CloudFlare service worker that proxies purge cache requests. Example: https://example.com/__purge_cache?zone=XX
addEventListener('fetch', event => {
event.respondWith(purgeCache(event.request))
})
async function purgeCache(request) {
const url = new URL(request.url)
@DavidWells
DavidWells / aws-lambda-redirect.js
Created June 28, 2018 20:48
How to do a 301 redirect from an AWS lambda function
exports.handler = (event, context, callback) => {
const response = {
statusCode: 301,
headers: {
Location: 'https://google.com',
}
};
return callback(null, response);
}
@SiddharthaChowdhury
SiddharthaChowdhury / jwt-module.js
Last active February 21, 2024 14:51
Implementation of JWT using private and public keys
const fs = require('fs');
const jwt = require('jsonwebtoken');
// http://travistidwell.com/blog/2013/09/06/an-online-rsa-public-and-private-key-generator/
// use 'utf8' to get string instead of byte array (1024 bit key)
var privateKEY = fs.readFileSync('./private.key', 'utf8'); // to sign JWT
var publicKEY = fs.readFileSync('./public.key', 'utf8'); // to verify JWT
module.exports = {
sign: (payload, $Options) => {
/*
@ziluvatar
ziluvatar / token-generator.js
Last active December 9, 2023 21:21
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jsonwebtoken');
@vahidhedayati
vahidhedayati / gist:e5c839a534ce5fbd7b157bc617c44036
Last active May 29, 2017 14:03
Grails application logging errors to slack

Grails slack plugin appears to do most of the work here

Visit: https://slack.com/ and create a new slack channel Goto Configure apps/integration and create a webhook Configure webhook url in the plugin

If you are using pre grails 2.3, get hold of the grails 2 project from : https://github.com/mathifonseca/grails-slack/tree/grails-2.x

Copy the content of the plugin https://github.com/mathifonseca/grails-slack/tree/grails-2.x/src/groovy/grails/plugin/slack & https://github.com/mathifonseca/grails-slack/tree/master/grails-app/services/grails/plugin/slack to your local application For grails 2.0.1:

body {
color: #212121;
font-family: "Helvetica Neue", "Calibri Light", Roboto, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
letter-spacing: 0.02em;
}
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@hussainanjar
hussainanjar / AmazonSESSample.groovy
Created November 18, 2015 13:27
Groovy script to send email using Amazon SES
@Grab('javax.mail:mail:1.4.7')
import java.util.Properties
import javax.mail.*
import javax.mail.internet.*
final String FROM = "SENDER@EXAMPLE.COM" // Replace with your "From" address. This address or domain must be verified.
final String TO = "RECIPIENT@EXAMPLE.COM" // Replace with a "To" address. If your account is still in the
// sandbox, this address must be verified.
@StevenACoffman
StevenACoffman / setenv.sh
Last active December 12, 2018 02:50 — forked from patmandenver/setenv.sh
Tomcat8 setenv.sh
#
# Cutom Environment Variables for Tomcat
#
############################################
export JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre
export PATH=${JAVA_HOME}/bin:${PATH}
############################################
#
# JAVA_OPTS