Skip to content

Instantly share code, notes, and snippets.

View junaidpv's full-sized avatar

Junaid P V junaidpv

View GitHub Profile
@junaidpv
junaidpv / rgba.js
Created July 31, 2013 07:06
Javascript RGB(A) string conversion functions.
/**
* Parse an rgb or rgba string like 'rgb(67, 216, 89)' or 'rgba(245, 156, 8, 178)'
* to array of integers in the order.
* Credit: http://stackoverflow.com/questions/10970958/get-a-color-component-from-an-rgb-string-in-javascript
**/
function parse_rgb_string(rgb) {
rgb = rgb.replace(/[^\d,]/g, '').split(',');
return rgb;
}
@junaidpv
junaidpv / atomic-chiller.py
Created September 20, 2013 03:38
Replace old chills with new atomic chills. To read more about chills see: http://www.unicode.org/versions/Unicode5.1.0/#Malayalam_Chillu_Characters
#!python
"""
Replace old chills with new atomic chills.
To read more about chills see: http://www.unicode.org/versions/Unicode5.1.0/#Malayalam_Chillu_Characters
"""
import unicodedata
import codecs
import sys
import os.path
@junaidpv
junaidpv / ls-mem
Last active August 29, 2015 14:10
Script to show combined memory usage share by a program along memory size used.
#!/bin/bash
user=$1
ps `if [ -n "$user" ]; then echo "-u $user"; else echo "-A"; fi` --sort -rss -o comm,pmem,rss | awk '
NR == 1 { print; next }
{ a[$1] += $2; b[$1] += $3;}
END {
split("B KB MB GB TB PB", unit)
for (i in a) {
human_readable = size_in_bytes = b[i] * 1024
j = 1
@junaidpv
junaidpv / file_entity-change_author.patch
Created July 29, 2015 05:52
Brings 'Change author' bulkoperation in files admin view. Fix from https://www.drupal.org/node/2510934 is required before applying this patch.
diff --git a/admin_views_default/file.admin-content-file.inc b/admin_views_default/file.admin-content-file.inc
index c108497..5423334 100644
--- a/admin_views_default/file.admin-content-file.inc
+++ b/admin_views_default/file.admin-content-file.inc
@@ -130,6 +130,13 @@ $handler->display->display_options['fields']['views_bulk_operations']['vbo_setti
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0;
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10';
$handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array(
+ 'action::views_bulk_operations_change_author_action' => array(
+ 'selected' => 1,
@junaidpv
junaidpv / media_browser_plus-change_author.patch
Last active October 14, 2016 09:42
Brings 'Change author' operation in thumbnails view. Need https://www.drupal.org/node/2510934 this to be applied before this patch to work.
diff --git a/views/media_browser_plus.views_default.inc b/views/media_browser_plus.views_default.inc
index fd3d099..1ccef8c 100644
--- a/views/media_browser_plus.views_default.inc
+++ b/views/media_browser_plus.views_default.inc
@@ -335,6 +335,13 @@ function media_browser_plus_views_management() {
$handler->display->display_options['fields']['media_browser_plus_preview_vbo']['vbo_settings']['force_single'] = 0;
$handler->display->display_options['fields']['media_browser_plus_preview_vbo']['vbo_settings']['entity_load_capacity'] = '10';
$handler->display->display_options['fields']['media_browser_plus_preview_vbo']['vbo_operations'] = array(
+ 'action::views_bulk_operations_change_author_action' => array(
+ 'selected' => 1,
@junaidpv
junaidpv / media_browser_plus-thumbnails_plus_tab_rename.patch
Last active August 29, 2015 14:26
Bring configuration settings to rename "Thumbnails Plus" to "Thumbnails" and hide original "Thumbnails" view.
diff --git a/includes/media_browser_plus.admin.inc b/includes/media_browser_plus.admin.inc
index dcaf7fa..564aa9f 100644
--- a/includes/media_browser_plus.admin.inc
+++ b/includes/media_browser_plus.admin.inc
@@ -20,6 +20,18 @@ function media_browser_plus_media_settings($form, &$form_state = array()) {
'#type' => 'value',
'#default_value' => variable_get('media_browser_plus_thumbnails_as_default_browser', TRUE),
);
+
+ $form['media_browser_plus_replace_media_browser_thumnails_browser'] = array(
@junaidpv
junaidpv / rubik-form-item.patch
Created August 12, 2015 12:17
Fix icorrect styling of form-item elements in Drupal Rubik theme
diff --git a/css/core.css b/css/core.css
index 2ea3d39..ce4afbf 100644
--- a/css/core.css
+++ b/css/core.css
@@ -254,7 +254,6 @@ table.field-multiple-table td {
.admin-list,
.node-type-list,
.admin-panel {
- background: #fff;
margin: 0 0 10px;
@junaidpv
junaidpv / mbp_browser_tabs_rename.patch
Last active October 14, 2016 09:54
To rename Media browser tabs brought by MBP module
diff --git a/views/media_browser_plus.views_default.inc b/views/media_browser_plus.views_default.inc
index 56fc60a..ea565fa 100644
--- a/views/media_browser_plus.views_default.inc
+++ b/views/media_browser_plus.views_default.inc
@@ -233,13 +233,13 @@ function media_browser_plus_views_management() {
/* Display: Media browser */
$handler = $view->new_display('media_browser', 'Media browser', 'media_browser_thumbnails');
$handler->display->display_options['defaults']['title'] = FALSE;
- $handler->display->display_options['title'] = 'Library (MBP)';
+ $handler->display->display_options['title'] = 'Library';
@junaidpv
junaidpv / socialmedia_twitter_widget_correct_script_load.patch
Last active August 29, 2015 14:27
Twitter widget of socialmedia module do have a problem with its script. When blocks are rendered as Ajax delivered content. Inline script get exectued before twitter library is loaded. This patch fixes that.
diff --git a/socialmedia.widgets.inc b/socialmedia.widgets.inc
index 3c4dcf5..b2b7dd7 100644
--- a/socialmedia.widgets.inc
+++ b/socialmedia.widgets.inc
@@ -953,33 +953,34 @@ EOF;
function socialmedia_widgets_element_twitter_profile_widget() {
$template = <<<EOF
-<script src="http://widgets.twimg.com/j/2/widget.js"></script>
<script>
@junaidpv
junaidpv / apply_patch_to_media_wysiwyg.patch
Created August 21, 2015 11:41
Patch for panopoly_widgets to apply patch on meida_wysiwyg
diff --git a/panopoly_widgets.make b/panopoly_widgets.make
index ea49841..1fd2633 100644
--- a/panopoly_widgets.make
+++ b/panopoly_widgets.make
@@ -27,6 +27,7 @@ projects[media][patch][2126697] = https://www.drupal.org/files/issues/media_wysi
projects[media][patch][2308487] = https://www.drupal.org/files/issues/media-alt-title-double-encoded-2308487-2.patch
projects[media][patch][2084287] = http://www.drupal.org/files/issues/media-file-name-focus-2084287-2.patch
projects[media][patch][2421589] = https://www.drupal.org/files/issues/media-library-preview-overflow-2421589-3.patch
+projects[media][patch][2381653] = "https://www.drupal.org/files/issues/media_wysiwyg-media-wysiwyg-fails-over-no-existing-wysiwyg-2381653.patch"