Skip to content

Instantly share code, notes, and snippets.

@guizmo
guizmo / alias-path.php
Created April 20, 2012 00:20
Get alias path in views
$pathAlias = drupal_lookup_path('alias',"node/".$row->nid);
@guizmo
guizmo / Asset.js
Created May 22, 2012 00:08
Next and Prev Counter
$("#prev").click(function(){
count--;
if(count < 0) count = $("li .tpl").length - 1;
$("li .tpl")[count].click();
});
$("#next").click(function(){
count++;
if(count > $("li .tpl").length - 1) count = 0;
@guizmo
guizmo / snag-list.js
Created May 24, 2012 02:49
Snag list message
/*
** first add custom body class in function.php (page slug/name)
** see code in body-class.php snippet
*/
/*
** Then map the messages to the appended body class
*/
var todo = {
<!-- content to be placed inside <body>…</body> -->
@guizmo
guizmo / Asset.php
Created June 30, 2012 09:07
Print category tree
foreach( get_categories('hide_empty=1') as $cat ) :
if( !$cat->parent ) {
echo '<ul><li><strong>' . $cat->name . '</strong></li>';
process_cat_tree( $cat->term_id );
}
endforeach;
wp_reset_query(); //to reset all trouble done to the original query
//
function process_cat_tree( $cat ) {
@guizmo
guizmo / Asset.php
Created July 5, 2012 21:42
Openlayers showPopup()
Drupal.settings.nid = Drupal.settings.nid || [];
Drupal.settings.getAllFeature;
function my_map() {
var all_layers = Drupal.openlayers.popup.popupSelect.layers;
for(var key1 in all_layers) {
var current_layer = all_layers[key1];
var all_features_in_layer = current_layer.features;
for(var key2 in all_features_in_layer) {
@guizmo
guizmo / Asset.php
Created July 6, 2012 21:49
Creating ZIP File with PHP
<?php
// source http://www.catswhocode.com/blog/snippets/creating-zip-file-with-php
$error = ""; //error holder
if(isset($_POST['createpdf'])){
$post = $_POST;
$file_folder = "files/"; // folder to load files
if(extension_loaded('zip')){ // Checking ZIP extension is available
if(isset($post['files']) and count($post['files']) > 0){ // Checking files are selected
$zip = new ZipArchive(); // Load zip library
$zip_name = time().".zip"; // Zip name
@guizmo
guizmo / disable-plugins-when-doing-local-dev.php
Created July 17, 2012 10:40 — forked from markjaquith/disable-plugins-when-doing-local-dev.php
Disables specified WordPress plugins when doing local development
<?php
/*
Plugin Name: Disable plugins when doing local dev
Description: If the WP_LOCAL_DEV constant is true, disables plugins that you specify
Version: 0.1
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
@guizmo
guizmo / dabblet.html
Created August 1, 2012 22:12 — forked from dstorey/dabblet.css
Untitled
<h1>Split view feature box with CSS skew transform and transitions</h1>
<div class="box sunrise"><a href="#box2"></a></div>
<div class="slider">
<div class="box sunset"><a href="#box1"></a></div>
</div>
<footer>
<p>Handcrafted by <a href="http://www.twitter.com/dstorey">@dstorey</a> for
<a href="http://www.generatedcontent.org/123456/split-feature">GeneratedContent.org</a>. Sunset image, <a href="http://creativecommons.org/licenses/by-nc-sa/2.0/">Some rights reserved</a> by <a href="http://www.flickr.com/photos/42429527@N03/">najeebkhan2009</a>. Sunrise image, <a href="http://creativecommons.org/licenses/by-nd/2.0/">Some rights reserved</a> by <a href="http://www.flickr.com/photos/petehogan/">3dpete</a>.</p>
</footer>
@guizmo
guizmo / Asset.sh
Created August 16, 2012 20:21
Merge 2 movie files
cat video1.avi video2.avi videon.avi > output.avi (this merges them but only playes length of 1st mov)
mencoder -forceidx -oac copy -ovc copy output.avi -o output_final.avi (this commands rebuilds the header file. One unqiue point about this commands is that it only copies the frames and audio across, it doesn’t re-encode them )