Skip to content

Instantly share code, notes, and snippets.

View oskarnrk's full-sized avatar
💭
"Mi avvalgo della facoltà di non comprendere" (cit.)

Oscar Zambotti oskarnrk

💭
"Mi avvalgo della facoltà di non comprendere" (cit.)
View GitHub Profile
var http = require('http');
var url = require('url');
var path = require('path');
var fs = require('fs');
var port = process.argv[2] || 8080;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname;
var filename = path.join(process.cwd(), uri);
@oskarnrk
oskarnrk / mod_xml2enc-installer.sh
Last active December 14, 2020 01:09
Install mod_xml2enc for Apache2 in Ubuntu 13.10 or later
#!/bin/sh
sudo apt-get install apache2-prefork-dev libxml2 libxml2-dev apache2-dev
mkdir ~/modbuild/ && cd ~/modbuild/
wget http://apache.webthing.com/svn/apache/filters/mod_xml2enc.c
wget http://apache.webthing.com/svn/apache/filters/mod_xml2enc.h
sudo apxs2 -aic -I/usr/include/libxml2 ./mod_xml2enc.c
cd ~
sudo rm -rfd ~/modbuild/
sudo service apache2 restart
@oskarnrk
oskarnrk / bashrc_add-home-bin-to-path.sh
Created December 5, 2014 10:11
Add /home/$USER/bin directory to path. (In Ubuntu: use this code in .bashrc)
#!/bin/sh
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
@oskarnrk
oskarnrk / disable-tabs-striped.js
Created March 3, 2015 15:38
[Ionic] Disable the default tabs-striped behavior for Android
angular.module( ... )
.config(['$ionicTabsConfig', function($ionicTabsConfig) {
// Override the Android platform default to add "tabs-striped" class to "ion-tabs" elements.
$ionicTabsConfig.type = '';
}])
@oskarnrk
oskarnrk / photos_exifdatetime_to_filename.sh
Created March 11, 2016 10:26
Rename photos using EXIF date and time
#!/bin/sh
#for f in *
#do
# moddate=$(date -r "$f" +"%Y%m%d_%H%M%S")
# mv "$f" "IMG_$moddate.jpg"
#done
exiftool -v '-filename<datetimeoriginal' IMG_%Y%m%d_%H%M.jpg *
@oskarnrk
oskarnrk / photos_filename_to_exifdatetime.sh
Created March 11, 2016 10:27
Change EXIF data using date and time written in photo's filename
#!/bin/sh
exiftool '-datetimeoriginal<filename' IMG_%Y%m%d_%H%M.jpg *
@oskarnrk
oskarnrk / rounddecimalplaces.js
Last active April 29, 2021 06:56
Round a number by decimal places (default: 1)
const roundDecimalPlaces = (num, decimalPlaces) => {
// default: 1 decimal places
decimalPlaces = !decimalPlaces ? 1 : decimalPlaces;
return Math.round(num * 10 * decimalPlaces) / (10 * decimalPlaces);
}
@oskarnrk
oskarnrk / isvalidemail.js
Last active April 29, 2021 06:57
Check if is a valid URL
const validEmailRegexp = /^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i;
const isValidEmail = email => validEmailRegexp.test(email);
@oskarnrk
oskarnrk / SearchTablesByColumnName.sql
Last active October 11, 2018 09:38
Search which tables have a column by name
SELECT c.name AS 'ColumnName'
,t.name AS 'TableName'
FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
WHERE c.name LIKE '%MyName%'
ORDER BY TableName
,ColumnName;
@oskarnrk
oskarnrk / SearchTablesAndViewsByColumnName.sql
Created October 11, 2018 09:38
Search which tables or views have a column by name
SELECT COLUMN_NAME AS 'ColumnName'
,TABLE_NAME AS 'TableName'
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME LIKE '%MyName%'
ORDER BY TableName
,ColumnName;