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 / 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'
@sobi3ch
sobi3ch / gist:5451004
Last active October 24, 2017 17:10
PHP Array pluck function
<?php
/**
* Pluck an array of values from an array. (Only for PHP 5.3+)
*
* @param $array - data
* @param $key - value you want to pluck from array
*
* @return plucked array only with key data
*/
function array_pluck($array, $key) {
@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 / 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 / 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.