Skip to content

Instantly share code, notes, and snippets.

View dergachev's full-sized avatar

Alex Dergachev dergachev

View GitHub Profile

When debugging Drupal, I often stick dpm($some_array, "my array"); calls to see what the value of $some_array is. This fails spectacularly if the code I'm debugging is run very late in the request after drupal_get_messages() has already been called. (Eg most hook_preprocess_THEMEHOOK functions).

In that case, I've found it useful to add these helper functions somewhere (any enabled custom module, or even index.php), use them instead of dpm. They'll serialize objects to apache's error_log (wherever that is), which you can track by opening a terminal tab and running:

tail -f /var/log/apache2/error.log | tr '%' "\n"
@amirkdv
amirkdv / mechanic.rb
Last active August 29, 2015 14:02
Login, click through, and get the data you need from an HTTPS site
#!/usr/bin/env ruby
# Use Mechanize to automatically login, click through, and fetch the data you
# need from an HTTPS site. The following works for the McGill admission portal.
# ruby mechanic.rb
# # Ready for Review
# # Ready for Review
require 'rubygems'
require 'mechanize'

After running homesick clone dotfiles ...

E492: Not an editor command: Plugin 'gmarik/Vundle.vim'
line   96:
E492: Not an editor command: Plugin 'gmarik/vundle'
line   97:
E492: Not an editor command: Plugin 'kana/vim-fakeclip'
line   98:
E492: Not an editor command: Plugin 'jtratner/vim-flavored-markdown'
# Place this file in the same directory as `Vagrantfile'
# then simply require "vagrant-snapshot.rb" at the top of Vagrantfile.
require 'optparse'
Vagrant.commands.register(:snap) { Snap::Commands }
# Provide rake-like desc() 'inflected' documentation
# See http://stackoverflow.com/questions/2948328/access-attributes-methods-comments-programmatically-in-ruby
class Module
@jvns
jvns / index.html
Last active December 17, 2015 00:00
snake in d3
<html>
<head>
<title> it's a snake! </title>
<link rel="stylesheet" href="snake.css"> </link>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"> </script>
<script src="snake.js"> </script>
</head>
<body>
@neil-s
neil-s / README.md
Last active December 27, 2015 10:29 — forked from JoelBesada/README.md

This is an example command for Backtick. A Backtick command consists of some executable JavaScript and a bit of metadata in JSON.

Here are the required steps to create a command:

  1. Create a new Gist with a command.js and command.json file.

  2. Write your JavaScript in command.js. This will be injected into and executed on the page the user is currently on when they run it.

  3. Add some metadata to the command.json file:

  • name: The name of the command.
@praveenvvstgy
praveenvvstgy / README.md
Last active December 27, 2015 13:19 — forked from JoelBesada/README.md

This is an example command for Backtick. A Backtick command consists of some executable JavaScript and a bit of metadata in JSON.

Here are the required steps to create a command:

  1. Create a new Gist with a command.js and command.json file, or simply fork this one.

  2. Write your JavaScript in command.js. This will be injected into and executed on the page the user is currently on when they run it.

  3. Add some metadata to the command.json file:

  • name: The name of the command.
@mijoharas
mijoharas / README.md
Last active December 27, 2015 16:09 — forked from JoelBesada/README.md
Backtick command for is it down.

This is an example command for Backtick. A Backtick command consists of some executable JavaScript and a bit of metadata in JSON.

Here are the required steps to create a command:

  1. Create a new Gist with a command.js and command.json file, or simply fork this one.

  2. Write your JavaScript in command.js. This will be injected into and executed on the page the user is currently on when they run it.

  3. Add some metadata to the command.json file:

  • name: The name of the command.
@cesarmiquel
cesarmiquel / README.md
Last active December 27, 2015 20:39 — forked from JoelBesada/README.md
Make Drupal issue queue information box sticky
@rusilko
rusilko / dev_start.sh
Last active April 15, 2017 04:48
Simple bash script to quickly fire up your Rails working environment.
#!/bin/bash
# Function displaying wrong usage information
# Proper usage is: ./dev_start.sh Rails-Project-Folder
usage()
{
cat << EOF
usage: $0 Rails-Project-Folder
EOF
}