Skip to content

Instantly share code, notes, and snippets.

View lucahammer's full-sized avatar
💭
Cleaning code.

Luca Hammer lucahammer

💭
Cleaning code.
View GitHub Profile
@lucahammer
lucahammer / multiprocessing-test.py
Created February 26, 2020 15:12
Testing python multiprocessing
from multiprocessing import Pool
import jsonlines
from datetime import datetime
def get_full_text(tweet):
if tweet['truncated']:
return(tweet['extended_tweet']['full_text'])
return (tweet['text'])
def dothings(tweets):
@lucahammer
lucahammer / perf_3900x_windows10.ipynb
Created February 26, 2020 14:56
Performance Test. Ryzen R9 3900X Windows 10
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lucahammer
lucahammer / perf_4670k_windows10.ipynb
Created February 26, 2020 14:54
Performance Test. Intel i5 4670k at 4.5GHz Windows 10
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lucahammer
lucahammer / perf_3900x_ubuntu.ipynb
Last active February 26, 2020 13:32
Performance Test. Ryzen 9 3900X Ubuntu 18.04
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lucahammer
lucahammer / retweetnetwork.py
Last active July 11, 2022 16:36
Example script to create a dynamic network gexf file for Gephi from a jsonl file Article: https://lucahammer.com/?p=367
'''
MIT License
Copyright (c) 2019 Luca Hammer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@lucahammer
lucahammer / premiumapi.py
Last active April 6, 2021 17:22
Example script to collect old Tweets with the Twitter Premium Search API. Article: https://lucahammer.com/?p=350
'''
MIT License
Copyright (c) 2019 Luca Hammer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
byobu https://byobu.org/
log2ram https://github.com/azlux/log2ram
import json_lines
import pprint
pp = pprint.PrettyPrinter(indent=1)
def get_companies(line_number=0,lines=1):
"""
Returns as many companies as you want as a list.
The higher the starting line, the longer it takes.
"""
@lucahammer
lucahammer / cells-to-rgb.gs
Last active September 22, 2018 10:32
Google script to change the background of a cell based on HSL values in other cells. (Select three cells with H, S and L values and click the Button under Custom in the menu)
// Change this to the column numbers of your HSL values
// A == 1, B == 2,...
var hColumn = 5;
var sColumn = 6;
var lColumn = 7;
var ui = SpreadsheetApp.getUi();
var sheet = SpreadsheetApp.getActiveSheet();
// setup Buttons
@lucahammer
lucahammer / mastodon-hashtag-network.py
Last active April 17, 2022 06:15
Python script to generate a GDF for Gephi to visualize the Mastodon Hashtag Network https://vis.social/web/statuses/100634263439065513
from multiprocessing import Pool
import requests
import datetime
import time
MAX_PROCESSES = 100 #number of python processes that can run in parallel
TOOTS_PER_INSTANCE = 4000 #multiples of 40
MASTOVERSE = ["mstdn.jp","pawoo.net","friends.nico","mastodon.social","mimumedon.com"] #instances you want to examine
def get_local_timeline(instance_url, count=80):