Skip to content

Instantly share code, notes, and snippets.

@Soraph
Soraph / haproxy.cfg
Created July 28, 2023 14:36
Out of the box default configuration file for haproxy-1.8.27-5.el8.x86_64
#---------------------------------------------------------------------
# Example configuration for a possible web application. See the
# full configuration options online.
#
# https://www.haproxy.org/download/1.8/doc/configuration.txt
#
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# Global settings
@Soraph
Soraph / clean_repo.sh
Created November 16, 2022 14:36
Repo maintenance, be sure to not have things in stash
git fetch --prune
git branch -vv | grep -i 'gone' | awk '{print $1}' | xargs git branch -D
git fsck --full
git reflog expire --expire=now --all
git repack -a -d -l
git gc --prune=now --aggressive
#!/bin/bash
#Author: Matteo Canu <soraph88@gmail.com>
# Handy script to resize and optimize image size.
# Version 0.2.1
# 2020-02-07: Linting and cleanup
wkpath=
@Soraph
Soraph / soraph_range.js
Last active September 11, 2017 14:14
Range function for JavaScript
const sRange = (from, to, includeUpperLimit = false) => {
/*
* Params:
*
* from: integer, first value of cycle and the Array
* to: integer, last value of the cycle
* includeUpperLimit: boolean, if true will use to as last
* element of the Array
*
* Works like Python's range() but two params are mandatory.
@Soraph
Soraph / environment.rb
Created October 29, 2013 09:09
field_error_proc override to add the "has-error" class
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
if html_tag.match(/class=(\'|\")([\w\s\d]*?)\1/i)
html_tag.gsub(/class=(\'|\")([\w\s\d]*?)\1/i, 'class="\2 has-error"')
else
html_tag.gsub(/\<[\w]+/i, '\0 class="has-error"')
end
end
@Soraph
Soraph / my.module
Created October 10, 2013 14:09
Example for Tushar
function my_menu() {
$items['path/page'] = array(
'title' => t('Page title'),
'page callback' => 'mypage_callback_function',
'page arguments' => array('my','totally','optional','argumet','list'),
);
return $items;
}
// All your other module logic
@Soraph
Soraph / styles.css
Created September 25, 2013 08:34
Using generic font-family to have consistency across operative systems http://www.w3.org/TR/CSS2/fonts.html#generic-font-families
pre {
font-family: monospace;
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
/*
padding: XX;
margin: XX;
@Soraph
Soraph / template.php
Created September 17, 2013 15:53
Removing CSS in Drupal 7 with hook_css_alter(&$css)
<?php
function yourtheme_css_alter(&$css){
$to_be_removed = array('sites/all/modules/example_module/styles/example_module_css.css' => FALSE,);
$css = array_diff_key($css,$to_be_removed);
}
@Soraph
Soraph / template.php
Last active December 22, 2015 23:59
Drupal 7 theme function to update the jQuery version used by the website, strongly recommended to restrict this to specific URLs, it will create issues in the default administration theme. More info: http://oldwildissue.wordpress.com/2012/11/19/drupal-7-manually-update-jquery-version/
<?php
function yourtheme_js_alter(&$javascript) {
[...]your stuffs[...]
$jquery_new = drupal_get_path('theme','yourtheme') . '/js/jquery-1.10.2.min.js';
$javascript[$jquery_new] = $javascript['misc/jquery.js'];
$javascript[$jquery_new]['version'] = '1.10.2';
$javascript[$jquery_new]['data'] = $jquery_new;
@Soraph
Soraph / htaccess_ie-edge_chromeframe
Created September 13, 2013 13:04
.htaccess instruction to force the use of the latest IE version or ChromeFrame if is present
<IfModule mod_headers.c>
Header append X-UA-Compatible "IE=edge,chrome=1"
<FilesMatch "\.(appcache|crx|css|eot|gif|htc|ico|jpe?g|js|m4a|m4v|manifest|mp4|oex|oga|ogg|ogv|otf|pdf|png|safariextz|svg|svgz|ttf|vcf|webm|webp|woff|xml|xpi)$">
Header unset X-UA-Compatible
</FilesMatch>
</IfModule>