Skip to content

Instantly share code, notes, and snippets.

View underhilllabs's full-sized avatar

Bart Lantz underhilllabs

View GitHub Profile
@underhilllabs
underhilllabs / mysqli_dbcalls.php
Created November 20, 2015 00:17
mysqli database call with prepared statement
<php
$stmt = $mysqli->prepare("select * from sv_surveys where id=?");
$stmt->bind_param("i", $edt);
$stmt->execute();
$res = $stmt->get_result();
if($getQuery = $res->fetch_assoc()) {
// Do it!
}
$stmt->close()
?>
@underhilllabs
underhilllabs / form-validations.php
Last active October 26, 2015 18:35
Add validation to Drupal 7 form
<?php
/**
* Implements hook_form_form_id_alter().
*/
function dance_code_form_dance_code_session_request_form_alter(&$form, &$form_state, $form_id) {
$form['#validate'][] = 'dance_code_session_request_form_validate';
}
/**
@underhilllabs
underhilllabs / cat-names.md
Last active September 29, 2015 19:44
Cat name shortlist
  • Oliver Heaviside
  • Linus
  • Bigwig
  • Barclay
  • Toshiro Mifune
  • Aslak
  • Labeau
  • Bombur
  • Bjorn
@underhilllabs
underhilllabs / superfish-bartik.md
Last active September 30, 2015 18:40
Steps to installing Superfish menu on a custom Drupal Bartik theme

Install UC Denver Bartik Subtheme

  • copy and unzip ucdenver_bartik.zip to site/all/themes
cd sites/all/themes
cp ~/ucdenver-bartik.zip .
unzip ucdenver-bartik.zip
  • on the Admin > Appearance > ucdenver_bartik > settings page:
    • uncheck/disable main and secondary menus
  • uncheck/disable "site name"
@underhilllabs
underhilllabs / apache-config.conf
Created September 10, 2015 18:59
Apache Configuration with Phusion Passenger for putting a second-app in a sub-uri
<VirtualHost *:80>
ServerName www.testsinatra.com
DocumentRoot /websites/testsinatra/public
<Directory /websites/testsinatra>
Allow from all
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
Require all granted
</Directory>
require 'csv'
User = Struct.new(:name, :email, :country)
users = []
CSV.foreach("./users.csv", headers: true) do |row|
# skip blank rows
next unless row["Name"]
users << User.new(row["Name"], row["Email Address"], row["Country"])
end
@underhilllabs
underhilllabs / print-all-users-crontabs.bash
Last active August 29, 2015 14:28
Print all users cron jobs
for user in $(cut -f1 -d: /etc/passwd)
do
echo $user
crontab -u $user -l
done
# from http://stackoverflow.com/questions/134906/how-do-i-list-all-cron-jobs-for-all-users?rq=1
@underhilllabs
underhilllabs / The Technical Interview Cheat Sheet.md
Last active August 29, 2015 14:28 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@underhilllabs
underhilllabs / gist:169c60675e8adb10c82d
Last active August 29, 2015 14:27 — forked from acwright/gist:1944639
Sinatra / ActionMailer / Sendgrid / Heroku
require 'sinatra'
require 'action_mailer'
class Mailer < ActionMailer::Base
def contact
mail(
:to => "[email protected]",
:from => "[email protected]",
:subject => "Test") do |format|
format.text
@underhilllabs
underhilllabs / add_penny.rb
Created August 20, 2015 03:38
Open csv file, add penny to each numeric value in a certain column.
#!/usr/local/bin/ruby
require 'csv'
require 'bigdecimal'
filename = ARGV[0]
# split filename to get name and extension
(base, ext) = filename.split(/\./)
# create output file name
newf = "#{base}-processed.#{ext}"