Skip to content

Instantly share code, notes, and snippets.

@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 / upload_file.sh
Created August 16, 2012 20:56
Upload file via ssh
scp someFile someUser@someServer:/somePath/someFile
@guizmo
guizmo / nc_list.php
Created January 17, 2013 02:40
List commune New Caledonia
function nc_opt_list_communes() {
$options = array(
'98812' => 'Boulouparis',
'98870' => 'Bourail',
'98813' => 'Canala',
'98830' => 'Dumbéa',
'98881' => 'Farino',
'98815' => 'Hienghène',
'98816' => 'Houaïlou',
'98811' => 'îles Belep',
@guizmo
guizmo / resize.js
Created November 22, 2012 22:00
Text resizer
//http://wp.tutsplus.com/tutorials/theme-development/creating-a-wordpress-post-text-size-changer-using-jquery/
// This prevents the execution of the code before the document is finished loading.
jQuery(document).ready(function() {
    // The 'A+' element  in the page is associated with the jQuery click() event.
    jQuery('#increase-font').click(function(event) {
        // This prevents the default action of the click() event from being triggered.
        event.preventDefault();
        // The jQuery each() event interates over each elements belonging to the 'resize' class
        jQuery('.resize').each(function() {
            // Call to a custom function to increase the text size
@guizmo
guizmo / delete.sh
Created September 17, 2012 09:35
delete
# Remove all files and directories (recursive removal)
rm -rf path/to/folder
# Remove / Delete directory called /tmp/foo
rmdir /tmp/foo
@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 )
@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 / 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 / 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 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 ) {