Skip to content

Instantly share code, notes, and snippets.

Avatar

Victor Kareh vkareh

  • Red Hat
  • Quebec, Canada
View GitHub Profile
@vkareh
vkareh / noop.js
Created Aug 15, 2014
(a)synchronous noop function for node.js
View noop.js
module.exports = function(callback) {
if (callback) {
process.nextTick(callback);
}
}
@vkareh
vkareh / trello-highlight.js
Last active Aug 29, 2015
Highlights Trello cards in which you are a member
View trello-highlight.js
setTimeout(function() {
var name = $('.header-user img.member-avatar').attr('title');
$('.js-member-on-card-menu img[title="' + name + '"]').each(function() {
$(this).parents('.list-card-details').css('background-color', '#fcaf3e');
});
}, 2000);
@vkareh
vkareh / node-async-json.js
Created Nov 14, 2014
Wrapper around JSON.parse and JSON.stringify to make them run asynchronously. Also gets rid of having to use a try/catch on JSON.parse()
View node-async-json.js
module.exports = {};
module.exports.parse = function parse() {
var args = Array.prototype.slice.call(arguments);
var callback = args.pop();
var _this = this;
process.nextTick(function() {
try {
var obj = JSON.parse.apply(_this, args);
return callback.apply(_this, [null, obj]);
@vkareh
vkareh / .vimrc
Created Jan 26, 2012
Drupal-friendly .vimrc
View .vimrc
"Enable filetype detection
:filetype on
"General settings
set incsearch "Find as you type
set ignorecase "Ignore case in search
set scrolloff=2 "Number of lines to keep above/below cursor
set smartcase "Only ignore case when all letters are lowercase
set number "Show line numbers
set wildmode=longest,list "Complete longest string, then list alternatives
@vkareh
vkareh / cradle.patch
Created Feb 28, 2012
patch for cradle
View cradle.patch
diff --git a/lib/cradle.js b/lib/cradle.js
index 7700ff6..db5e2a5 100644
--- a/lib/cradle.js
+++ b/lib/cradle.js
@@ -509,7 +509,9 @@ cradle.Connection.prototype.database = function (name) {
}
if (options && options.keys) {
- this.query('POST', path, {}, options, args.callback);
+ var keys = options.keys;
View gist:2721620
<?php
/**
* Form submit...
*/
function my_module_submit($form, $form_state) {
$email = $form_state['values']['email'];
$message_type = $form_state['values']['message_type'];
$params = array('form_values' => $form_state['values']);
drupal_mail('my_module', $message_type, $email, language_default(), $params);
@vkareh
vkareh / gist:2990301
Created Jun 25, 2012
Forcing an input format on a textfield
View gist:2990301
$form['my_text_field'] = array(
'#type' => 'text_format',
'#base_type' => 'textfield',
'#title' => t('My Text'),
'#default_value' => '',
'#format' => 'filtered_html',
);
View settings.php
if (!extension_loaded('pdo')) {
dl('pdo.so');
}
View gist:3277475
$element = array(
'#type' => 'markup',
'#markup' => t('...'),
'#prefix' => '<h2>',
'#suffix' => '</h2>'
);
View gist:3277520
/**
* Implements hook_theme().
*/
function HOOK_theme($existing, $type, $theme, $path) {
return array(
'h2' => array(
'variables' => array('text' => NULL, 'args' => NULL),
),
);
}