Skip to content

Instantly share code, notes, and snippets.

@hissy
hissy / c5-open-graph-tags.php
Created January 19, 2012 00:32
Open Graph Tags Setting for concrete5 site
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); ?>
<!-- Open Graph Tags Start -->
<?php
$page = Page::getCurrentPage();
$pageTitle = $page->getCollectionName();
$pageMetaTitle = $page->getCollectionAttributeValue('meta_title');
if ( $pageMetaTitle ) $pageTitle = $pageMetaTitle;
$pageOgTitle = $page->getCollectionAttributeValue('og_title');
if ( $pageOgTitle ) $pageTitle = $pageOgTitle;
$pageOgType = $page->getCollectionAttributeValue('og_type');
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@lossyrob
lossyrob / install-gdal
Last active August 10, 2017 18:53
Script to install GDAL on Ubuntu 12.04 LTS
# Install subversion
sudo apt-get -y install subversion
# Install g++
sudo apt-get -y install g++
# Install Hierarchical Data Format library
# NOTE: This library is not necessarily needed, but was required
# in order for this to compile against a clean Ubuntu 12.04 LTS system.
# I didn't need it on a clean EC2 Ubuntu 12.10 instance, so
@chill117
chill117 / mysql_backup.sh
Last active December 13, 2021 22:02
Bash script to perform backups on one or more MySQL databases.
#!/bin/bash
#
# Use this script to perform backups of one or more MySQL databases.
#
# Databases that you wish to be backed up by this script. You can have any number of databases specified; encapsilate each database name in single quotes and separate each database name by a space.
#
# Example:
# databases=( '__DATABASE_1__' '__DATABASE_2__' )
@nitaku
nitaku / README.md
Last active May 13, 2017 09:28
Graph editing tools

Starting from the previous example, this one implements a more complete graph editing tool.

Select a tool to operate on the graph: The pointer only lets the user pan & zoom or drag nodes around. The add node tool opens up a library of node types; click one to add a node of that type to the graph. The add link tool lets the user connect two nodes with a drag gesture from the first to the second one.

Clicking a node or a link always selects it regardless of the current tool. You can press del to remove the current selection.

The example activates and deactivates d3.js's drag behavior on nodes by using a technique found in this example by Ross Kirsling: Everytime the behavior has to be deactivated, the underlying listeners (mousedown.drag and touchstart.drag) are cleared.

Mouse coordinates are used to move the representation of a new link. The coordinates are retrieved as in [this example]

@nitaku
nitaku / README.md
Last active September 30, 2016 04:56
Graph editing with persistence

Same as the previous example, but with client-side persistence, thanks to the IndexedDB APIs (see this other example).

Try to modify the graph, then reload the page to load it again.

The graph is automatically saved on each modification of its structure, and also every second with a setInterval, to store even the changes made to nodes' position by the force layout.

# ps -ef - disaply all processes
# grep apache2 - find the rows with apache
# grep -v grep - remove rows with the word grep
# awk '{print $2}' - get the second column of the previous output
# kill -9 $(..) - execute kill -9 on all the values returned from the previous pipes
kill -9 $(ps -ef |grep apache2 |grep -v grep| awk '{print $2}')
@Soupala
Soupala / base64.js
Last active August 29, 2015 14:15 — forked from whatnickcodes/base64.js
// Create Base64 Object
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r