Skip to content

Instantly share code, notes, and snippets.

View nalipaz's full-sized avatar

Nicholas Alipaz nalipaz

  • Huntington Beach, CA
View GitHub Profile
<?php
function _pwdc_section_save_stylesheet($data, $tid = NULL, $name = NULL) {
$path = 'public://pwdc_section';
if (file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
$name = $name ? $name : ($tid ? 'pwdc-section-' . $tid . '.css' : 'pwdc-section.css');
$file = $path . '/' . $name;
file_unmanaged_save_data($data, $file, FILE_EXISTS_REPLACE);
// Set standard file permissions for webserver-generated files.
drupal_chmod($file);
@nalipaz
nalipaz / gist:c223b7414bc205178088
Last active August 29, 2015 14:02
Drupal.behaviors standard format
(function($) {
Drupal.behaviors.yourModule = {
attach: function (context, settings) {
// Your JS Here!
}
}
})(jQuery);
@nalipaz
nalipaz / local_sync_tasks.drush.inc
Created July 8, 2014 19:12
Local sync drush tasks
<?php
/**
* @file
* Local sync tasks to run after drush sql-sync on target site.
*
* @author Nicholas Alipaz - http://nicholas.alipaz.net/ (email through contact form)
*/
/**
* Implements hook_drush_help_alter().
@nalipaz
nalipaz / gist:09ae34b323e9ee1c6f43
Created September 18, 2014 20:29
Drupal: How to correctly add js in a form_alter()
<?php
function MODULE_NAME_form_alter($form, &$form_state, $form_id) {
...
$form['#after_build'] = array('MODULE_NAME_add_assets');
...
}
function MODULE_NAME_add_assets($element) {
drupal_add_js(......);
alias ll='ls -la'
soundfile="/home/nalipaz/Music/Sound Effects/smb_stage_clear.wav"
function scp() {
/usr/bin/scp "$@" && /usr/bin/aplay "$soundfile"
}
function mysqldump() {
/usr/bin/mysqldump "$@" && /usr/bin/aplay "$soundfile"
}
function drush() {
case "$1" in
@nalipaz
nalipaz / gist:d99e3bd821ca4b097023
Created November 17, 2014 22:07
Programmatically save block admin form
<?php
function ccs_deploy_update_7108() {
$beans = array(
'popular-brands',
'popular-courses',
'featured-prizes',
'user-testimonials',
'globalcs-get-started-button'
);
$weight = 2;
@nalipaz
nalipaz / gist:9402cfe208fa44d8d1f0
Last active August 29, 2015 14:09
How to save a media type for the media module, will save new or update
<?php
$types['video'] = new stdClass();
$types['video']->name = 'video';
$types['video']->label = "Video";
$types['video']->base = TRUE;
$types['video']->type_callback_args = array(
'match_type' => 'all',
'mimetypes' => array('/^video/'),
'extensions' => array('mov', 'mp4', 'avi'),
@nalipaz
nalipaz / gist:ec63ceed62e5f03b3a58
Created March 26, 2015 16:56
xrandr -q --verbose output
Screen 0: minimum 320 x 200, current 3840 x 1200, maximum 8192 x 8192
eDP1 connected primary 1920x1080+0+0 (0x45) normal (normal left inverted right x axis y axis) 308mm x 173mm
Identifier: 0x42
Timestamp: 36422116
Subpixel: unknown
Gamma: 1.0:1.0:1.0
Brightness: 1.0
Clones:
CRTC: 0
CRTCs: 0 1 2
@nalipaz
nalipaz / gist:11a2fde80f0b2009d920
Last active August 29, 2015 14:17
autorandr --config output
output HDMI1
off
output eDP1
mode 1920x1080
pos 0x0
primary
rate 60.00
@nalipaz
nalipaz / gist:c380ed3f6142de555fec
Created March 26, 2015 16:59
cat ~/.autorandr/docked/config
output eDP1
mode 1920x1080
pos 0x0
primary
output HDMI1
mode 1920x1200
pos 1920x0