Skip to content

Instantly share code, notes, and snippets.

View pixel5's full-sized avatar
💭
"You know what our users really want? To update their status." -github

Aaron Baxter pixel5

💭
"You know what our users really want? To update their status." -github
View GitHub Profile
@pixel5
pixel5 / bootstrap_menu_badges.php
Last active July 15, 2016 19:52
Drupal Bootstrap Menu Link Badges
<?
function MODULE_preprocess_menu_link(array &$variables) {
// Set your menu item here. Use the path you'd use to get to it via URL, no preceding slashes!
$link_path = 'path/to/item';
if ($variables['element']['#original_link']['link_path'] == $link_path) {
// This is where you get the number or string that shows up in the badge
$badge_count = MODULE_badge_count();
if (!empty($badge_count)) {
// Tell Drupal that this menu link contains HTML
@pixel5
pixel5 / base.php
Created July 11, 2016 17:57
Base function
<?
/**
* Base function for LHAC API
*/
$app->get('/', function (Request $request, Response $response) {
$response->getBody()->write("Welcome to the LHAC API.");
return $response;
});
@pixel5
pixel5 / stupid_logic.php
Created June 29, 2016 14:53
ridiculous date string comparison
<?php
// Make sales chart data
$i = 1;
foreach ($master['eom'] as $key => $eom) {
$key_compare = intval(substr($key, -2));
$starting_index_month = intval(substr($EOM_STARTING_INDEX + ($i - 1), -2));
$month_compare = $starting_index_month <= 12 ? $starting_index_month : $starting_index_month - 12;
$diff = $key_compare - $month_compare;
@pixel5
pixel5 / blazeit_snip.py
Created September 23, 2015 19:28
blazeit upgrade
if number == 420 and source == "g2wolf":
response = "Oh look g2wolf has rolled yet another illegitimate 420."
elif number == 420:
response = u"{0} \u00034ROLLED A \u00038DANK 420 \u00033#SMOK".format(source)
elif number != 0:
response = source + " rolled " + str(number)
@pixel5
pixel5 / blazeit.py
Created August 19, 2015 15:30
.blazeit command for BigBen
import irclib
import random
import datetime
class blazeit:
def on_pubmsg(self, nick, connection, event):
message = event.arguments()[0]
source = event.source().split('!')[0]
# Retrieve stored quote
@pixel5
pixel5 / blaseit.py
Created July 17, 2015 16:25
BigBen .blazeit
import irclib
import random
import datetime
class blazeit:
def on_pubmsg(self, nick, connection, event):
message = event.arguments()[0]
source = event.source().split('!')[0]
# Retrieve stored quote
@pixel5
pixel5 / quote.py
Created June 16, 2015 18:53
BigBen Quote Module
import irclib
import random
class quote:
def on_pubmsg(self, nick, connection, event):
message = event.arguments()[0]
source = event.source().split('!')[0]
# Retrieve stored quote
if message.startswith(".quote"):
words = message.split()
@pixel5
pixel5 / inputgroup_example_form.php
Created June 1, 2015 18:22
input-group example form
<?php
function inputgroup_example_form($form,&$form_state) {
$form = array();
$form['i'] = array(
'#type' => 'textfield',
'#attributes' => array(
'placeholder' => 'input-groups in drupal!',
),
@pixel5
pixel5 / form_example_2.php
Last active August 29, 2015 14:21
Form Example 2
<?php
// This is your page function, where your content is rendered.
// $id is a 'page argument' (see Drupal hook_menu documentation)
function MYMODULE_page_function($id) {
$output = '';
// MYMODULE_get_values represents a function for a query that
// retrieves values from the database and accepts $id as an
// argument to be used as a query condition.
@pixel5
pixel5 / form_example_1.php
Created May 15, 2015 17:39
Form Example 1
<?php
function MYMODULE_example_form($form, &$form_state) {
$form = array();
$form['name'] = array(
'#type' => 'textfield',
'#title' => t("Your Name"),
);