Skip to content

Instantly share code, notes, and snippets.

View carwin's full-sized avatar
🍔
cheeseburger

Carwin Young carwin

🍔
cheeseburger
  • Missouri
View GitHub Profile
@carwin
carwin / SassMeister-input.scss
Created April 4, 2014 21:06
Generated by SassMeister.com.
// ----
// Sass (v3.3.4)
// Compass (v1.0.0.alpha.18)
// ----
@mixin some-color-name($color) {
@if type-of($color) == 'map' {
background-image: linear-gradient(map-get($color, key1), map-get($color, key2));
}
}
@carwin
carwin / element-background.scss
Created May 16, 2014 22:36
element background magic
@mixin element-background($color, $direction: top) {
@if type-of($color) == list {
background-color: nth($color, 1);
@include background-image(linear-gradient($direction, $color));
}
else {
@if ($color != 'none') {
$percent: alpha($color) * 100%;
$opaque: opacify($color, 1);
$solid-color: mix($opaque, white, $percent);
@carwin
carwin / your_module.module
Last active August 29, 2015 14:05
D7: Using the Picture module in code
<?php
/**
* Helper function.
*
* Prepares the necessary array for use with theme_picture.
*
* @param array $variables
* The image array loaded from field_get_items.
*
* @param string $group
@carwin
carwin / UpdateAndroidHosts
Created December 1, 2014 23:44
Update Android emulator hosts file
adb pull /system/etc/hosts /tmp/hosts
echo "192.168.57.1 test.example.com" >> /tmp/hosts
adb remount
adb push /tmp/hosts /system/etc
@carwin
carwin / d6_uc_cart_form_alter.php
Created September 6, 2012 01:09
Drupal 6: Use hook_form_alter() to remove the "Remove" button on Ubercart's cart form
<?php
function modulename_form_alter(&$form, $form_state, $form_id) {
switch ( $form_id ) {
case 'uc_cart_view_form':
/*
* This is how you can remove the "remove"
* button for each item.
*/
foreach($form['items'] as $k => $v ) {
if(is_integer($k) && isset($v['remove'])) {
@carwin
carwin / weathergist.php
Created September 6, 2012 01:46
PHP: Use Yahoo's Weather API, cURL, and SimpleXML to get current weather conditions given a WOEID.
<?php
/*
* This gist utilizes Yahoo's Weather API to snag the current
* weather conditions for any country given it's WOEID.
*
* - by Carwin Young
*/
/* Set up some location WOEIDs */
$Cambodia = 1020985; /* Phnom Pneh */
@carwin
carwin / d7_uc_extra_checkout_pane.php
Created September 7, 2012 17:37
Drupal 7: (UNTESTED) Add an extra pane to Ubercart's checkout form / review.
<?php
function yourmodule_custom_form($form, &$form_state, $term) {
/* Note: rather than passing a $term var, you could use arg(2) from the url */
drupal_set_title('Your Label: ' . ucwords($term));
// or
drupal_set_title('Your Label: ' . str_replace('%20',' ', arg(2)));
/* Make life easier: */
$school = ucwords($term);
@carwin
carwin / icons
Created September 8, 2012 09:28
A list of neat characters I don't want to forget about.
☎ - &#9742; &#x260e;
☂ - &#9730; &#x2602;
☑ - &#9745; &#x2611;
☒ - &#9746; &#x2612;
☐ - &#9744; &#x2610;
☁ - &#9729; &#x2601;
⌘ - &#8984; &#x2318;
♻ - &#9851; &#x267b;
@carwin
carwin / d7_theme_jquery_usage.js
Created September 12, 2012 17:43
Drupal 7: Proper implementation of jQuery in a Drupal theme.
(function ($) {
Drupal.behaviors.themename = {
attach: function(context, settings) {
// Add a hover class to nav items.
$('.mainnav nav a')
.hover(
function() {
$(this).addClass('hover');
},
function() {
@carwin
carwin / d7_html5_menus.php
Created September 13, 2012 17:26
Drupal 7: Change structure of all menus from pattern [ ul > li > a ] to a valid html5 pattern [ nav > a ]
<?php
/*
* Replace all menu tree <ul> elements with <nav>.
*/
function foo_menu_tree(&$variables) {
return '<nav>' . $variables['tree'] . '</nav>';
}
/*
* Removes <li> from all menu links, leaving only <a>s.
*/