Skip to content

Instantly share code, notes, and snippets.

View vladdancer's full-sized avatar
🖖

Vlad Moyseenko vladdancer

🖖
View GitHub Profile
@gheydon
gheydon / ExampleController.php
Created November 7, 2013 00:30
Drupal 8 Param Converters (Drupal 7 Auto Loaders)
<?php
/**
* @file
* Contains \Drupal\autoloader_example_d8\Controller\ExampleController.
*/
namespace Drupal\autoloader_example_d8\Controller;
use Drupal\Component\Utility\String;
@p1nox
p1nox / using_meld_on_mac.md
Last active January 16, 2025 08:44
Using meld on Mac

Using Meld merging tool on Mac

There are two ways of installing meld on osx (May 2023), using brew and .dmg package (from @yousseb). Since I found https://yousseb.github.io/meld/, I've installed it with .dmg package, but having macOS Ventura Version 13.4 (22F66) in place, it's not even starting for me. So I tried brew installation, and the application is working as expected, including symlink to start it from the terminal.

brew install --cask meld

# set meld as your default git mergetool
@chrisboulton
chrisboulton / ip_blacklist.lua
Last active September 19, 2024 15:42
Redis based IP blacklist for Nginx (LUA)
-- a quick LUA access script for nginx to check IP addresses against an
-- `ip_blacklist` set in Redis, and if a match is found send a HTTP 403.
--
-- allows for a common blacklist to be shared between a bunch of nginx
-- web servers using a remote redis instance. lookups are cached for a
-- configurable period of time.
--
-- block an ip:
-- redis-cli SADD ip_blacklist 10.1.1.1
-- remove an ip:
@kwokhou
kwokhou / angular-autoNumeric.js
Last active April 22, 2024 21:54
AngularJS directive for autoNumeric.js
// Directive for autoNumeric.js
// Require AngularJS, jQuery and autoNumeric.js
angular.module('crunch.ui.numeric', []).directive('crNumeric', [function () {
'use strict';
// Declare a empty options object
var options = {};
return {
// Require ng-model in the element attribute for watching changes.
require: '?ngModel',
// This directive only works when used in element's attribute (e.g: cr-numeric)
@voising
voising / gists_to_dash_db.rb
Last active October 21, 2021 21:32
Connect Gists with Dash (Code Snippet Manager)
#!/usr/bin/env ruby
if ARGV[0].nil? || ARGV[0].match(/-h/)
puts "Usage : #{$0} github_username dash_sqlite_db char_appended_to_keyword [no_comments]"
exit
end
require 'net/http'
require 'open-uri'
#require 'awesome_print'
@callado4
callado4 / behat-phantomjs-webdriver.md
Last active January 24, 2021 17:10
Instructions on how to make behat (with mink) use the phantomjs webdriver to run headless browser tests

Making behat use phantomjs for the tests

If you want to run it on phantomjs (a headless browser) you can add this profile to your behat.yml and you need phantomjs >= 1.8.0

phantomjs:
    extensions:
        Behat\MinkExtension\Extension:
            base_url: http://dev.local
            goutte: ~
            selenium2:
 wd_host: "http://localhost:8643/wd/hub" 
@DuaelFr
DuaelFr / gist:4664660
Created January 29, 2013 14:32
hook_default_rules_configuration() advanced sample.
<?php
/**
* Implements hook_default_rules_configuration().
*/
function MYMODULE_default_rules_configuration() {
$rules = array();
// Custom rule : calculate the weight of a line item
$rule = rule($variables, $provides);
@benclark
benclark / theme_D7MODULE_table_form.php
Created January 8, 2013 20:04
Theme a series of form elements into a table (Drupal 7)
<?php
/**
* Theme a series of form elements into a table (Drupal 7).
*/
function theme_D7MODULE_table_form($variables) {
$form = $variables['form'];
$header = array();
$rows = array();
@kalabro
kalabro / kalabro.module
Last active December 10, 2015 01:28
Drupal 7: Define Age formatter for date fields.
<?php
/**
* Define Age formatter for date fields.
*/
/**
* Implements hook_field_formatter_info().
*/
function kalabro_field_formatter_info() {
$formatters = array(
@netsensei
netsensei / drupal-ajax.php
Created November 7, 2012 11:14
Minimal Drupal Bootstrap for AJAX requests
<?php
/**
* @file
*
* Minimal AJAX page. Call like this:
* $.ajax({
* type: 'GET',
* url: '/drupal-ajax.php?param1=...
* data: {},