Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from bs4 import BeautifulSoup
from time import sleep
from tqdm import tqdm
import os
import dbm
import csv
import requests
import random
desktop_agents = ['Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36',
@CaptainStabs
CaptainStabs / anes-2020-data.ipynb
Last active April 2, 2025 17:03
ANES 2020 data.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@CaptainStabs
CaptainStabs / election_data.py
Last active November 11, 2024 21:57
Separates Michigan voter data into democratic, republican, and independent votes
import os
import pandas as pd
folder = './elections/'
for file in os.listdir(folder):
df = pd.read_csv(folder + file, sep='\t', skipfooter=1)
df['OfficeDescription'].loc[1]
@CaptainStabs
CaptainStabs / converter.py
Created February 6, 2024 02:03
Qb-inventory to qs-inventory. Convert from qb to quasar inventory
import json
import pandas as pd
import csv
# Export from database by running `SELECT citizenid, inventory FROM players;`
# Make sure to export using an app like TablePlus and use the `Quote if needed` option. This will not work if you export from HeidiSQL
# The output should look something like this
'''
citizenid,inventory
AFN86608,"[{""slot"":1,""name"":""weapon_nightstick"",""type"":""weapon"",""info"":{""serie"":""54yiL4at180nbcg"",""quality"":100},""amount"":1}
RegisterNetEvent("919-admin:server:MonetaryAction", function(targetId, action, amount)
local src = source
if AdminPanel.HasPermission(src, "givetakemoney") then
if action == "givecash" then
Compat.PlayerActions.AddMoney(targetId, amount)
print("TARGETID", targetId)
print("name", getCharName(targetId))
local logMessage = string.format("**STAFF MEMBER %s** added £%d to **%s[%d]** (%s)'s **wallet**", GetPlayerName(src), amount, GetPlayerName(targetId), targetId, getCharName(targetId))
@CaptainStabs
CaptainStabs / client_customise_me.lua
Last active September 13, 2023 17:02
cd_dispatch custom 111 command
RegisterNetEvent('cd_dispatch:PillboxBell')
AddEventHandler('cd_dispatch:PillboxBell', function()
QBCore.Functions.Notify('You rang the bell letting NHS know that you are here.', "primary", 7500)
local data = exports['cd_dispatch']:GetPlayerInfo()
TriggerServerEvent('cd_dispatch:AddNotification', {
job_table = {'ambulance'},
coords = data.coords,
title = 'Somebody rang the bell at Pillbox',
message = 'Somebody rang the bell at Pillbox',
flash = 0,
@CaptainStabs
CaptainStabs / bsw_import.txt
Created April 28, 2023 22:35
bsw import stats
20-2850920.csv
Rows Processed: 117,244, Additions: 109,962, Modifications: 3,147, Had No Effect: 4,135
20-3749695.csv
Rows Processed: 256,321, Additions: 245,773, Modifications: 6,383, Had No Effect: 4,165
26-0194016.csv
Rows Processed: 170,777, Additions: 165,908, Modifications: 4,721, Had No Effect: 148
26-3603862.csv
@CaptainStabs
CaptainStabs / install.bat
Created February 8, 2023 15:07
invokeai_conda_installer.bat
@echo OFF
rem How to run a Python script in a given conda environment from a batch file.
rem from https://gist.github.com/maximlt/531419545b039fa33f8845e5bc92edd6
rem It doesn't require:
rem - conda to be in the PATH
rem - cmd.exe to be initialized with conda init
rem CREATE THE ENV PRIOR TO RUNNING THIS SCRIPT
rem Define here the path to your conda installation
@CaptainStabs
CaptainStabs / combined.csv
Created September 10, 2022 20:12
sale price data for LA and Riverside CA
We can't make this file beautiful and searchable because it's too large.
property_county,sale_datetime,sale_price
LOS ANGELES,2020-02-21 00:00:00,9
LOS ANGELES,2020-03-31 00:00:00,550005
LOS ANGELES,2020-02-28 00:00:00,750007
LOS ANGELES,2020-04-16 00:00:00,949009
LOS ANGELES,2020-12-03 00:00:00,1500015
LOS ANGELES,2020-08-24 00:00:00,2900029
LOS ANGELES,2020-11-17 00:00:00,3213032
LOS ANGELES,2020-04-14 00:00:00,2700027
LOS ANGELES,2020-08-24 00:00:00,331003