Skip to content

Instantly share code, notes, and snippets.

View noahbass's full-sized avatar

Noah Bass noahbass

View GitHub Profile
@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]
@noahbass
noahbass / wp-site-last-updated.php
Created August 23, 2014 21:16
Site last updated function for wordpress
<?php
/*
Description: Show the last time the website was updated.
Usage: use <?php site_last_updated(); ?> anywhere in your theme's files
*/
function site_last_updated($d = '') {
$recent = new WP_Query("showposts=1&orderby=modified&post_status=publish");
if ( $recent->have_posts() ) {
input {
border: none;
box-shadow: none;
outline: 0;
background-color: #fff;
font-size: 3.125rem;
font-weight: 500;
color: #333;
height: auto;
padding: 0.5rem;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>MySQL Connection Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
#wrapper {
width: 600px;
margin: 20px auto 0;
union() {
// body
translate([0,0,0])
cylinder(30, r1=4, r2=3.5, $fn=100);
// cone
translate([0,0,30])
cylinder(10, 3.5, 1, $fn=100);
}
var index = lunr(function() {
this.field('title', {
boost: 10
})
this.field('body')
this.ref('id')
});
{% for post in site.posts %}
index.add({
@noahbass
noahbass / num2binary.py
Created November 11, 2014 16:28
convert an integer to a binary
i = 10
nums = []
if i == 0:
nums.append(0)
else:
while i >= 1:
if (i//2) % 2 == 0:
nums.append(1)
@noahbass
noahbass / binary2num.py
Created November 11, 2014 18:03
convert a binary to an integer
b = '10' # binary input
b = b[::-1]
number = 0
for i in b:
i = int(i)
if i != 0:
number += 2**i