Skip to content

Instantly share code, notes, and snippets.

View thamas's full-sized avatar

Tamás Hajas thamas

View GitHub Profile
@thamas
thamas / drupal_rules_access_alias_only.txt
Last active December 19, 2015 00:48
Drupal 7, Rules export. Use to redirect anonymous user to frontpage when she tries to access content using node/[nid] path. So content will be available only on its path alias.
{ "rules_access_w_alias_only" : {
"LABEL" : "Acces content with alias only",
"PLUGIN" : "reaction rule",
"TAGS" : [ "access" ],
"REQUIRES" : [ "rules" ],
"ON" : [ "node_view" ],
"IF" : [
{ "user_has_role" : {
"account" : [ "site:current-user" ],
"roles" : { "value" : { "1" : "1" } }
@thamas
thamas / compass-text-replacement-span.scss
Last active December 19, 2015 03:29
compass scss text-replacement span
//see http://compass-style.org/reference/compass/typography/text/replacement
//compass 0.12.2
@import "compass/typography/text/replacement"
span.logo {
@include replace-text-with-dimensions("logo.png");
display: inline-block;
position: relative;
top: 4px;
@thamas
thamas / sublime-regexp-add-month-name-to-date.md
Last active December 19, 2015 08:39
sublime regexp add month name to date

Using Sublime Text's Replace function with regex

changes this:
"1997.01.01.";

to this:
"1997.01.03.";"Január";

Find What:

@thamas
thamas / sublime-regexp-remove-newlines.md
Last active December 19, 2015 08:39
Sublime regexp remove newlines

Using Sublime Text's Replace function with regex

Remove newlines from paragraph:

Changes this:

"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment.

@thamas
thamas / get-own-ip
Last active December 28, 2015 05:19
Get own IP address
curl -l http://echoip.net; echo
<ul>
<li>
<a href="/" data-drupal-link-system-path="<front>">Frontpage</a>
</li>
<li>
<a href="/about" data-drupal-link-system-path="node/1">About us</a>
<ul>
<li>
<a class="is-active" href="/team" data-drupal-link-system-path="node/2">Team</a>
</li>
<ul class="c-menu-main">
<li class="c-menu-main__item">
<a href="/" class="c-menu-main__link" data-drupal-link-system-path="<front>">Frontpage</a>
</li>
<li class="c-menu-main__item c-menu-main__item--expanded c-menu-main__item--active-trail">
<a href="/about" class="c-menu-main__link" data-drupal-link-system-path="node/1">About us</a>
<ul class="c-menu-main__submenu">
<li class="c-menu-main__item c-menu-main__item--active-trail">
<a href="/team" class="c-menu-main__link is-active" data-drupal-link-system-path="node/2">Our team</a>
</li>
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'menu__main' -->
<!-- FILE NAME SUGGESTIONS:
* menu--main.html.twig
x menu.html.twig
-->
<!-- BEGIN OUTPUT from 'core/themes/stable/templates/navigation/menu.html.twig' -->
{% import _self as menus %}
{#
We call a macro which calls itself to render the full tree.
@see http://twig.sensiolabs.org/doc/tags/macro.html
#}
{{ menus.menu_links(items, attributes, 0) }}
{% macro menu_links(items, attributes, menu_level) %}
{% import _self as menus %}
@thamas
thamas / menu.html.twig
Created April 29, 2016 20:15
menu_name passed as argument
{{ menus.menu_links(items, attributes, 0, menu_name) }}
{% macro menu_links(items, attributes, menu_level, menu_name) %}