Skip to content

Instantly share code, notes, and snippets.

View axooh's full-sized avatar

Alexander Muischneek axooh

View GitHub Profile
@axooh
axooh / file.php
Last active August 29, 2015 14:03
Symfony i18n
<?php
// Flash messages without parameters
$this->container->get('flash')->show($this->container->get('translator')->trans('label.no_parameter'), FlashMessageTypes::SUCCESS);
// Flash messages with parameters
$this->container->get('flash')->show($this->container->get('translator')->trans('label.with_parameter', array('%id%' => $entity->id())), FlashMessageTypes::SUCCESS);
// Form types without parameters
$builder->add('name', 'text', array(
@axooh
axooh / files.php
Created December 22, 2012 14:45
Drupal template functions
// Prepare files from content type field
function prepare_files($node) {
$files = field_get_items('node', $node, 'field_attachments');
// break up and return nothing, if there are no files
if (empty($files)) {
return NULL;
}
// iterate through the links and render the output
foreach ($files as $file) {
@axooh
axooh / refresh.js
Created December 22, 2012 14:43
Refreshing jQuery Mobile listviews, buttons, select dropdowns, and input fields
// Textarea fields
$('body').prepend('<textarea id="myTextArea"></textarea>');
$('#myTextArea').textinput();
// Text input fields
$('body').prepend('<input type="text" id="myTextField" />');
$('#myTextField').textinput();
@axooh
axooh / config.rb
Created November 27, 2012 07:50
Compass Configuration File
#
# This file is only needed for Compass/Sass integration. If you are not using
# Compass, you may safely ignore or delete this file.
#
# If you'd like to learn more about Sass and Compass, see the sass/README.txt
# file for more information.
#
# Change this to :production when ready to deploy the CSS to the live server.
environment = :development
@axooh
axooh / View.js
Created October 15, 2012 06:38
Backbone: Render inline template
header = _.template(tplHeader);
$(this.el).prepend(header({
'title': 'Search',
'icon': 'serach'
}));
// Equal column heights
var max_height = 0;
$("div.col").each(function(){
if ($(this).height() > max_height) { max_height = $(this).height(); }
});
$("div.col").height(max_height);
@axooh
axooh / .htaccess
Created August 29, 2012 19:20
.htaccess Snippets
# Force trailing slashes
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
</IfModule>
# Prevent Hotlink
RewriteEngine On
@axooh
axooh / template.php
Created August 19, 2012 09:39
Drupal Preprocess Node
<?php
/**
* Override or insert variables into the node templates.
*
* @param $variables
* An array of variables to pass to the theme template.
* @param $hook
* The name of the template being rendered ("node" in this case.)
*/