Skip to content

Instantly share code, notes, and snippets.

View piffall's full-sized avatar
🏠
Working from home

Cristòfol Torrens piffall

🏠
Working from home
View GitHub Profile
@piffall
piffall / mikrotik-if-version.sh
Last active June 5, 2017 00:29
Mikrotik "IF" statement example code
# Mikrotik "if" statement example
:global version [/system resource get version ]
:if (version>=6.5) do={
# Do some stuff
} else={
# Do some other stuff
}
@piffall
piffall / git-colors.sh
Last active January 4, 2016 02:59
git colors
#!/bin/sh
git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto
git config --global color.status auto
@piffall
piffall / vb-add-hd.sh
Last active January 4, 2016 03:09
Add physical HD to VirtualBox
#!/bin/sh
sudo VBoxManage internalcommands createrawvmdk -filename /mnt/resources/$1.vmdk -rawdisk $2
sudo chmod 777 /mnt/resources/$1.vmdk
@piffall
piffall / mssql_server_php_freetds_debian.md
Last active June 11, 2024 21:52
MS SQL Server/PHP with FreeTDS (Debian/Ubuntu)

MS SQL Server/PHP with FreeTDS (Debian/Ubuntu)

Install required packages

sudo aptitude install freetds-bin freetds-common tdsodbc odbcinst php5-odbc unixodbc

Edit /etc/odbcinst.ini, and add the following lines

[FreeTDS]
@piffall
piffall / desktop-file-install.sh
Created September 26, 2014 13:38
Create and install Application Launcher
#!/bin/bash
desktop-file-install example.desktop
@piffall
piffall / cache.php
Created October 16, 2014 06:44
Cache HTTP header PHP
<?php
$ttl = 5*60; // Minutes x seconds
header_remove("Pragma");
header("Cache-Control: private,max-age=$ttl");
header("Date: ".gmdate('D, d M Y H:i:s \G\M\T',time()));
header("Expires: ".gmdate('D, d M Y H:i:s \G\M\T',time()+$ttl));
?>
@piffall
piffall / git-aliases.sh
Last active August 29, 2015 14:13
Git aliases
#!/bin/bash
git config alias.taglog "log --tags --decorate=full"
@piffall
piffall / git-help.gradle
Last active August 29, 2015 14:13
Get version from git tagging
// Copy and paste the content of this file in app/build.gradle
// Now you are able to use it under defaultConfig, for example:
// versionCode getRevCount()
// versionName getTag() + '-' + getRevHash()
System.println( "App: " + "com.example.app" + " v" + getTag() + '-' + getRevHash() + "(" + getRevCount() + ")" )
def getTag() {
def cmd1 = "git rev-list --tags --max-count=1"
def proc1 = cmd1.execute()
-- http://dossy.org/2011/09/mysql-geo-distance-code-and-samples/
DELIMITER $$
DROP FUNCTION IF EXISTS geodist $$
CREATE FUNCTION geodist (
src_lat DECIMAL(9,6), src_lon DECIMAL(9,6),
dst_lat DECIMAL(9,6), dst_lon DECIMAL(9,6)
) RETURNS DECIMAL(6,2) DETERMINISTIC
BEGIN
@piffall
piffall / mikrotik-if-something.sh
Created March 5, 2015 11:58
Mikrotik "IF" statement example code (another one)
# If something do something
:if ( [ :len [ /somepath find where somematch="match" ] ] > 0 ) do={
# Do something
} else {
# Do something else
}