Skip to content

Instantly share code, notes, and snippets.

@vordan
vordan / text-select.js
Created February 23, 2018 20:47
[DIV Text Selected On Mouse Over and Click] Working solution for selecting text in a div on events #JavaScript
// https://www.princeawful.com/807/solved-text-selected-mouse-and-click
function SelectText(element) {
 var doc = document
  , text = doc.getElementById(element)
  , range, selection
 ;
 if (doc.body.createTextRange) {
  range = document.body.createTextRange();
  range.moveToElementText(text);
@vordan
vordan / new_file0
Created September 24, 2017 18:47
How To Use SSHFS to Mount Remote File Systems Over SSH
Installing sshfs
===================
SSHFS is Linux based software that needs to be installed on your local computer.
On Ubuntu and Debian based systems it can be installed through apt-get.
sudo apt-get install sshfs
Mounting the Remote File System
===============================
@vordan
vordan / new_gist_file_0
Last active August 3, 2017 12:22
Инсталација на фонтови
Инсталација на фонтови
------------------------------------------------
wget 10.10.10.98/fonts/infomatrix-fonts.zip
cd /usr/share/fonts/truetype/
mkdir infomatrix
mv infomatrix-fonts.zip infomatrix
cd infomatrix
unzip infomatrix-fonts.zip
wget 10.10.10.98/fonts/msttcorefonts.zip
@vordan
vordan / command-not-found.sh
Created May 30, 2017 09:46
Sorry, command-not-found has crashed!
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
sudo dpkg-reconfigure locales
@vordan
vordan / php-geoip-install.sh
Last active June 27, 2021 09:16
Installing PHP GeoIP on UbuntuTo make GeoIP work on PHP
# Installing PHP GeoIP on Ubuntu To make GeoIP work on PHP
# all the functions in http://php.net/manual/en/book.geoip.php
# php5-geoip and GeoCityLite.dat must be installed.
apt-get install php5-geoip
mkdir /usr/local/share/GeoIP
cd /usr/share/local/GeoIP
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz
service apache2 restart
@vordan
vordan / update.sh
Created April 25, 2017 10:56
Why after fresh Ubuntu 12.04 installation update aren't being installed?
sudo rm /var/lib/apt/lists/* -vf
sudo apt-get clean
sudo apt-get autoremove
sudo apt-get update
sudo apt-get dist-upgrade
@vordan
vordan / random_big_number.sql
Last active September 6, 2023 18:07
Generate random date between two dates in MySQL
select
concat(round(rand() * 10000),
round(rand() * 10000),
round(rand() * 10000),
round(rand() * 10000)
) as rnd
;
@vordan
vordan / monitor.sh
Created April 8, 2017 06:55
Set monitor resolution on GDM start
As root:
--------------------------------------------------------------------------------
Generate monitor resolution string:
cvt 1680 1050 60
Sample output:
# 1680x1050 59.95 Hz (CVT 1.76MA) hsync: 65.29 kHz; pclk: 146.25 MHz
Modeline "1680x1050_60.00" 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync
--------------------------------------------------------------------------------
@vordan
vordan / locale.sh
Last active July 29, 2023 18:24
How-to fix "Warning: No support for locale: en_US.utf"
This is because locale-gen is using an archive file to store all the locales, but many utilities are still looking for the locale files.
Have a look at /usr/lib/locale/. If your output looks like this, read on:
ls /usr/lib/locale/
C.UTF-8 locale-archive
The warning isn't critical, as far as I can tell, but if it bothers you or causes troubles, try the following in a terminal window:
@vordan
vordan / purge-old-kernels.sh
Last active April 6, 2017 09:37
Remove old kernel versions to clean up the boot menu
#!/bin/bash
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'|grep -E "(image|headers)" | xargs sudo apt-get -y purge