Skip to content

Instantly share code, notes, and snippets.

View Tab3r's full-sized avatar
💭
Coffee time! ☕️

David Tabernero Pérez Tab3r

💭
Coffee time! ☕️
View GitHub Profile
@Tab3r
Tab3r / rename.ps1
Created February 1, 2018 10:40
Massive rename files removing first characters
get-childitem *.mp4 | rename-item -newname { [string]($_.name).substring(3) }
@Tab3r
Tab3r / install_nextcloud.sh
Created December 12, 2017 21:44
Install nextcloud
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install apache2 php7.0 php7.0-gd sqlite php7.0-sqlite3 php7.0-curl
sudo apt-get install php7.0-gd php7.0-json php7.0-curl php7.0-mbstring php7.0-intl php7.0-mcrypt php-imagick php7.0-xml php7.0-zip
sudo service apache2 restart
cd /var/www/html
curl https://download.nextcloud.com/server/releases/nextcloud-12.0.4.tar.bz2 | sudo tar -jxv
cd /var/www/html/nextcloud
sudo mkdir -p /var/www/html/nextcloud/data
sudo chown www-data:www-data /var/www/html/nextcloud/data
@Tab3r
Tab3r / owncloud-update.sh
Last active November 12, 2017 21:40
Updating owncloud manually
sudo wget https://download.owncloud.org/community/owncloud-8.1.12.zip
sudo service nginx stop
sudo mv owncloud owncloud-8.0
sudo unzip ./owncloud-8.1.12.zip
sudo cp ./owncloud-8.0/config/config.php ./owncloud/config/
sudo mv ./owncloud-8.0/data ./owncloud/
sudo chown -R www-data:www-data ./owncloud
cd owncloud
sudo -u www-data php occ upgrade
sudo service nginx start
SELECT jsonb_build_object(
'type', 'FeatureCollection',
'features', jsonb_agg(feature)
)
FROM (
SELECT jsonb_build_object(
'type', 'Feature',
'id', gid,
'geometry', ST_AsGeoJSON(geom)::jsonb,
'properties', to_jsonb(row) - 'gid' - 'geom'
@Tab3r
Tab3r / apt_updates_check.sh
Created November 7, 2016 17:33
Obtain security updates in Ubuntu Server
sudo /usr/lib/update-notifier/apt-check --human-readable | awk -v RS=[0-9]+ '{print RT+0;exit}'
@Tab3r
Tab3r / installwildfly9Ubuntu1404.sh
Last active November 11, 2021 14:53
Install wildfly 9.x in Ubuntu 14.04 LTS
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
# General utils
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y install unzip
sudo apt-get -y install software-properties-common python-software-properties
@Tab3r
Tab3r / mergeshape.bat
Created July 1, 2015 11:36
Merge a lot of shapefiles with ogr2ogr (in Windows shell)
@echo off
mkdir merged
set counter=0
setlocal ENABLEDELAYEDEXPANSION
for %%f in (*.shp) do (
if not exist merged\mergedFilter.shp (
echo Uniendo %%f
ogr2ogr -f "ESRI Shapefile" merged\mergedFilter.shp %%f
@Tab3r
Tab3r / gist:ad43473fe0b00086ffc0
Last active February 12, 2017 01:38
Linux: CPU Usage in percernt
######## USING PS ##########
## Note: In hign loads, it could return more than 100% of load
# Show total %
ps aux | awk {'sum+=$3;print sum'} | tail -n 1
# Debug mode:
ps aux | awk {'value=$3; if ($3 != "0.0") {print "Adding: " value}; sum+=$3; sumt = "Total sum: " sum; print sumt'}
####### USING TOP #########
## Note: It needs 2 seconds to execute to be accurrate
top -bn 2 -d 2 | grep '^%Cpu' | tail -n 1 | awk '{print $2+$4+$6 "%"}'
@Tab3r
Tab3r / fisc.c
Created October 28, 2014 08:47
Fast Inverse Square Calculation
float FastInvSqrt(float x) {
float xhalf = 0.5f * x;
int i = *(int*)&x; // evil floating point bit level hacking
i = 0x5f3759df - (i >> 1); // what the fuck?
x = *(float*)&i;
x = x*(1.5f-(xhalf*x*x));
return x;
}
// Light beat in jQuery
function pulse(imgId) {
$(imgId).animate({
opacity: 0.7
}, 700, function() {
$(imgId).animate({
opacity: 1
}, 700);
});
};