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"
@dergachev
dergachev / Makefile
Last active August 29, 2015 13:57
Makefile for partial re-indexing while working with search_api
#============================================================================
# Utilities
#============================================================================
num_items_to_index = $(shell drush sqlq "SELECT COUNT(*) FROM search_api_item;" --extra=--skip-column-names)
index_name = coursecal_content
index_id = $(shell drush php-eval 'print search_api_index_load("$(index_name)")->id')
'use strict';
window.addEventListener("DOMContentLoaded", SL_GOOGLE_WPT(), false);
document.addEventListener('mousedown',function(){SL_HideButton();},!1);
document.addEventListener('mouseup',function(e){QuickBubbleInit(e);},!1);
window.addEventListener("load", setTimeout('SL_Hider()',500), false);
wget http://downloads.sourceforge.net/gparted/gparted-live-0.18.0-1-i486.iso
# got path from VBox GUI
cd '/Users/dergachev/VirtualBox VMs/docker-vm_default_1389213567886_15275'
VBoxManage clonehd box-disk1.vmdk cloned.vdi --format vdi
VBoxManage modifyhd cloned.vdi --resize 102400
VBoxManage clonehd "cloned.vdi" box-disk1-100gb.vmdk --format vmdk
# go to VBox GUI and attach box-disk1-100gb.vmdk in storage section
# also create new IDE controller, and then add gparted.iso as image (need to create blank one first, UI was buggy)
@dergachev
dergachev / Makefile
Created July 3, 2014 16:58
google-translation-experimentation
working:
@echo "WORKING"
time curl 'https://translate.google.com/translate_a/single?client=t&sl=fr&tl=en&hl=en&dt=bd&dt=ex&dt=ld&dt=md&dt=qc&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&oc=1&prev=conf&psl=auto&ptl=en&otf=1&it=sel.7964&ssel=3&tsel=0&q=contravention' \
-H 'pragma: no-cache' -H 'accept-encoding: gzip,deflate,sdch' -H 'accept-language: en-US,en;q=0.8,fr;q=0.6' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36' -H 'x-chrome-uma-enabled: 1' -H 'accept: */*' -H 'cache-control: no-cache' \
-H 'referer: https://translate.google.com/' \
-H 'x-client-data: CMy1yQEIlLbJAQiltskBCKm2yQEIxLbJAQi4iMoBCOmIygEIqZTKAQ==' \
--compressed \
| jq '.'
query=contravention
====================
Test name: test with tilde, should print NULL
====================
INPUT:
---
1: a
2: ~
@dergachev
dergachev / Vagrantfile.docker
Created October 1, 2014 12:16
Vagrantfile for docker
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "trusty64"
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"

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'

Je veux seulement développer des logiciels propriétaires car cela m'est égal si la toile mondiale est ruinée.

Je veux toujours rester fidèle à Linux bien qu'on me force la main à développer en Windows.

À mes yeux, un bon développeur ne gaspille pas de temps pour rédiger des guides pratiques ou créer les essais d'un programme pourvu qu'on utilise un système pour gérer toutes les versions des ensembles de données.

Je cherche un logiciel pour acquérir la connaissance du français de crainte que je sois dénoncé comme espion russe.

Je peux me croiser les bras pendant que mes créations se promeuvent elles-mêmes.

diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb
index b381fbc..b4a4aad 100644
--- a/app/controllers/my_controller.rb
+++ b/app/controllers/my_controller.rb
@@ -132,7 +132,7 @@ class MyController < ApplicationController
@user = User.current
layout = @user.pref[:my_page_layout] || {}
# remove if already present in a group
- %w(top left right).each {|f| (layout[f] ||= []).delete block }
+ %w(top left right bottom).each {|f| (layout[f] ||= []).delete block }