Skip to content

Instantly share code, notes, and snippets.

View ZacSweers's full-sized avatar

Zac Sweers ZacSweers

View GitHub Profile
@ZacSweers
ZacSweers / FacebookGroupLikesCounter.py
Last active July 26, 2021 13:27
Python code for getting like stats from posts in a Facebook group
from Queue import Queue # Threadsafe queue for threads to use
from collections import Counter # To count stuff for us
import datetime # Because datetime printing is hard
from pprint import pprint
import time # Should be obvious
import subprocess # Used to send notifications on mac
import sys # Get system info
import threading # Should be obvious
import json # Also obvious
@ZacSweers
ZacSweers / crashcourse.md
Last active July 10, 2022 02:14
Python Reddit bot on Heroku

A crash course in setting up your Python Reddit bot on Heroku

You'll need to do the following:

  • You need to make your bot a python app. Do this by making another directory (can be the same name as the regular one) and put all your python code in that, and make an empty file called __init__.py in it as well. See how I structured mine if this isn't clear. In your base directory, create two files: "requirements.txt" and "runtime.txt". The requirements.txt file should be the output of pip freeze (you can run the command "pip freeze > requirements.txt"). If you're not using virtualenv, you'll need to go through after and delete all the lines with packages your code doesn't actually use. Check out mine to see what I mean. Runtime.txt just specifies with python version for heroku to use. Mine just has the line "python-2.7.4" in it. All of this will tell heroku to recognize your bot as a python app.

  • Make a heroku account and

@ZacSweers
ZacSweers / Presentbot.py
Last active August 29, 2015 13:56
Python Bot Presentation
# http://goo.gl/sxbh65
# Presentbot.py
import praw
import pickle
import time
# log in
# reading login info from a file, it should be username \n password
with open("login.properties", "r") as loginFile:
login_info = loginFile.readlines()
@ZacSweers
ZacSweers / flashnotifierAPI.java
Created February 18, 2014 09:57
Flashnotifier API Example
// Make an API request like this:
Intent i = new Intent("com.leepapesweers.flashnotifier.API");
// Put flash pattern in request
// OPTIONAL
ArrayList pattern = new ArrayList();
pattern.add(50);
pattern.add(50);
i.putIntegerArrayListExtra("flash_pattern", pattern);
@ZacSweers
ZacSweers / sublet_posts.md
Last active August 29, 2015 13:56
Sublet Group Post Rules

UT Sublets Group Post Rules

The bot checks for 3 main things:

  • Tag validity
  • Price reference
  • Length

Note: Capitalization doesn't matter.

apply plugin: 'java'
apply plugin: 'maven-publish'
group = 'com.demo'
version = '1.0.0'
sourceCompatibility = 1.7
repositories {
mavenCentral()
public class MenuPreference extends ListPreference {
private View anchor;
public MenuPreference(Context context) {
super(context);
}
public MenuPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
@ZacSweers
ZacSweers / HashUtil.java
Created January 31, 2015 02:02
HashUtil
/**
* Utility functions for hashing sets of values, based on the methods described in Ch. 3 of Effective Java
*/
public class HashUtil {
public static int hash(boolean... args) {
int result = 0;
for (boolean arg : args) {
result += 31 * result + (arg ? 1 : 0);
}
about
account
add
admin
api
app
apps
archive
archives
auth
@ZacSweers
ZacSweers / RxJava.md
Last active September 3, 2018 18:52 — forked from cesarferreira/RxJava.md
Party tricks with RxJava, RxAndroid & Retrolambda

View Click

Instead of the verbose setOnClickListener:

RxView.clicks(submitButton).subscribe(o -> log("submit button clicked!"));

Filter even numbers

Observable
    .just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)