Skip to content

Instantly share code, notes, and snippets.

View sobi3ch's full-sized avatar
🎯
Focusing

Piotr Sobieszczański sobi3ch

🎯
Focusing
View GitHub Profile
@sobi3ch
sobi3ch / login.sh
Created February 2, 2015 13:57
Login to Drupal via https
#!/bin/bash
# Obviously change name and pass values and example.com domain
curl --insecure \
--cookie ./cookie.txt \
--cookie-jar ./cookie.txt \
-e example.com \
-d "name=admin" \
-d "pass=admin" \
-d "form_id=user_login" \
https://example.com/user
@sobi3ch
sobi3ch / docker-ip.sh
Created May 29, 2015 13:02
docker-ip
#!/bin/sh
# Get IP address from latest docker instance
exec docker inspect --format '{{ .NetworkSettings.IPAddress }}' "$@"
@sobi3ch
sobi3ch / gist:8c74fe7531000e4b4d9c
Created July 2, 2015 12:14
Drush import .sql.gz with progress bar
# Make sure you have pv and zcat already installed
pv my_database.sql.gz | zcat | drush sqlc
# Example output:
# 433kB 0:00:00 [ 658kB/s] [============================================================================================>] 100%
@sobi3ch
sobi3ch / backup.sh
Created July 6, 2015 21:27
One line drush DB backup without cashe tables (defined in drushrc.php "common" in this example)
#!/bin/bash
drush -y sql-dump --structure-tables-key=common --gzip --result-file=path/based/on/drupal/root/to/your/backup.sql
@sobi3ch
sobi3ch / gist:956293
Last active September 25, 2015 17:17
Programmatically insert block when you need it (D6)
<?php
function blue_get_block($module, $delta, $subject = '') {
$block = new stdclass; // empty object
$array = module_invoke($module, 'block', 'view',$delta );
// must be converted to an object
// @see block_list()
if (isset($array) && is_array($array)) {
foreach ($array as $k => $v) {
$block->$k = $v;
}
@sobi3ch
sobi3ch / gist:956292
Created May 5, 2011 00:12
helper function in template or module
<?php
function user_is_editor() {
global $user;
if(in_array(array('employee editor', 'administrator'), $user->roles) || $user->uid == 1) {
return TRUE;
} else {
return FALSE;
}
}
@sobi3ch
sobi3ch / page.tpl.php
Created May 5, 2011 00:10
drupal 6 latest jquery support
<?php
/**
* General utility variables:
* - $base_path: The base URL path of the Drupal installation. At the very
* least, this will always default to /.
* - $css: An array of CSS files for the current page.
* - $directory: The directory the template is located in, e.g. modules/system
* or themes/garland.
* - $is_front: TRUE if the current page is the front page. Used to toggle the mission statement.
* - $logged_in: TRUE if the user is registered and signed in.
@sobi3ch
sobi3ch / settings.php
Created November 23, 2011 16:23
dobrafaza nadpisywanie wszystkich linkow
/**
* overwrite all links with extra subkultura _GET parametr
* This is usefull for people that send link over IM's
* @param type $path
* @param type $options
* @param type $original_path
*/
function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
if(isset($_SESSION['subculture'])) {
if(!empty($options['query'])) {
@sobi3ch
sobi3ch / config.xml
Created November 27, 2012 17:32
settings for fileconvoyer
<?xml version="1.0" encoding="UTF-8"?>
<config>
<!-- Sources -->
<sources ignoredDirs="CVS:.svn:tmp:.git:.hg:.bzr">
<source name="drupal" scanPath="/var/www/versions/phoenix109-piotrek" documentRoot="/var/www/versions/phoenix109-piotrek" basePath="/" />
</sources>
<!-- Servers -->
<servers>
<server name="rackspace" transporter="cumulus">
@sobi3ch
sobi3ch / gist:5795468
Created June 17, 2013 08:33
How to cat colorized cat with your own 'c' command
$ sudo easy_install Pygments
$ alias c='pygmentize -O style=monokai -f console256 -g'