Skip to content

Instantly share code, notes, and snippets.

View michaelfward's full-sized avatar
😃

Michael F. Ward michaelfward

😃
  • United States
View GitHub Profile

Keybase proof

I hereby claim:

  • I am michaelfward on github.
  • I am anemos (https://keybase.io/anemos) on keybase.
  • I have a public key ASBpukXG_MkyzHZzGw3d5mgdjcgkvsn0JG9ehzFdpXlaBgo

To claim this, I am signing this object:

@michaelfward
michaelfward / selenium-ext.py
Created April 10, 2018 05:23
Example of adding WebPage methods to PhantomJS webdriver
from selenium.webdriver import PhantomJS, DesiredCapabilities
from selenium.webdriver.remote.remote_connection import RemoteConnection as Remote
from selenium.webdriver.phantomjs.service import Service
from selenium.webdriver.remote.command import Command
import warnings
from selenium.webdriver.remote.webdriver import WebDriver as _RemoteWebDriver
class PhantomCommands(Command):
@michaelfward
michaelfward / keybase.md
Created August 22, 2017 17:49
Keybase Proof

Keybase proof

I hereby claim:

  • I am michaelfward on github.
  • I am michaelfward (https://keybase.io/michaelfward) on keybase.
  • I have a public key ASAqsLHSXd-qi7x4C3PkFtlU-wckr7AQK4L_5WVDuYSrPQo

To claim this, I am signing this object:

@michaelfward
michaelfward / generateAccessToken.js
Created May 20, 2015 23:54
Function to generate facebook access token. Requires the https library, an object named keys with app ID and client secret, and facebook-node-sdk
function generateAccessToken(callback){
var requestUrl = 'https://graph.facebook.com/oauth/access_token?client_id='+keys.facebook.appID+'&client_secret='+keys.facebook.secret+'&grant_type=client_credentials';
https.get(requestUrl, function(response){
response.on('data', function(data){
var token = data.toString('utf-8').split("access_token=");
FacebookClient.setAccessToken(token[1]);
callback();
});
}).on('error', function(error){
@michaelfward
michaelfward / tumblr_url_finder.rb
Created May 6, 2015 16:53
Pulls image URLs from Tumblr Posts pulled from the API. Programmed for a twitter robot.
def get_html file
regex = /.*(media.*\.jpg)/
fd = File.open("./img/#{file}", "r")
fd.each_line do |line|
if (regex =~ line) == 0
data = Regexp.last_match
puts data[1]
end
end
@michaelfward
michaelfward / writestrings.rb
Last active August 29, 2015 14:18
Load a file and write it into a string declaration in your language of choice
#!/bin/usr/ruby
#reads a file and parses into a single string declaration in language of choice
#another little snippet to make my job easier when writing lots of code
#programmed by michael ward
# h3xc0ntr0l@gmail.com | gists.github.com/michaelfward
# ***************************************
# example scrips
# with readfiles
@michaelfward
michaelfward / indenter.rb
Last active August 29, 2015 14:18
ruby script to adjust lines a through b (i made it for when i copy and paste large chunks of code but don't want to fix my indentations. keep a uniform pattern throughout, and voila)
#programmed by michael ward
#h3xc0ntr0l@gmail.com
def adjustline(line, off)
str = ""
1.upto(off) {|x| str << " "}
str << line
str
end
@michaelfward
michaelfward / writefiles.rb
Created March 30, 2015 22:55
Copy contents of multiple files (passed as a command line argument of a file containing the paths) into a single file
#!/bin/ruby
def getfile(path)
content = []
content[0] = "from: #{path}\n\n\n" #hopefully makes the output easier to read
fd = File.open(path.chomp, "r")
fd.each_line {|x| content.push(x)}
content.push("\n\n")
$destination_output.push(content)
puts "successfully got #{path}"
@michaelfward
michaelfward / jsfunctionbuilder.rb
Last active August 29, 2015 14:17
If you're like me, you write a ton of HTML+CSS when doing web development, and write all the javascript later. Point this script at your html files to automatically generate function declarations. NOTE: move the script file after use, because it will be destroyed each time
#coded by michael ward
#i wrote a bunch of client facing code to render different stuffs
#and decided to write all the javascript functions later and
#only focus on the CSS and HTML, and i realized it was a pain
#to go and get all the functions i needed to write, etc... so..
#voila
#*-------------------------------------------------*
#i want to port it to be able to take 1/2 argument *
#that would either a) read dirs for all html files *