Skip to content

Instantly share code, notes, and snippets.

View rammyblog's full-sized avatar

Babatunde Onasanya rammyblog

View GitHub Profile
@rammyblog
rammyblog / py_gravatar.py
Last active May 15, 2020 21:51
Gravatar Python3 Image Requests (Get Gravatar Image URL using user email)
import hashlib
import requests
def get_gravatar_image_url(email):
# Set your variables here
default = "https://res.cloudinary.com/rammy/image/upload/ar_4:3,c_fill/c_scale,w_auto,dpr_auto/v1589578218/default_avatar.png"
size = 200
base_url = "https://www.gravatar.com/avatar/"
curl --location --request POST 'https://YOUR_AUTH0_DOMAIN/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=YOUR_AUTH0_CLIENT_ID' \
--data-urlencode 'username=YOUR_USERNAME' \
--data-urlencode 'password=YOUR_PASSWORD' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'scope=openid'
@umutyerebakmaz
umutyerebakmaz / author.entity.ts
Last active April 19, 2023 17:10
TypeORM many to many lazy relation jointable custom table name TypeGraphQL Example (with bi-directional conect GraphQL Approach)
import { Entity, PrimaryGeneratedColumn, Column, BaseEntity, ManyToMany } from 'typeorm';
import { ObjectType, Field, ID, InputType, ArgsType, Int } from 'type-graphql';
import { Book } from '../book/book.entity';
@Entity()
@ObjectType()
export class Author extends BaseEntity {
@PrimaryGeneratedColumn("uuid")
@Field(type => ID)
@ansrivas
ansrivas / main.go
Created November 13, 2017 16:35
csrf template validation using pongo2, chi and gorilla/csrf
package main
import (
"fmt"
"log"
"net/http"
"os"
"os/signal"
"syscall"
"time"
@adam-p
adam-p / Local PR test and merge.md
Last active September 18, 2025 16:14
Testing a pull request, then merging locally; and avoiding TOCTOU

It's not immediately obvious how to pull down the code for a PR and test it locally. But it's pretty easy. (This assumes you have a remote for the main repo named upstream.)

Getting the PR code

  1. Make note of the PR number. For example, Rod's latest is PR #37: Psiphon-Labs/psiphon-tunnel-core#37

  2. Fetch the PR's pseudo-branch (or bookmark or rev pointer whatever the word is), and give it a local branch name. Here we'll name it pr37:

$ git fetch upstream pull/37/head:pr37
@jcinis
jcinis / gist:2866253
Created June 4, 2012 04:02
Generate a random username for Django
from random import choice
from string import ascii_lowercase, digits
from django.contrib.auth.models import User
def generate_random_username(length=16, chars=ascii_lowercase+digits, split=4, delimiter='-'):
username = ''.join([choice(chars) for i in xrange(length)])
if split:
username = delimiter.join([username[start:start+split] for start in range(0, len(username), split)])