Skip to content

Instantly share code, notes, and snippets.

@light9
light9 / new_gist_file_0
Created August 3, 2015 17:31
pt4 total uninstall
1. TrashReg > all with name WinLicense 1.x
2. Del > c:\ProgramData\flwjycbm.bab
@light9
light9 / browser synch commands
Last active September 21, 2015 13:36
browser synch
npm install -g browser-sync
browser-sync start --files "/srv/www/crm/public_html/sites/all/themes/crm/css/*.css" --proxy --port 4000
//kill process
sudo netstat -lpn |grep :4000
fuser -n tcp -k 4000
/// after add js file before </body> and go to http://194.177.20.106:3009/
@light9
light9 / get rendered view
Last active September 21, 2015 13:36
get rendered view instead <?php echo views_embed_view('clients','block_1'); ?> if get error: Notice: Undefined property: view::$dom_id ... refer to https://www.drupal.org/node/1556174
$view = views_get_view('lp_promoted_content');
$display_id = 'promoted_content';
// Set the display and arguments based on the pane's context.
$view->set_display($display_id);
$args = $view->args;
$args[0] = $node->nid;
$view->set_arguments($args);
// ADD THESE 2 LINES IN TO REMOVE ERRORS
@light9
light9 / get view result as array
Created June 5, 2015 13:21
get view result as array
$result = views_get_view_result('my_view_name', 'default', $arg1, $arg2, ...);
@light9
light9 / send variable from .php file to .js file in Drupal 7
Created June 4, 2015 06:45
send variable from .php file to .js file in Drupal 7
drupal_add_js(array('YOURMODULE' => array('testvar' => $testvar)), array('type' => 'setting'));
And in your JavaScript, you can the access the value in Drupal.settings.YOURMODULE.testvar:
alert(Drupal.settings.YOURMODULE.testvar);
@light9
light9 / git clone --branch
Created June 3, 2015 18:05
git clone --branch
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/mnico/2178611.git nodejs_debug
@light9
light9 / install forever to run nodejs as service
Created May 20, 2015 08:17
install forever to run nodejs as service. logs in a hidden .forever directory in the home directory of the user you ran forever as. Startup: All you need to do is create a file named something like myapp.conf in /etc/init with the following contents: --- start on startup exec forever start /full/path/to/test.js --- http://www.slidequest.com/Tabo…
sudo npm -g install forever
export PATH=$PATH:/usr/local/bin
export NODE_PATH=$NODE_PATH:/usr/local/lib/node_modules
ln -s /usr/bin/nodejs /usr/bin/node
forever start test.js
@light9
light9 / editablefields
Created May 15, 2015 06:18
edited sites\all\modules\editablefields\editablefields.module 378
'#value' => t('Edit this field'),
'#value' => t('<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>'),
@light9
light9 / parse url string
Created May 14, 2015 15:48
parse url string
$url = "https://mysite.com/test/1234?email=xyz4@test.com&testin=123";
$query_str = parse_url($url, PHP_URL_QUERY);
parse_str($query_str, $query_params);
print_r($query_params);
@light9
light9 / Get the first element of an array
Created May 12, 2015 17:26
Get the first element of an array
# to map child array element without bu parent position
$data = array_values($request)[0];