Skip to content

Instantly share code, notes, and snippets.

View crazyrohila's full-sized avatar
🏠
Working from home

Sanjay Rohila crazyrohila

🏠
Working from home
View GitHub Profile
@crazyrohila
crazyrohila / read-email.php
Created December 16, 2016 11:38
Retrieve Email data with PHP-IMAP
<?php
set_time_limit(4000);
// Connect to gmail
$imapPath = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = '<your-email>';
$password = '<email-password>';
// try to connect
$inbox = imap_open($imapPath,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
@crazyrohila
crazyrohila / download-charts.js
Created December 9, 2016 13:03
Download all the highchart graph in zip file [dependency on https://stuk.github.io/jszip/]
var zip = new JSZip();
// Get all the highchart elements
var hc_containers = document.querySelectorAll('.highcharts-container');
if (hc_containers.length) {
hc_containers.forEach(function(hc, index) {
// Get the highchart Chart object.
chart_ele = hc.parentNode;
var chart = chart_ele.highcharts();
// Get the svg data from chart.
var svg = chart.getSVG({chart:{ width: 1040 }});
@crazyrohila
crazyrohila / remove-old-images
Last active November 25, 2016 06:29
Remove old images in boot dir
uname -r ##identify the kernel you are presently booting DO NOT remove this one ! Keep one other for a back up.
dpkg -l | grep linux-image- ##identify all installed kernel images
dpkg -l | grep linux-headers- ##identify all kernel header files
sudo apt-get --purge remove linux-image-3.2.0-31-generic ##for example
sudo apt-get --purge remove linux-headers-3.2.0-31-generic ##for example
@crazyrohila
crazyrohila / remove-old-images.md
Created November 25, 2016 06:28
Remove old images in boot dir

uname -r ##identify the kernel you are presently booting DO NOT remove this one ! Keep one other for a back up. dpkg -l | grep linux-image- ##identify all installed kernel images dpkg -l | grep linux-headers- ##identify all kernel header files sudo apt-get --purge remove linux-image-3.2.0-31-generic ##for example sudo apt-get --purge remove linux-headers-3.2.0-31-generic ##for example

@crazyrohila
crazyrohila / update-field-instance.php
Created August 12, 2016 11:06
Update drupal field instance
<?php
$field = field_read_instance('node', 'field_xxx', '<content_type>');
$field['label'] = 'New Label';
field_update_instance($field);
@crazyrohila
crazyrohila / HighchartExport-ExtraInfo.js
Last active December 9, 2016 13:08
HighchartExport - Calculated column data (Extra data)
// If we want to export some more info or calculated column in export csv data
// we can create a fake series with minimal required props and then push to chart.series
// and highchart will export that.
var s = {
name: "Test2",
options: {
stickyTracking: true
},
points: [{
@crazyrohila
crazyrohila / DrupalCoder.sublime-build
Created July 13, 2016 12:05
DrupalCoder.sublime-build
{
"cmd": ["/Users/MYUSER/.composer/vendor/bin/phpcs", "--report=emacs", "--standard=Drupal", "--extensions=php,module,inc,install,test,profile,theme", "$file"],
"file_regex": "^(.*):(.*):(.*):(.*)$",
"variants": [
{
"name": "Run",
"cmd": ["/Users/MYUSER/.composer/vendor/bin/phpcbf", "--standard=Drupal", "--extensions=php,module,inc,install,test,profile,theme", "$file"]
}
]
}
@crazyrohila
crazyrohila / sublime_regex
Last active March 4, 2016 09:43
Sublime Regex
Set title same as value attribute
Find: value="chart*(\w+)"
Replace: value="chart$1" title="chart$1"
Set title same as text within element
Find: title="chart*(\w+)">*(.+?>)
Replace: title="$2">$2
Single attribute selection and replace
@crazyrohila
crazyrohila / SassMeister-input.scss
Created December 7, 2015 09:59
Generated by SassMeister.com.
// ----
// Sass (v3.4.14)
// Compass (v1.0.3)
// ----
@mixin placeholder($extend: true) {
@if($extend) {
@extend %placeholder;
}
@else {
@crazyrohila
crazyrohila / SassMeister-input.scss
Created August 7, 2015 15:06
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
.story-box {
&__header {
font-weight: 500;
}
&:hover &__header {
text-decoration: underline;