Skip to content

Instantly share code, notes, and snippets.

View arpitr's full-sized avatar

Arpit arpitr

  • Srijan Aravali Technologies
  • Goa
View GitHub Profile
<?php
include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
header('Content-Type: text/plain');
function _get_module_count() {
$modules = system_list('module_enabled');
foreach ($modules as $module) {
if (strpos($module->filename, 'sites/all/modules/contrib') === 0) {
@arpitr
arpitr / iterm2.md
Created August 21, 2016 21:04 — forked from arpitra/iterm2.md
iterm2 cheatsheet

Tabs and Windows

Function Shortcut
Previous Tab + Left Arrow
Next Tab + Right Arrow
Go to Tab + Number
Go to Window + Option + Number
Go to Split Pane by Direction + Option + Arrow
Go to Split Pane by Order of Use + ] , + [
@arpitr
arpitr / tmux-cheatsheet.markdown
Created April 18, 2016 07:02 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@arpitr
arpitr / safe_filename.php
Created January 19, 2016 06:12
Regular Expression for safe file name input by user.
// ^ matches the beginning of the string.
// \w matches a "word" character (A-Z, a-z, 0-9, and _ only).
// The "+" sign means "one or more."
// \. matches a single dot.
// And the final $ matches the end of the string.
$safeFilename = '/^\w+\.\w+$/';
@arpitr
arpitr / sample_hook.php
Created December 22, 2015 10:59
drupal_hook_sample
/**
* Implements hook_node_insert
*/
function mymodulename_node_insert($node) {
// Get Node Author.
$author = $node->author;
// Use Drupal Mail
send_mail($to=$author);
}
@arpitr
arpitr / watchdog.php
Last active March 11, 2016 10:09
Drupal Watchdog Objects and Array
watchdog('module_name', 'Your Object: !object', array('!object' => '<pre>' . check_plain(print_r($object, TRUE)) . '</pre>'), WATCHDOG_ERROR);
#! /bin/bash
MYSQL="mysql -h <hostname> -u <username> -<password> -D <DATABASENAME>"
$MYSQL -BNe "show tables" | awk '{print "set foreign_key_checks=0; drop table `" $1 "`;"}' | $MYSQL
unset MYSQL
@arpitr
arpitr / watchdog.php
Last active November 18, 2016 07:24
Drupal Watchdog Object
watchdog('custom_debug', 'Debug Global User Object for @user_name, user object: !user', array('@' => $user->name, '!node' => '<pre>' . check_plain(print_r($user, TRUE)) . '</pre>'), WATCHDOG_ERROR);
- SSH with password
- Add alias on bashrc
sudo apt-get install sshpass
#Then prepend your ssh/scp command with
sshpass -p '<password>' <ssh/scp command>
@arpitr
arpitr / gist:92cb564944e3115161f8
Last active August 29, 2015 14:23
Screen Handy Commands
#Screen
#Run a task and detach
screen -S <Name Your Screen> -d -m <yourcommand>
#List screens
screen -ls
#Attach to a screen
screen -r <initials of screen id>