Skip to content

Instantly share code, notes, and snippets.

@mynameispj
mynameispj / scripts.js
Created November 3, 2014 01:04
Wordpress: Remove image height & width on mobile devices with jQuery
/**
* jQuery.browser.mobile (http://detectmobilebrowser.com/)
*
* jQuery.browser.mobile will be true if the browser is a mobile device
*
**/
(function(a){(jQuery.browser=jQuery.browser||{}).mobile=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|
@mynameispj
mynameispj / affix.css.scss
Last active August 29, 2015 14:03
Bootstrap affix on smaller screens...
@media (max-width: 768px) {
.affix {
position: static;
}
}
@mynameispj
mynameispj / .gitignore
Last active January 2, 2021 02:37
Git Ignore SASS cache files
# Ignore docs files
styles/.sass-cache
styles/.sass-cache/*
# Not working?
# Try: http://stackoverflow.com/questions/11451535/gitignore-not-working
# Try: http://stackoverflow.com/questions/1139762/gitignore-file-not-ignoring
@mynameispj
mynameispj / MySQL
Created April 8, 2014 04:12
Drupal 7 - Turn on comments for all nodes in a content type via MySQL
UPDATE node SET comment = 2 WHERE type = 'foo'
UPDATE node_revision SET comment = 2 WHERE nid IN (SELECT nid FROM node WHERE type = 'foo')
//'foo' = the machine name of your content type
@mynameispj
mynameispj / yourmodule.module
Last active August 29, 2015 13:56
Get Drupal 7 comment forms to display error messages on the original node's page
function yourmodule_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'comment_node_blog_post_form') {
$form['actions']['submit']['#value'] = 'Add Your Comment';
$form['#action'] = '?'. drupal_get_destination();
}
}
Sub MyAdd(ByVal strTableName As String, ByRef arrData As Variant)
Dim Tbl As ListObject
Dim NewRow As ListRow
Set Tbl = Worksheets("Cart Conversion").ListObjects(strTableName)
Set NewRow = Tbl.ListRows.Add(AlwaysInsert:=True)
' Handle Arrays and Ranges
If TypeName(arrData) = "Range" Then
NewRow.Range = arrData.Value
@mynameispj
mynameispj / rails.html.erb
Created January 20, 2014 03:19
Render Rails partial multiple times
<% 10.times { -%>
<%= render :partial => '/prototype/partials/story-list/story_list_filler' %>
<% } -%>
@mynameispj
mynameispj / pagetpl.php
Last active December 19, 2015 17:29
Drupal 7 -- Node_load and then render() some content
<?php
$front_page = node_load("111");
$page_intro = field_view_field('node',$front_page,'field_page_intro');
print render($page_intro);
?>
@mynameispj
mynameispj / pagetpl.php
Last active December 19, 2015 17:28
Drupal 7 Field Collections - Loop to avoid cruft markup
<?php
$front_page = node_load("1");
foreach ($front_page->field_slideshow_images['und'] as $key => $value) {
$slide = entity_load('field_collection_item', array($value['value']));
$idx = $value['value'];
?>
<div class="rsContent slide">
<img src="<?php print image_style_url('none', $slide[$idx]->field_image['und']['0']['uri']); ?>" class="rsImg">
<div class="projectInfo">
<p><?php print $slide[$idx]->field_title_of_project['und']['0']['value']; ?></p>
@mynameispj
mynameispj / overrides.scss
Created July 7, 2013 01:23
Global Drupal overrides. Props to Jeff Glenn (@jeffaglenn) at Deluge.
/*-------------------------------------------------------------------------------*/
/* GLOBAL / DRUPAL OVERRIDES */
/*-------------------------------------------------------------------------------*/
html {
background: #fff;
}
body {
background: #fff;
color: #111011;