Skip to content

Instantly share code, notes, and snippets.

View kossoff's full-sized avatar
🏠
Working from home

Anthony kossoff

🏠
Working from home
View GitHub Profile
@kossoff
kossoff / change_modules_location_in_drupal.txt
Created July 3, 2016 07:10
How to move installed modules from /sites/all/modules/* to /sites/all/contrib/modules/*
I restored a backup from production locally and tried to just move things and hit admin/modules or to run registry_rebuild() but it didn't stop fatal errors from being thrown. This makes sense to me since some modules may use includes or whatever in their hook_init(), or you may have a menu router path set that depends on a module or include that Drupal can't find on bootstrap. Ultimately, this is what I did (your paths may be different):
Step 1: Replace sites/all/modules with sites/all/modules/contrib
UPDATE system SET filename = REPLACE(filename, 'sites/all/modules', 'sites/all/modules/contrib');
UPDATE registry SET filename = REPLACE(filename, 'sites/all/modules', 'sites/all/modules/contrib');
UPDATE registry_file SET filename = REPLACE(filename, 'sites/all/modules', 'sites/all/modules/contrib');
Step 2: Replace sites/all/modules/contrib with sites/all/modules/custom for custom namespaced modules
UPDATE system SET filename = REPLACE(filename, 'sites/all/modules/contrib', 'sites/all/modules/custom') WHER
@kossoff
kossoff / test.html.slim
Created September 8, 2016 08:19
Custom parameters for jQuery Datatables with server-side processing
label
input#test-checkbox type="checkbox"
|Test checkbox
table#test-table
javascript:
$(document).ready(function() {
var table = $("#test-table").dataTable( {
"ajaxSource": '#{test_datatable_path}',
@kossoff
kossoff / watcher.rb
Created November 8, 2016 09:55
Service for watch Dropbox folder on linux & send notifications to Slack if new files added
#!/home/RUBYUSER/.rvm/rubies/ruby-2.3.0/bin/ruby
require 'rubygems'
require 'rb-inotify'
require 'slack-notifier'
watcher = INotify::Notifier.new
notifier = Slack::Notifier.new "https://hooks.slack.com/services/SLACKWEBHOOKURL"
notifier.channel = '#CHANNEL_NAME'
@kossoff
kossoff / puma.rb
Created August 17, 2019 10:04
Puma config template
#!/usr/bin/env puma
# The directory to operate out of.
#
# The default is the current directory.
#
# directory '/u/apps/lolcat'
# Use an object or block as the rack application. This allows the
# config file to be the application itself.
def luhn(code)
(code
.chars # Break into individual digits
.map(&:to_i) # map each character by calling #to_i on it
.reverse # Start from the end
.map.with_index { |x, i| i.odd? ? x * 2 : x } # Double every other digit
.map { |x| x > 9 ? x - 9 : x } # If > 9, subtract 9 (same as adding the digits)
.inject(0, :+) % 10).zero? # Check if multiple of 10
end