Skip to content

Instantly share code, notes, and snippets.

View noahbass's full-sized avatar

Noah Bass noahbass

View GitHub Profile
@noahbass
noahbass / README.md
Last active April 4, 2019 05:01
google docs - insert data from an external form to a spreadsheet
@noahbass
noahbass / nodejs-tcp-example.js
Created September 18, 2018 23:49 — forked from tedmiston/nodejs-tcp-example.js
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
import XCTest
typealias Quality = Int
typealias SellIn = Int
typealias UpdateRule = (Quality, SellIn) -> Quality
enum ItemType {
case normal
# First, run:
# virtualenv venv
# . venv/bin/activate
# pip install beautifultable
import csv
from beautifultable import BeautifulTable
# import numpy as np
# map: 6+2 -> graduation_date
@noahbass
noahbass / index.html
Last active July 26, 2016 13:10
Meteor external api example: bibles.org api
<head>
<title>meteor external api example</title>
</head>
<body>
<table>
<p>{{{verse.verse}}}</p>
<p>{{{verse.text}}}</p>
</table>
</body>
.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 / 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,
@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 / 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 / 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"
}
}
},