Rāda ziņas ar etiķeti Snippet. Rādīt visas ziņas
Rāda ziņas ar etiķeti Snippet. Rādīt visas ziņas

trešdiena, 2010. gada 24. marts

Create a symbolic link

To create a symbolic link on Linux, you must type:

ln -s /path/to/real/file /path/to/non-existant/file



Help: ln --help

ceturtdiena, 2009. gada 3. decembris

Translit directory names

#!/bin/bash

DIREKTORIJA="/home/bh/test/";

ls -d $DIREKTORIJA*/ | while read -r FILE

do

mv -v "$FILE" `echo "$FILE" | iconv -f UTF-8 -t ASCII//TRANSLIT -c | tr ' ' '_'`

done

trešdiena, 2009. gada 2. decembris

Skaneris Ubuntu

Veca skanera piedabūšana.

Komanda ar kuru noteikt, kas pieslēgts pie USB: lsusb (http://linuxcommand.org/man_pages/lsusb8.html)
Komanda ar kuru noteikt skanera modeli: scanimage -L (http://www.sane-project.org/man/scanimage.1.html)

Savācam attiecīgo failu: http://www.meier-geinitz.de/sane/gt68xx-backend/
iekopējam iekš /usr/share/sane/gt68xx/

Ja neiet, tad komanda scanimage pateiks kāds fails trūkst.

Ja iet, tad xsane un tāda garā.

trešdiena, 2009. gada 30. septembris

MySQL database sql dump file

Export database to sql file:

mysqldump -u USER -p PASSWORD DATABASE > filename.sql

Import sql dump file to mySQL database:

mysql -u USER -p PASSWORD DATABASE < filename.sql

ceturtdiena, 2009. gada 3. septembris

Using Nautilus with root permission

gksudo gedit /usr/share/applications/Nautilus-root.desktop

Insert those lines into the file:

[Desktop Entry]
Name=File Browser (Root)
Comment=Browse the filesystem with the file manager
Exec=gksudo "nautilus --browser %U"
Icon=file-manager
Terminal=false
Type=Application
Categories=Application;System;

Save file. Go to: Applications -> System Tools -> File Browser (Root)

Or:
apt-get install nautilus-gksu

After Logout, Login: Right-click on a folder and "open as administrator"

sestdiena, 2009. gada 15. augusts

TrueCrypt MBR, Ubuntu GRUB

Notes for myself. Boot from Ubuntu Live CD.

sudo su
mkdir /nix
mount /dev/sdb2 /nix

mkdir /nix/back

cp /nix/truecrypt.mbr /nix/back/truecrypt.mbr
cp /nix/truecrypt.backup /nix/back/truecrypt.backup
rm /nix/truecrypt.backup
rm /nix/truecrypt.mbr

sudo dd if=/dev/sda of=/nix/truecrypt.mbr count=1 bs=512
sudo dd if=/dev/sda of=/nix/truecrypt.backup count=8 bs=3225


sudo grub
root (hd1,1)
setup (hd0)
quit

gedit /nix/boot/grub/menu.lst

### END DEBIAN AUTOMAGIC KERNELS LIST

title TrueCrypt
rootnoverify (hd0,0)
makeactive
chainloader (hd1,1)/truecrypt.mbr
boot

http://ubuntuforums.org/showthread.php?t=761530

pirmdiena, 2009. gada 26. janvāris

someone's age in years

<?php

$dob = '1984-09-04';

$age = date('Y') - date('Y', strtotime($dob));

if (date('md') < date('md', strtotime($dob))) {

    $age--;

}

?>

otrdiena, 2009. gada 13. janvāris

Changing User Agent for Mozilla Firefox

1. Open up Firefox browser.
2. In the adderss bar, type the following: about:config
3. You will see lots of preference names and their respective value. Search for “general.useragent.extra.firefox” by scrolling alphabetically or using filter.
4. Right click and select Modify or double click on it.
5. In the Enter string value dialog box, type in the user agent string that you want to simulate, such as “Googlebot 2.1″ to surf as Google spider bot.
6. To change back to the default user agent, simply right click on the line and select Reset.

OR

User Agent Switcher :: Firefox Add-ons

piektdiena, 2008. gada 26. decembris

Page Redirection

JavaScript:

var sURL = unescape(window.location.pathname);

function refresh(){
window.location.href = sURL;
}


or

function refresh(){
window.location.replace(sURL);
}


Meta refresh:
<meta equiv="refresh" content="0;url=http://example.com/" />

svētdiena, 2008. gada 21. decembris

Windows Last Shutdown

VBScript Script File:
strValueName = "HKLM\SYSTEM\CurrentControlSet\Control\Windows\" _
& "ShutdownTime"
Set oShell = CreateObject("WScript.Shell")
Ar = oShell.RegRead(strValueName)
Term = Ar(7)*(2^56) + Ar(6)*(2^48) + Ar(5)*(2^40) + Ar(4)*(2^32) _
+ Ar(3)*(2^24) + Ar(2)*(2^16) + Ar(1)*(2^8) + Ar(0)
Days = Term/(1E7*86400)
WScript.Echo "ShutdownTime = " & CDate(DateSerial(1601, 1, 1) + Days) _
& " UTC"

pirmdiena, 2008. gada 15. decembris

Make an ISO Image

To make an ISO from your CD/DVD, place the media in your drive but do not mount it. If it automounts, unmount it.

dd if=/dev/dvd of=dvd.iso # for dvd
dd if=/dev/cdrom of=cd.iso # for cdrom
dd if=/dev/scd0 of=cd.iso # if cdrom is scsi

To make an ISO from files on your hard drive, create a directory which holds the files you want. Then use the mkisofs command.

mkisofs -o /tmp/cd.iso /tmp/directory/

This results in a file called cd.iso in folder /tmp which contains all the files and directories in /tmp/directory/.

Windows

VaporCD can create a copy of a CD on your hard disk and mount it as if it were the real CD:
http://vaporcd.sourceforge.net/

http://www.granneman.com/techinfo/linux/burningcds/makeanisoimage.htm

ceturtdiena, 2008. gada 27. novembris

Speed Tweaks for TOR

Lets get to editing our torrc so we can improve the speed!

gedit ~/.vidalia/torrc

Paste this at the beginning of the torrc:

# Set the Tor Circuit Build time to find faster tor servers, increments of seconds

CircuitBuildTimeout 2

# connections while Tor is not in use.

KeepalivePeriod 60

# Force Tor to consider whether to build a new circuit every NUM seconds.

NewCircuitPeriod 15

# Set How many entry guards we should we keep at a time

NumEntryGuards 8

otrdiena, 2008. gada 14. oktobris

Ubuntu and Kernel Version commands

Ubuntu version command line:

cat /etc/lsb-release


Result like this:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04.1"


Kernel version command line:

uname -r


Result like this:

2.6.24-19-generic


Or:

uname -a


Result like this:

Linux bh-desktop 2.6.24-19-generic #1 SMP Wed Aug 20 22:56:21 UTC 2008 i686 GNU/Linux

otrdiena, 2008. gada 30. septembris

ISPmanager PHP script from cron

Add the line below into the scheduler
/usr/local/bin/php -q /home/user/data/www/domain_name/script.php


If your script runs through a web browser, use the following line
/usr/local/bin/GET http://domain_name/required_script.php


http://www.minivds.com/technology/faq/firststeps.html
http://en.wikipedia.org/wiki/Cron

trešdiena, 2008. gada 24. septembris

DVD capacity

Capacity and nomenclature[10][11]
Designation Sides Layers
(total)
Diameter Capacity
(cm) (GB) (GiB)
DVD-1[12] SS SL 1 1 8 1.46 1.36
DVD-2 SS DL 1 2 8 2.66 2.47
DVD-3 DS SL 2 2 8 2.92 2.72
DVD-4 DS DL 2 4 8 5.32 4.95
DVD-5 SS SL 1 1 12 4.70 4.37
DVD-9 SS DL 1 2 12 8.54 7.95
DVD-10 DS SL 2 2 12 9.40 8.74
DVD-14[13] DS DL/SL 2 3 12 13.24 12.32
DVD-18 DS DL 2 4 12 17.08 15.90

DVD - Wikipedia, the free encyclopedia

4.7GB = 4.38GB.

Long story short - media companies / salesmen and women claim that 1GB = 1000 MB, 1MB = 1000KB and 1KB = 1000B. Of course we all know that 1GB = 1024 MB, 1MB = 1024KB and 1KB = 1024B.

So, 4.7GB = 4,700,000,000B according to the companies.

But really, 4,700,000,000 / 1024 / 1024 /1024 = 4.377GB

http://www.videohelp.com/forum/archive/can-you-make-a-4-7-gb-dvd-r-actually-fit-4-7-gb-t313580.html

ceturtdiena, 2008. gada 18. septembris

Mozilla Firefox about:config

This is a reference to the entries in about:config, where all user preferences can be viewed and modified. Entries that apply to Firefox or Thunderbird may also apply to Mozilla Suite/SeaMonkey and vice versa.

About:config entries - MozillaZine Knowledge Base

trešdiena, 2008. gada 17. septembris

Change language The GIMP

In windows, you should be able to change the languge of gtk+ to english by adding a new environment variable 'lang' with a value of 'c'.
( right-click on My Computer -> properties -> Advanced -> Environment Variables )

http://www.kirupa.com/forum/showthread.php?t=244236

Snippet (programming)

Snippet is a programming term for a small region of re-usable source code or text. Ordinarily, these are formally-defined operative units to incorporate into larger programming modules. Snippets are often used to clarify the meaning of an otherwise "cluttered" function, or to minimize the use of repeated code that is common to other functions.

Snippet management is a feature of some text editors, program source code editors, IDEs, and related software. It allows the user to persist and use snippets in the course of routine edit operations.

Snippet (programming) - Wikipedia, the free encyclopedia