Skip to content

Instantly share code, notes, and snippets.

View BdVade's full-sized avatar

Victor Aderibigbe BdVade

View GitHub Profile
@MorganBorman
MorganBorman / main.py
Created December 9, 2012 04:33
A short example of how to use vertex array objects in PyOpenGL
import OpenGL.GL as GL
import OpenGL.GL.shaders
import ctypes
import pygame
import numpy
vertex_shader = """
#version 330
in vec4 position;
@valtron
valtron / capture_queries.py
Created February 25, 2014 18:56
Context manager for collecting queries executed in a Django environment.
class CaptureQueries(object):
"""
Context manager that captures queries executed by the specified connection.
Mostly copied from django.test.utils.CaptureQueriesContext.
"""
def __init__(self, connection = None):
if connection is None:
from django import db
connection = db.connection
@randallreedjr
randallreedjr / heroku-remote.md
Last active April 25, 2024 07:06
Add a Heroku remote to an existing git repo

Working with git remotes on Heroku

Generally, you will add a git remote for your Heroku app during the Heroku app creation process, i.e. heroku create. However, if you are working on an existing app and want to add git remotes to enable manual deploys, the following commands may be useful.

Adding a new remote

Add a remote for your Staging app and deploy

Note that on Heroku, you must always use master as the destination branch on the remote. If you want to deploy a different branch, you can use the syntax local_branch:destination_branch seen below (in this example, we push the local staging branch to the master branch on heroku.

$ git remote add staging https://git.heroku.com/staging-app.git
@Jonalogy
Jonalogy / handling_multiple_github_accounts.md
Last active July 10, 2024 16:57
Handling Multiple Github Accounts on MacOS

Handling Multiple Github Accounts on MacOS

The only way I've succeeded so far is to employ SSH.

Assuming you are new to this like me, first I'd like to share with you that your Mac has a SSH config file in a .ssh directory. The config file is where you draw relations of your SSH keys to each GitHub (or Bitbucket) account, and all your SSH keys generated are saved into .ssh directory by default. You can navigate to it by running cd ~/.ssh within your terminal, open the config file with any editor, and it should look something like this:

Host *
 AddKeysToAgent yes

> UseKeyChain yes

@bpartridge
bpartridge / patch_geos.py
Created December 19, 2021 04:08
Django GEOS patch for macOS arm64
def patch_geos_signatures():
"""
Patch GEOS to function on macOS arm64 and presumably
other odd architectures by ensuring that call signatures
are explicit, and that Django 4 bugfixes are backported.
Should work on Django 2.2+, minimally tested, caveat emptor.
"""
import logging
@BdVade
BdVade / a16z-crypto-canon.md
Created April 30, 2022 20:38 — forked from arthurgousset/a16z-crypto-canon.md
a16z's Crypto Canon (markdown)
@ARYAN-NIKNEZHAD
ARYAN-NIKNEZHAD / Django_Channels3_Custom_Auth_Middleware.py
Last active July 13, 2023 17:21 — forked from AliRn76/Django_Channels3_Custom_Auth_Middleware.py
Token authorization middleware for Django Channels 3
from django.contrib.auth.models import AnonymousUser
from rest_framework.authtoken.models import Token
from channels.db import database_sync_to_async
from channels.middleware import BaseMiddleware
from project.settings import SIMPLE_JWT, SECRET_KEY
from urllib.parse import parse_qs
import jwt
@database_sync_to_async
def get_user(token_key):