Skip to content

Instantly share code, notes, and snippets.

View noahbass's full-sized avatar

Noah Bass noahbass

View GitHub Profile
@noahbass
noahbass / web-robot.applescript
Last active December 15, 2015 21:09
A simple webpage clicking robot script.
(*
Inscructions:
Change Safari to your selection of browser
Change nameOrIDofButton to the ID or Name of the button to be selected, find this in your dev tools. If you don't know what this es, you probably shouldn't try to use this
Then replace http://example.com with the url you want to be refreshed
*)
repeat 3 times
tell application "Safari"
do JavaScript "document.all(\"nameOrIDofButton\").click()" in document 1
delay 1
@noahbass
noahbass / airmech-launcher
Created April 27, 2013 17:18
A method to launch Airmech through an Applescript.
tell application "Google Chrome"
activate
open location "chrome-extension://hdahlabpinmfcemhcbcfoijcpoalfgdn/AirMech.html#"
end tell
@noahbass
noahbass / wordpress-bootstrap-gruntfile.js
Created May 24, 2013 21:34
A starter Gruntfile for use with WordPress Bootstrap by 320press.
module.exports = function(grunt){
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
less: {
production: {
files: {
"library/less/bootstrap.less": "library/css/bootstrap.css"
}
}
},
@noahbass
noahbass / better-wp-excerpts.php
Last active December 18, 2015 23:39
Better WordPress Excerpts
<?php
// better WordPress excerpts
// Usage: echo get_excerpt(250); (replace 250 with the number of characters)
function get_excerpt($count) {
$excerpt = get_the_content();
$excerpt = strip_tags($excerpt);
$excerpt = strip_shortcodes($excerpt);
$excerpt = substr($excerpt, 0, $count);
$excerpt = rtrim($excerpt, '.');
@noahbass
noahbass / protect-wp-login.php
Last active December 19, 2015 00:29
protect and redirect failed wordpress logins in the wp-login.php
<?php
// redirects and failed login attempts to the FBI cyber intelligence thingy
// adapted from http://css-tricks.com/snippets/htaccess/shock-teenage-gangsters-with-wp-config-redirect/
add_filter('login_redirect', 'catch_login_error', 10, 3);
function catch_login_error($redir1, $redir2, $wperr_user){
if(!is_wp_error($wperr_user) || !$wperr_user->get_error_code()) return $redir1;
switch($wperr_user->get_error_code()){
case 'incorrect_password':
case 'empty_password':
case 'invalid_username':
@noahbass
noahbass / wordoftheday.php
Created July 13, 2013 00:43
For getting the word of the day from dictionary.com and displaying it nice and pretty.
<?php
// adapted from http://bavotasan.com/2010/display-rss-feed-with-php/
$rss = new DOMDocument();
$rss->load('http://dictionary.reference.com/wordoftheday/wotd.rss'); // calling dictionary.com
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
.row {
margin-top: 0.5rem;
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.col {
flex: 1 1 8%;
margin: 0 0 0.5rem 0;
@noahbass
noahbass / README.md
Last active April 4, 2019 05:01
google docs - insert data from an external form to a spreadsheet
@noahbass
noahbass / 0_reuse_code.js
Created August 10, 2014 14:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@noahbass
noahbass / wp-email-login.php
Created August 23, 2014 21:15
Use the users email address to login in wordpress.
<?php
/* Use the users email address to login */
add_filter('authenticate', 'bainternet_allow_email_login', 20, 3);
/**
* bainternet_allow_email_login filter to the authenticate filter hook, to fetch a username based on entered email
* @param obj $user
* @param string $username [description]
* @param string $password [description]