Skip to content

Instantly share code, notes, and snippets.

View Ryouku's full-sized avatar
💭
I may be slow to respond.

Zy Ryouku

💭
I may be slow to respond.
View GitHub Profile
@Ryouku
Ryouku / settings.php
Last active August 29, 2015 14:10
Drupal Memcache-Storage Oracle config
<?php #<-- omit
# All other configs goes here
# ------------------------------------------ #
# THIS GOES AT THE END OF SETTINGS.PHP FILE!
#
# Replace strings with appropriate info:
# - USER-XXXX
# - server-ip
# ------------------------------------------ #
@Ryouku
Ryouku / index.html
Created November 25, 2014 14:08
DEMO JWPlayer Integration HTML code
<!DOCTYPE html>
<html>
<head>
<title>JWPlayer test</title>
<!-- JW Player Library -->
<script src="http://jwpsrv.com/library/RANDOM_ACCOUNT_KEY.js"></script>
<script>jwplayer.key="RANDOM_KEY==";</script>
</head>
<body>
<div id="playeryEQEzJOybgkU"></div>
@Ryouku
Ryouku / goto.php
Last active August 29, 2015 14:11
PHP GOTO
<?php
/**
* Class Resp Used to simulate WS response
*/
class Resp {
private $r = array(1 => 'A', 2 => 'B');
public function re() {
return $this->r[rand(1,2)];
}
@Ryouku
Ryouku / check_date.php
Last active August 29, 2015 14:12
Simple date check function in PHP
<?php
class MyException extends Exception {}
class Helper {
/**
* @param string $date The date in format: "Y-m-d"
* @param string $operator Operator used to compare two dates
* @return bool
* @throws string
*/
@Ryouku
Ryouku / d7_commerce.php
Last active August 29, 2015 14:13
Drupal7 Commerce currency conversion
<?php
/**
* First we need to configure Commerce Currency and enable new target currency
* at (admin/commerce/config/currency) to convert to.
* Next we setup conversion rates in admin/commerce/config/currency/conversion
* And finally execute this snippet in Devel PHP block or create simple module
*/
/**
* Find all commerce products
@Ryouku
Ryouku / scripts.js
Last active August 29, 2015 14:13
HTML/jQuery: Sticky header
jQuery(document).ready(function($){
var $content_area = $('#content-area');
var $body = $('body');
var $footer = $('#footer');
$content_area.find('.content p:last').addClass('last');
$(window).scroll(function() {
if ($(this).scrollTop() > 21) {
$('#top, #sidebar-first').addClass("sticky");
@Ryouku
Ryouku / template.php
Created January 21, 2015 12:56
Drupal7: get page template hook suggestions by taxonomy term
<?php
/**
* Override or insert variables into the page template.
*/
function theme_name_preprocess_page(&$vars) {
if (isset($vars['node']) && $vars['node']->type == 'preke') {
if (count($vars['node']->field_tax_vandens_filtrai) > 0) {
$vars['theme_hook_suggestions'][] = 'page__vandens_filtrai';
}
@Ryouku
Ryouku / template.php
Created January 21, 2015 13:00
Drupal7: add page regions inside node template.
<?php
/**
* Override or insert variables into the node template.
*/
function theme_name_preprocess_node(&$vars) {
$vars['submitted'] = $vars['date'] . ' — ' . $vars['name'];
// Add decent classes for node titles.
$vars['title_attributes_array']['class'][] = 'title';
$vars['title_attributes_array']['class'][] = 'node-title';
@Ryouku
Ryouku / template.php
Created January 21, 2015 13:08
Drupal7: set active menu item manually
<?php
function theme_name_preprocess_page(&$vars) {
if (!empty($vars['node']) && $vars['node']->nid == '17') {
menu_set_active_item('node/10');
}
}
@Ryouku
Ryouku / template.php
Created January 21, 2015 13:11
Drupal7: give page body classes by taxonomy term
<?php
/**
* Override or insert variables into the html template.
*/
function theme_name_preprocess_html(&$vars) {
if (arg(0) == 'node') {
$_nid = arg(1);
if (is_numeric($_nid)) {
$nod = node_load($_nid);