Skip to content

Instantly share code, notes, and snippets.

View jacobbednarz's full-sized avatar
💭
I may be slow to respond.

Jacob Bednarz jacobbednarz

💭
I may be slow to respond.
View GitHub Profile
@jacobbednarz
jacobbednarz / gist:2196919
Created March 25, 2012 15:03
Dynamically update age
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title></title>
</head>
<body>
<p>My age is: <span id="age"></span></p>
</body>
@jacobbednarz
jacobbednarz / example.html
Created April 1, 2012 12:09
100% CSS div height
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>100% CSS div height</title>
<style>
html, body { height: 100%; }
#left_panel { height: 100%; }
</style>
</head>
#!/usr/bin/ruby
# Output a prettier version of the number
def prettify_number(number)
formatted_output = number.to_s.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1 ")
end
# Get the free space of a drive
def get_free_space(path)
bash_listing = `df -h #{path} | grep ^/ | awk '{ print $4;}'`
# Found at: https://github.com/defunkt/zippy/blob/master/lib/zippy.rb
# ♥
%w( rubygems cgi hpricot net/http open-uri ).each { |f| require f }
@jacobbednarz
jacobbednarz / gist:2755240
Created May 20, 2012 06:13
Removed file extensions using .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
@jacobbednarz
jacobbednarz / drupal-quick-dump.sh
Created May 8, 2013 05:13
Dump MySQL tables excluding certain tables.
#!/bin/bash
# Take a MySQL DB dump excluding some tables.
#
# Usage:
# ./drupal-quick-dump user host database
USER="$1"
HOST="$2"
DB="$3"
DATE=`date +%Y%m%d`

Exporting Views

This guide assumes you have a module ready to save the views but it does not have any Views integration or folder structure. Skip ahead if you've already created the folders and Views Hooks.

  • Add the views folder to your module.
  • Create a file called MODULENAME.views.inc inside the views folder.
  • Add a default_views folder inside the views folder.

Your module directory structure should now resemble something like this:

#!/usr/bin/php -q
<?php
/**
* @file
* Script to automate the transfer of all databases and files from one
* environment to another using Acquia Cloud API.
*/
@jacobbednarz
jacobbednarz / drupal_write_record_example.php
Last active December 30, 2015 04:29
Example of using drupal_write_record over a conditional db_insert and db_update.
<?php
// Let's say for argument sake $query is a database query that checks for the
// presence of an existing record and returns FALSE if nothing is found. In this
// example, we need to check for an existing record and update the row if it
// exists or create a new entry if it doesn't.
/**
* Bad
*/
0.00011992454528809
0.0055930614471436
6.7949295043945E-5
9.2029571533203E-5
0.00070881843566895
0.00023818016052246
0.00063109397888184
0.0012919902801514
0.00021719932556152
0.00012302398681641