Skip to content

Instantly share code, notes, and snippets.

Avatar

Zac Sweers ZacSweers

View GitHub Profile
View pub_machine
#!/bin/bash
## Source this to add the functions to your environment
function choice {
file=${1}
lc=$(wc -l < $file)
if [ ${lc} -gt 0 ]; then
sed -n "$((1 + $RANDOM % ${lc})) p" ${file}
@BobertForever
BobertForever / delete_facebook_group_memebers.py
Last active Aug 29, 2015
Delete all members of a facebook group using Selenium
View delete_facebook_group_memebers.py
import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from facepy import GraphAPI
import contextlib
import time
import threading
usr = 'FB_USER'
pwd = 'FB_PASS'
View gist:b12f10e3951cf595664c
public class MenuPreference extends ListPreference {
private View anchor;
public MenuPreference(Context context) {
super(context);
}
public MenuPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
@tecoholic
tecoholic / xfb.py
Created May 23, 2011
This sample code (written in Python) demonstrates integrating Facebook Chat using the X-FACEBOOK-PLATFORM authentication mechanism.
View xfb.py
#!/usr/bin/env python
# This is a demonstration script for Facebook Chat
# using the X-FACEBOOK-PLATFORM SASL mechanism.
# It requires pyfacebook and pyxmpp to be installed.
# This client only works for desktop applications (configured in the
# developer app), and uses the old-style auth.getSession mechanism to get a
# Facebook session. For newer-style or web apps, only the
# `get_facebook_client` function should have to change.
@blech
blech / caltrain.geojson
Last active Dec 3, 2015
Caltrain Ridership
View caltrain.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@agscala
agscala / vine2gif.py
Created Jan 30, 2013
python vine2gif.py [vine_url] [output_file] Scrapes vine url, downloads video, and converts the file to a gif with mplayer
View vine2gif.py
from pyquery import PyQuery as pq
import sys
import subprocess
import os
from urllib2 import urlopen, URLError, HTTPError
def convert(input_file, output_gif):
print "CONVERT", input_file, " => ", output_gif
subprocess.call(["mplayer", input_file, "-ao", "null", "-ss", "0:0:0", "-endpos", "6", "-vo", "gif89a:fps=8:output=%s" % output_gif, "-vf", "scale=240:180"])
@sabadow
sabadow / monkeyrunnerTestSuite.py
Created Oct 25, 2013
github / gauges-android monkey runner
View monkeyrunnerTestSuite.py
# Imports the monkeyrunner modules used by this program
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection()
# Installs the Android package. Notice that this method returns a boolean, so you can test
# to see if the installation worked.
device.installPackage('../app/target/gauges-android-1.0.apk')
@cpatulea
cpatulea / gist:7394412
Created Nov 10, 2013
Find Python string literals that should probably be Unicode
View gist:7394412
#!/usr/bin/python
import ast, _ast, os
for root, dirs, files in os.walk('.'):
for name in files:
if name.endswith('.py'):
full = os.path.join(root, name)
t = ast.parse(open(full).read())
for n in ast.walk(t):
if isinstance(n, _ast.Str) and not isinstance(n.s, unicode):
View RobolectricGradleSetup.md

Set up Robolectric with Gradle

  1. Open your top level build.gradle file.

  2. Add Sonatype repo to buildscript repositories and Square Gradle Android Test Plugin to buildscript dependencies. (Older Gradle projects may automatically put this buildscript code in your project build.gradle, in which situation you should put the following in that file.)

@MichaelEvans
MichaelEvans / appcompat.diff
Last active Mar 27, 2016
Changelog for Support Libraries v23.2.0 -> v24.0.0-alpha1
View appcompat.diff
diff -U 0 -N appcompat-v7-23.2.0_ff0f8a1a/android.support.v7.app.AppCompatDelegateImplV7$PanelFeatureState appcompat-v7-24.0.0-alpha1_4f276de6/android.support.v7.app.AppCompatDelegateImplV7$PanelFeatureState
--- appcompat-v7-23.2.0_ff0f8a1a/android.support.v7.app.AppCompatDelegateImplV7$PanelFeatureState 1969-12-31 19:00:00.000000000 -0500
+++ appcompat-v7-24.0.0-alpha1_4f276de6/android.support.v7.app.AppCompatDelegateImplV7$PanelFeatureState 2016-03-09 19:28:22.000000000 -0500
@@ -0,0 +1,5 @@
+public final class android.support.v7.app.AppCompatDelegateImplV7$PanelFeatureState {
+ public boolean qwertyMode;
+ public boolean hasPanelItems();
+ public void clearMenuPresenters();
+}
diff -U 0 -N appcompat-v7-23.2.0_ff0f8a1a/android.support.v7.view.WindowCallbackWrapper appcompat-v7-24.0.0-alpha1_4f276de6/android.support.v7.view.WindowCallbackWrapper