Skip to content

Instantly share code, notes, and snippets.

View smerrill's full-sized avatar
🤖
Attention is all you need

Steven Merrill smerrill

🤖
Attention is all you need
View GitHub Profile
<?php
function get_profile_data_wrapper($uid) {
$query = new EntityFieldQuery;
$result = $query->entityCondition('entity_type', 'profile2')->entityCondition('bundle', 'main')->propertyCondition('uid', $uid)->execute();
if (!empty($result)) {
try {
$entity_info = current($result['profile2']);
$entity_wrapper = entity_metadata_wrapper('profile2', $entity_info->pid);
return $entity_wrapper;
# Remote management
git remote -v
git remote add <remote-name> <url>
git remote set-url <remote-name> <url>
# Working with branches
git branch : Show all local branches git knows about
git branch -a : Show all branches on all remotes that git knows about
git log : Show the commits on the current local branch
git reset --hard <ref-name> : Reset the current branch to the given ref (a ref could be a commit hash or a branch name)
@smerrill
smerrill / lxc-centos
Created February 28, 2013 17:38 — forked from hagix9/lxc-centos
#!/bin/bash
#
# template script for generating CentOS container for LXC
#
#
# lxc: linux Container library
# Authors:
@smerrill
smerrill / VagrantFile
Created November 8, 2012 04:58
VagrantFile
Vagrant::Config.run do |config|
config.vm.define :lucid32 do |lucid32_config|
lucid32_config.vm.box = "lucid32"
lucid32_config.vm.forward_port 22, 22221
lucid32_config.vm.network :hostonly, "172.30.30.1"
end
config.vm.define :lucid64 do |lucid64_config|
lucid64_config.vm.box = "lucid64"
lucid64_config.vm.forward_port 22, 22222
@smerrill
smerrill / gist:3805715
Created September 30, 2012 02:56
Fun with filesystems and virtualization.
=== VirtualBox VM with root device on a ZFS zvol exported through FreeNAS's iSCSI
=== (4 disk RAIDZ2 volume populated with 4 x 2TB Seagate Barracuda 7200 RPM drives)
=== The Mac mini and the FreeNAS have a gigabit connection to one another
smerrill@stash-cache:~$ mysqlslap --auto-generate-sql --concurrency=100 --number-of-queries=10000 --engine=innodb
Benchmark
Running for engine innodb
Average number of seconds to run all queries: 13.877 seconds
Minimum number of seconds to run all queries: 13.877 seconds
Maximum number of seconds to run all queries: 13.877 seconds
@smerrill
smerrill / config.json
Created August 23, 2012 12:39
A sample jsHint config.json file to run on custom Drupal code.
{
"undef": false,
"predef": ["Drupal", "jQuery"],
"browser": true
}
(defn words [x] (re-seq #"[a-z]+" (lower-case x)))
(def NWORDS (frequencies (words (slurp "big.txt")))) ; @TODO: Move from slurp.
class drush::files {
file { "/usr/share/pear/drush/drushrc.php":
ensure => present,
source => "puppet:///modules/drush/$environment/drushrc.php",
require => Class["drush::packages"],
}
file { "/usr/share/pear/drush/aliases.drushrc.php":
ensure => present,
source => "puppet:///modules/drush/$environment/aliases.drushrc.php",
casper = require('casper').create({
verbose: true,
logLevel: "debug"
})
# Variables for the tests.
url = "http://georgia.gov"
breakpoints = [
[1280, 1024],
[960, 640],
@smerrill
smerrill / gist:2128465
Created March 19, 2012 23:37
Sample 1.0.1 Vagrantfile w/ NFS, host-only network, Puppet provisioning
# Set up some variables relating to which path Vagrant will try to share
# with the VM.
require 'pathname'
$docroot_name = "path/to/your/docroot"
$docroot_path = ""
# Test that the directory to be shared is in the right place and if it is,
# calculate the fully dereferenced path (since NFS exports will fail if you
# try to specify the path to a symlink.)
if !File.exists?("../#{$docroot_name}") then