File file = new File("trades_3.txt");The Files class doc.
List<String> lines = Files.readLines(file, Charset.defaultCharset());
Monday, October 27, 2014
Guava Files class
Sometimes you are still in the Java 1.6 land and you just to want to read the entire file into a list. Guava can help you:
Saturday, October 11, 2014
Foundation and Empire
- Part I: The General
- Search for Magicians
- The Magicians
- The Dead Hand
- The Emperor
- The War Begins
- The Favorite
- Bribery
- To Trantor
- On Trantor
- The War Ends
- Part II The Mule
- Bride and Groom
- Captain and Mayor
- Lieutenant and Clown
- The Mutant
- The Psychologist
- Conference
- The Visi-Sonor
- Fall of the Foundation
- Start of the Search
- Conspirator
- Interlude in Space
- Death on Neotrantor
- The Ruins of Trantor
- Convert
- Death of a Psychologist
- End of the Search
Labels:
Asimov,
Foundation and Empire,
Foundation series
Friday, October 3, 2014
IPTABLES
# List the rules with line numbers,
# the -n disables the DNS reverse lookup
iptables -n --list --line-numbers
# Block a specific IP
iptables -A INPUT -s 192.168.0.1 -j DROP
# Allow SSH for a specific IP
iptables -A INPUT -s 192.168.0.2 -p tcp -m tcp --dport 22 -j ACCEPT
# Delete a rule based on its number
iptables -D INPUT 8
# Insert rule before other certain one
# For example before line # 3
iptables -I INPUT 3 -s 192.168.0.2 -p tcp -m tcp --dport 22 -j ACCEPT
# the -n disables the DNS reverse lookup
iptables -n --list --line-numbers
# Block a specific IP
iptables -A INPUT -s 192.168.0.1 -j DROP
# Allow SSH for a specific IP
iptables -A INPUT -s 192.168.0.2 -p tcp -m tcp --dport 22 -j ACCEPT
# Delete a rule based on its number
iptables -D INPUT 8
# Insert rule before other certain one
# For example before line # 3
iptables -I INPUT 3 -s 192.168.0.2 -p tcp -m tcp --dport 22 -j ACCEPT
Thursday, September 25, 2014
Java 8 installation on Fedora 14
- Download Java SDK/JRE from Oracle: http://www.oracle.com/technetwork/java/javase/downloads/server-jre8-downloads-2133154.html. (I selected the server version).
- Extract the files into /usr/local/java. (I created the java directory).
- Use the alternatives program to create the necessary links:
- [root@Fedora-test ~]# alternatives --install /usr/bin/java java /usr/local/java/jdk1.8.0_20/bin/java 20000
- Run the alternatives config command:
[root@Fedora-test ~]# alternatives --config java
Select the option for Java 8
- Test it:
[root@Fedora-test ~]# java -versionThe following link was useful: http://www.dafoot.co.uk/index.php/menuitemcomputing/linux/101-fedora-12-alternatives-program-to-manage-java-runtimes-jdkjre
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
Tuesday, September 23, 2014
Thursday, September 11, 2014
Dumping computer’s DMI (SMBIOS) in Linux
dmidecode
dmidecode -t
The SMBIOS specification defines the following DMI types:
Type Information
--------------------------------------------
0 BIOS
1 System
2 Baseboard
3 Chassis
4 Processor
5 Memory Controller
6 Memory Module
7 Cache
8 Port Connector
9 System Slots
10 On Board Devices
11 OEM Strings
12 System Configuration Options
13 BIOS Language
14 Group Associations
15 System Event Log
16 Physical Memory Array
17 Memory Device
18 32-bit Memory Error
19 Memory Array Mapped Address
20 Memory Device Mapped Address
21 Built-in Pointing Device
22 Portable Battery
23 System Reset
24 Hardware Security
25 System Power Controls
26 Voltage Probe
27 Cooling Device
28 Temperature Probe
29 Electrical Current Probe
30 Out-of-band Remote Access
31 Boot Integrity Services
32 System Boot
33 64-bit Memory Error
34 Management Device
35 Management Device Component
36 Management Device Threshold Data
37 Memory Channel
38 IPMI Device
39 Power Supply
40 Additional Information
41 Onboard Devices Extended Information
42 Management Controller Host Interface
dmidecode -t
The SMBIOS specification defines the following DMI types:
Type Information
--------------------------------------------
0 BIOS
1 System
2 Baseboard
3 Chassis
4 Processor
5 Memory Controller
6 Memory Module
7 Cache
8 Port Connector
9 System Slots
10 On Board Devices
11 OEM Strings
12 System Configuration Options
13 BIOS Language
14 Group Associations
15 System Event Log
16 Physical Memory Array
17 Memory Device
18 32-bit Memory Error
19 Memory Array Mapped Address
20 Memory Device Mapped Address
21 Built-in Pointing Device
22 Portable Battery
23 System Reset
24 Hardware Security
25 System Power Controls
26 Voltage Probe
27 Cooling Device
28 Temperature Probe
29 Electrical Current Probe
30 Out-of-band Remote Access
31 Boot Integrity Services
32 System Boot
33 64-bit Memory Error
34 Management Device
35 Management Device Component
36 Management Device Threshold Data
37 Memory Channel
38 IPMI Device
39 Power Supply
40 Additional Information
41 Onboard Devices Extended Information
42 Management Controller Host Interface
Additionally, type 126 is used for disabled entries and type 127 is an end-of-table marker. Types 128 to 255 are for OEM-specific data.
Keywords can be used instead of type numbers with --type. Each keyword is equivalent to a list of type numbers:
Keyword Types
------------------------------
bios 0, 13
system 1, 12, 15, 23, 32
baseboard 2, 10, 41
chassis 3
processor 4
memory 5, 6, 16, 17
cache 7
connector 8
slot 9
Wednesday, August 13, 2014
Excel Regular Expressions
Sub RegEx_Tester()
Dim objRegExp_1 As Object
Dim regExp_Matches As Object
Dim strToSearch As String
Set objRegExp_1 = CreateObject("vbscript.regexp")
objRegExp_1.Global = True
objRegExp_1.IgnoreCase = True
objRegExp_1.Pattern = "[a-z,A-Z]*@[a-z,A-Z]*.com"
strToSearch = "ABC@xyz.com"
Set regExp_Matches = objRegExp_1.Execute(strToSearch)
If regExp_Matches.Count = 1 Then
MsgBox ("This string is a valid email address.")
End If
End Sub
Dim objRegExp_1 As Object
Dim regExp_Matches As Object
Dim strToSearch As String
Set objRegExp_1 = CreateObject("vbscript.regexp")
objRegExp_1.Global = True
objRegExp_1.IgnoreCase = True
objRegExp_1.Pattern = "[a-z,A-Z]*@[a-z,A-Z]*.com"
strToSearch = "ABC@xyz.com"
Set regExp_Matches = objRegExp_1.Execute(strToSearch)
If regExp_Matches.Count = 1 Then
MsgBox ("This string is a valid email address.")
End If
End Sub
Subscribe to:
Posts (Atom)