Skip to content

Instantly share code, notes, and snippets.

View banagale's full-sized avatar

Rob Banagale banagale

View GitHub Profile
function rvc.toggleAIPatrol()
isAutoPatrolOn = not isAutoPatrolOn
if isAutoPatrolOn and isPlayerDriving then
AI.TASK_VEHICLE_DRIVE_WANDER(playerPed, playerVehicle, 30, 0xC00AB)
rvc.updateMenus("PATROL MODE - ON", nil)
else
isAutoPatrolOn = false
AI.TASK_PAUSE(playerPed, 1)
rvc.updateMenus("PATROL MODE - OFF", nil)
end
-- Realistic Vehicle Controls v1.3.1
-- by skyrayfox
-- Changelog:
-- 1.3.1
-- library hotfix
-- 1.3:
-- Auto-Drive to waypoint (AI will try to follow all traffic code, press "W,S or Space" to disengage)
-- Auto-Patrol the area (AI will randomly drive the vehicle around, following the fraffic code)
{
"Website": [],
"default": ["inherit.allow-vpns", "minehq.vpn.bypass"]
}
{
"Website": [],
"default": ["inherit.epic"]
}
@banagale
banagale / gist:47a2163f4e9a55390bc6d5df4d8192b7
Created March 25, 2019 14:51
Registering Admin for User and profile model in one
@admin.register(CustomUser)
class CustomUserAdmin(UserAdmin):
fieldsets = UserAdmin.fieldsets + (('Custom Info', {'fields': ('account_type', 'address1', 'address2', 'city', 'state', 'zip', 'phone', 'sms_consent', 'onesignal_id',)}),)
list_display = UserAdmin.list_display + ('account_type',)
list_filter = UserAdmin.list_filter + ('account_type',)
icon = '<i class="material-icons">person</i>'
# Squash X commits with an opportunity to update the message headline and body:
git reset --soft HEAD~X &&
git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"
class Profile(TimeStampedModel):
user = models.OneToOneField(User, null=True, blank=True, related_name='profile', on_delete=models.CASCADE)
organization = models.ForeignKey('home.Organization', null=True, blank=True, on_delete=models.CASCADE)
personal_data = models.OneToOneField('PersonalData', null=True, blank=True, on_delete=models.CASCADE)
...
@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
# When user is created, build user profile and create payinfo instance.
# See also accounts.forms.SignupForm.signup for other signup steps
if created:
profile = Profile.objects.create(user=instance)
profile.payment_info = PaymentInfo.objects.create()
try:
instance.profile.account_type = AccountType.objects.get(name='Basic')
except AccountType.DoesNotExist:
@banagale
banagale / postgres.log
Created August 8, 2020 18:06
Example Postgres Errors due to Nginx passive health check (random 502, intermittent 502)
db_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
db_1 |
db_1 | 2020-08-07 21:04:53.734 UTC [1] LOG: starting PostgreSQL 12.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 9.3.0) 9.3.0, 64-bit
db_1 | 2020-08-07 21:04:53.734 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db_1 | 2020-08-07 21:04:53.734 UTC [1] LOG: listening on IPv6 address "::", port 5432
db_1 | 2020-08-07 21:04:53.738 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2020-08-07 21:04:53.771 UTC [20] LOG: database system was shut down at 2020-08-07 21:04:52 UTC
db_1 | 2020-08-07 21:04:53.775 UTC [1] LOG: database system is ready to accept connections
db_1 | 2020-08-07 21:05:24.660 UTC [30] LOG: invalid length of startup packet
db_1 |
@banagale
banagale / zoom_utils.py
Last active August 31, 2021 22:24
Python 3.6+ Implementation of Zoom.us SDK Signature Generation
import time
import base64
import hashlib
import hmac
def generate_signature(sig_ingredients: dict) -> str:
"""Python 3.6+ implementation of Zoom Signature Generation
@banagale
banagale / useCustomHookDebugPattern.js
Created October 9, 2020 21:13
A pattern for outputting debug from a custom react hook
import { useEffect, useState } from "react";
export function useCustomHookDebugPattern(arg1, arg2, arg3, message, something, setSomething) {
// Watch for loop progress
const [count, setCount] = useState(1);
// Additional local state
const [prevMessageId, setPreviousMessageId] = useState(undefined);
useEffect(() => {
// Increment hook count