Skip to content

Instantly share code, notes, and snippets.

View jbn's full-sized avatar

John B Nelson jbn

View GitHub Profile
import json
import pathlib
import tweepy
import pickle
from collections import defaultdict
import pandas as pd
from dateutil.parser import parse as parse_time
def load_api():
import numpy as np
n, syn, ack = 240, "SYN", "ACK"
k = n//4
idx = sorted(zip(np.random.randint(0, n, k), np.random.choice([syn, ack], k)))
corruption = []
for i in range(n):
while idx and idx[0][0] <= i:
import tweepy # pip install tweepy
import json
import time
from missing_builtins import chunker # pip install missingbuiltins
with open("twitter_creds.json") as fp: # Yours with the fields below
creds = json.load(fp)
auth = tweepy.OAuthHandler(creds['appKey'], creds['appSecret'])
auth.set_access_token(creds['userToken'], creds['userSecret'])
api = tweepy.API(auth)
sudo apt-get install jq # See: https://stedolan.github.io/jq/download/
take Virus # or, mkdir Virus && cd Virus
python -m venv env
source env/bin/activate
pip jmespath twarc # https://github.com/DocNow/twarc
twarc configure # https://github.com/DocNow/twarc#quickstart
twarc filter "#TraceableMemeticVirus" | tee -a virus.jsonl | jq '. | {id: .id, who: .user.screen_name, what: .text}'
# Copyright 2019 Google LLC.
# SPDX-License-Identifier: Apache-2.0
# This snippet shows you how to use Blob.generate_signed_url() from within compute engine / cloud functions
# as described here: https://cloud.google.com/functions/docs/writing/http#uploading_files_via_cloud_storage
# (without needing access to a private key)
# Note: as described in that page, you need to run your function with a service account
# with the permission roles/iam.serviceAccountTokenCreator
import os, google.auth
from google.auth.transport import requests
# print time spent in all contexts
bosmang
# print current context
bosmang current
bosmang new -t <context> \
[--parent <content>] \
-m "<why are you spending time here>?"

Keybase proof

I hereby claim:

To claim this, I am signing this object:

import random
def sample(freqs_or_probs, precomputed_max_over_freqs_or_probs=None):
x = freqs_or_probs
n = len(x)
max_value = precomputed_max_over_freqs_or_probs or max(x)
while True:
i = int(n * random.random())
@jbn
jbn / gremlin_noteboo.ipynb
Created September 12, 2019 17:19
gremlin_python comparison for string execution versus local g
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import os
import re
import shutil
import subprocess
ROOT_DIR = "overleaf_kludge"
DISSERTATION_FILES_DIR = os.path.join(ROOT_DIR, "_jbn_dissertation_files")