Skip to content

Instantly share code, notes, and snippets.

View SpacemanPete's full-sized avatar

Piotr Butkiewicz SpacemanPete

View GitHub Profile
@waako
waako / themename.theme.php
Last active June 17, 2019 12:54
Drupal 8: Get Block's parent Node title and full URL
<?php
use Drupal\Core\Url;
/**
* Implements hook_preprocess_HOOK() for block.html.twig.
*/
function themename_preprocess_block(&$variables) {
// Get Title of Block's parent Node.
$request = \Drupal::request();

#Installing Taiga on CentOS 6 (x64)

##Dependencies ...

yum update -y
yum groupinstall "Development Tools" -y
yum install libxslt-devel libxml2-devel libXt-devel curl git tmux -y

##Installing PostgreSQL

@mediabeastnz
mediabeastnz / Staging&ProductionUsingGit
Last active December 1, 2022 14:47
Staging and Production Server using Git.
If you are running a large website where you will need to test new features on a seperate url before pushing them live then the following instructions are for you ;)
For this example imagine your url is apple.com and you want a development/staging site on a subdomain which is dev.apple.com
#Setup#
1. First thing you'll want to do is go ahead and create your website in plesk and add the subdomain dev.apple.com at the same time.
2. ssh into the server e.g. $ ssh username@ipaddress
3. Once logged in cd into the private directory (this will be where all git repos are stored) e.g. $ cd ~/private
4. Create the main repo e.g. $ git init --bare apple.git
5. Now to clone this new repo on your local machine. $ git clone ssh://username@ipaddres/~/private/apple.com
@james2doyle
james2doyle / loadScript.js
Created March 15, 2014 17:47
loadScript. Async load a script and then fire a callback when loaded.
//this function will work cross-browser for loading scripts asynchronously
function loadScript(src, callback) {
var s,
r,
t;
r = false;
s = document.createElement('script');
s.type = 'text/javascript';
s.src = src;
s.onload = s.onreadystatechange = function() {
@aymanfarhat
aymanfarhat / urlobject.js
Last active July 27, 2017 00:04
JS utility function that: - Breaks down url to an object with accessible properties: protocol, parameters object, host, hash, etc... - Converts url parameters to key/value pairs - Convert parameter numeric values to their base types instead of strings - Store multiple values of a parameter in an array - Unescape parameter values
function urlObject(options) {
"use strict";
/*global window, document*/
var url_search_arr,
option_key,
i,
urlObj,
get_param,
key,
@ecorson
ecorson / drush_admin_create
Created April 3, 2012 14:43
Add admin user via Drush
drush user-create adminuser --mail="adminuser@uiowa.edu" --password="UserPw"; drush user-add-role "administrator" adminuser
@anhang
anhang / localStorage.js
Created July 20, 2011 23:07
HTML5 Local Storage with Expiration
AZHU.storage = {
save : function(key, jsonData, expirationMin){
if (!Modernizr.localstorage){return false;}
var expirationMS = expirationMin * 60 * 1000;
var record = {value: JSON.stringify(jsonData), timestamp: new Date().getTime() + expirationMS}
localStorage.setItem(key, JSON.stringify(record));
return jsonData;
},
load : function(key){
if (!Modernizr.localstorage){return false;}