MoonPoint Support Logo

 


Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
June
Sun Mon Tue Wed Thu Fri Sat
       
 
2017
Months
Jun


Thu, Jun 29, 2017 10:48 pm

Selecting unique column entries with SQL

If you have a MariaDB, MySQL, SQLite, etc. database that may have more than one occurrence of a value for a particular column in a table, but want to display only unique values, you can fillter out the repeated values using SELECT DISTINCT. E.g., I have a table in a database where each record, aka row, in the table holds two fields: one holds an account id (Acct) and the other a project name. An account can be associated with more than one project and any project may have many account IDs associated with it.

To produce a list of the projects in the table without listing any project more than once and to list the projects in alphabetical order, I can use the SQL statement below:

SELECT DISTINCT Project FROM Acct_Projects ORDER BY Project;

Each record, aka row, in the table holds two fields: one holds an account id (Acct) and the other a project name. For the PHP code I use to query the SQLite database that holds the data to display a list of all the projects in the table, I use the following code:

<?php

$filename   = "/Users/jasmith1/Documents/www/SGRS/SGRS.db";

$query_string = "SELECT DISTINCT Project FROM Acct_Projects ORDER BY Project";

$db_handle  = new SQLite3($filename);

$results     = $db_handle->query($query_string);

echo "<table>\n";
echo "<tr><td><b>Project</b></td></tr>\n";
while ($row = $results->fetchArray()) {
    echo "<tr><td><a href=\"project_acctids.php?project=" . 
          $row['Project']  . "\">" .  $row['Project'] . "</a></td></tr>\n";
}
echo "</table>\n";

?>

I make the project displayed on each row of the HTML table a clickable link that will open another page, project_acctids.php that will, for the project that is clicked on, display all of the account ids associated with that project.

[/software/database/sql] permanent link

Sun, Jun 25, 2017 9:27 pm

icacls

On Microsoft Windows Vista and Windows Server 2003 and later systems, you can use the Integrity Control Access Control List (icacls) program to display, modify, backup and restore Access Control Lists (ACLs) for files and folders. E.g.:

C:\>icacls C:\WINDOWS\system32\mmc.exe
C:\WINDOWS\system32\mmc.exe NT SERVICE\TrustedInstaller:(F)
                            BUILTIN\Administrators:(RX)
                            NT AUTHORITY\SYSTEM:(RX)
                            BUILTIN\Users:(RX)
                            APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES:(RX)
                            APPLICATION PACKAGE AUTHORITY\ALL RESTRICTED APPLICATION PACKAGES:(RX)

Successfully processed 1 files; Failed processing 0 files

C:\>

In the above example, the "RX" indicates read and execute access for the file for the specified accounts.

[ More Info ]

[/os/windows/commands] permanent link

Sat, Jun 24, 2017 2:36 pm

Modifying search domain settins under OS X

If you would like to be put a system's name in your web browser, e.g., ajax, into your browser's address bar and have the system automatically append a domain name, e.g. example.com, so that the browser attempts to access ajax.example.com, even though you just typed ajax, you can modify the Domain Name System (DNS) search domain settings. To do so on an Apple OS X/macOS system, take the following steps:

  1. Click on the Apple icon at the top, left-hand side of your screen.
  2. Choose System Preferences then Network.
  3. Select the relevant network service, such as Wi-Fi or Ethernet, then click on the Advanced button.
  4. Click on DNS.
  5. Click in the Search Domains box and then click on the "+" at the bottom of that box to add a new search domain.
  6. Type the name of the search domain, e.g. example.com.
  7. Click on OK

You can add multiple domains; domains will be searched in the order you list them with the search starting at the topmost entry and continuing down through the list of domains with the search stopping when a valid name is found.

[ More Info ]

[/os/os-x] permanent link

Fri, Jun 23, 2017 10:22 pm

lscpu

On a Linux system, you can use the lscpu command to obtain information on the system's Central Processing Unit (CPU). On a CentOS Linux system, the utility is included in the util-linux package. On a CentOS system, you can install that package using the yum package management utility, if it isn't already installed, using yum install util-linux. You can check on whether the lscpu program is already present using which lscpu and, on a CentOS system or another system that uses RPM, you can use rpm -qi util-linux to determine if the util-linux package is already installed.

[ More Info ]

[/os/unix/linux/utilities/sysmgmt] permanent link

Wed, Jun 21, 2017 10:09 pm

Adding an email address to Outlook Mail's Safe Sender list

If you use an outlook.com or hotmail.com email address and are not receiving email from someone whose email you wish to see, you may need to add the address to your safe sender's list. Otherwise, email from the sender may not even be placed in your junk email folder, but may, instead, just be discarded by Outlook Mail.

To add an email address to Outlook Mail's safe sender list, click on the gear icon at the top of the Outlook Mail window you will see after logging into your account then take the following steps:

  1. Select Options from the drop down list.
  2. Select Safe Senders.
  3. Type the email address that you wish to add as a new safe sender in the field below the pencil and trash can icons, hit Enter then click on Save.

[ More Info ]

[/network/email/hotmail] permanent link

Tue, Jun 20, 2017 10:22 pm

NetHogs

If you wish to monitor the top bandwidth consuming processes on a Linux system, you can use the nethogs program, which displays bandwidth usage by process. It will display the process id (PID) of the processes consuming the most bandwidth. E.g.:

NetHogs version 0.8.5

    PID USER     PROGRAM                    DEV        SENT      RECEIVED       
  19355 jim      sshd: jim@pts/0            enp1s4      0.188       0.082 KB/sec
  15022 apache   /usr/sbin/httpd            enp1s4      0.000       0.000 KB/sec
      ? root     unknown TCP                            0.000       0.000 KB/sec

  TOTAL                                                 0.188       0.082 KB/sec

The above output shows me that the two processes consuming the most bandwidth at the time the program was run had PIDs of 19355 and 15022. I can get additional information on those processes using the ps command.

$ ps 19355
  PID TTY      STAT   TIME COMMAND
19355 ?        S      0:19 sshd: jim@pts/0
$ ps 15022
  PID TTY      STAT   TIME COMMAND
15022 ?        S      0:00 /usr/sbin/httpd -DFOREGROUND
$

[ More Info ]

[/os/unix/linux/network] permanent link

Mon, Jun 19, 2017 9:39 pm

Wrapping text on a webpage

I query an SQLite database using PHP code on a webpage. One of the fields in the database is a "Note" field, where notes have been entered without any HTML code to format the text. When I display the notes on a webpage, I want to preserve the line breaks and paragraphs as they were typed. Since there are no <br> line break nor <p> paragraph tags on the page, I could display the text as typed using the pre tag, but the problem with just using that tag is that in cases where the a line is very long, someone would have to scroll far to the right to see the entire line on the webpage, if I just used the pre tag. However, I can specify a style for the pre tag that will result in the text wrapping at the right-edge of the browser window. E.g. <pre style="white-space: pre-wrap"> . Or, if I don't want the text displayed in the monospaced default font for the pre tag, I can apply the style to the <div> tag, instead. E.g.: <div style="white-space: pre-wrap">.

[ More Info ]

[/network/web/html] permanent link

Sat, Jun 17, 2017 8:02 pm

Clearing the counters for a port on a Cisco switch

You can view the counters for a port on a Cisco switch using the show interfaces command. E.g., if I want to check on whether cyclic redundancy check (CRC) errors have been occurring on port fa0/16, I can issue the command shown below:

Huron>show interfaces fa0/16
FastEthernet0/16 is up, line protocol is up (connected)
  Hardware is Fast Ethernet, address is 0009.e897.d290 (bia 0009.e897.d290)
  MTU 1500 bytes, BW 10000 Kbit, DLY 1000 usec,
     reliability 255/255, txload 19/255, rxload 1/255
  Encapsulation ARPA, loopback not set
  Keepalive set (10 sec)
  Full-duplex, 10Mb/s, media type is 100BaseTX
  input flow-control is unsupported output flow-control is unsupported
  ARP type: ARPA, ARP Timeout 04:00:00
  Last input never, output 00:00:00, output hang never
  Last clearing of "show interface" counters 2d17h
  Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
  Queueing strategy: fifo
  Output queue: 0/40 (size/max)
  5 minute input rate 24000 bits/sec, 40 packets/sec
  5 minute output rate 756000 bits/sec, 64 packets/sec
     46168 packets input, 4608074 bytes, 0 no buffer
     Received 1250 broadcasts (1161 multicast)
     0 runts, 0 giants, 0 throttles
     121 input errors, 16 CRC, 105 frame, 0 overrun, 0 ignored
     0 watchdog, 1161 multicast, 0 pause input
     0 input packets with dribble condition detected
     255151 packets output, 119141892 bytes, 0 underruns
     0 output errors, 0 collisions, 0 interface resets
     0 babbles, 0 late collision, 0 deferred
     0 lost carrier, 0 no carrier, 0 PAUSE output
     0 output buffer failures, 0 output buffers swapped out
Huron>

[ More Info ]

[/hardware/network/switch/cisco] permanent link

Thu, Jun 15, 2017 11:26 pm

Changing the duplex setting for a port on a Cisco switch

You can determine the speed and duplex settings for a port on a Cisco switch with the show interfces port_designation status. E.g.:

Huron>show interfaces fa0/1 status

Port      Name               Status       Vlan       Duplex  Speed Type
Fa0/1                        connected    1            full     10 10/100BaseTX
Huron>

Often ports will be set to autonegotiate the speed and duplex settings with the equipment connected to the port. But sometimes that autonegotiation process may not work as expected requiring you to manually set the parameters. E.g, if the piece of equipment being connected to the port on the Cisco switch is configured for a fixed mode of operation while the port on the switch is configured for autonegotiate, the speeds may be configured for matching values on both sides but there may be a duplex mismatch. As a result of that mismatch cyclic redundancy check (CRC) errors may be reported for the port on the switch. You can manually set the duplex setting by entering the enable command and then the enable password when prompted. Then enter the configure command and then enter duplex followed by full or half, e.g., duplex full.

[/hardware/network/switch/cisco] permanent link

Wed, Jun 14, 2017 11:02 pm

Installing Lynx with Homebrew

If you need a text-based web browser that doesn't require a graphical user interface (GUI), one alternative is the Lynx browser that is available for a variety of operating systems, including Linux, OS X/macOS, DOS, and Microsoft Windows. If you have the Homebrew package management software installed on a OS X/macOS system, you can use it to easily install the Lynx browser using the command brew install lynx.

Advantages to using a text-based browser such as Lynx, in addition to it not requiring a GUI, making it suitable to be run in a Terminal window, is that it doesn't support Adobe Flash, which makes it invulnerable to malware distributed through vulnerabilities in Flash. Also, because it doesn't support JavaScript nor graphics, it prevents tracking software that uses JavaScript or web bugs, aka web beacons, which can track your web browsing activities via small graphics files that will be invisible to you on a webpage, from being used to track your browsing activities. It does support HTTP cookies, though, which are also used by sites to track visitors, but Lynx will prompt you if you want to allow cookies for a site when you visit the site and has whitelisting and blacklisting capabilities. E.g., when a site tries to place a cookie on your system, Lynx will prompt you as to whether it should be allowed. You can choose from "Y/N/Always/neVer."

[ More Info ]

[/os/os-x/homebrew] permanent link

Tue, Jun 13, 2017 10:04 pm

Determining the version of Firefox on OS X

If you wish to determine the version of Firefox installed on an OS X from a command line interface (CLI), you can open a Terminal window and use the command shown below:

$ /Applications/Firefox.app/Contents/MacOS/firefox -v
Mozilla Firefox 45.8.0
$

You can also find the information in the Info.plist file found at /Applications/Firefox.app/Contents/Info.plist. The version number will be on the line following the "key" line for CFBundleGetInfoString and also after the "key" line for CFBundleShortVersionString .

        <key>CFBundleGetInfoString</key>
        <string>Firefox 45.8.0</string>

        <key>CFBundleShortVersionString</key>
        <string>45.8.0</string>

[ More Info ]

[/os/os-x] permanent link

Mon, Jun 12, 2017 7:22 am

Can't Force Quit Firefox

Firefox (version 45.8.0) became unresponsive on my MacBook Pro running OS X El Capitan (10.11.6). I killed Firefox by clicking on the Apple icon at the top, left-hand corner of the page and selecting Force Quit and then selecting Firefox in the list of running applications and then clicking on the Force Quit button.

Force Quit Applications - Firefox

I then restarted Firefox by clicking on its icon in the Dock. The icon bounced a few times and then stopped, so I assumed Firefox was now running. But when I tried accessing it by holding down the command while repeatedely tapping the tab key to cycle through the open applications, it didn't appear. Nor did it show up in the list of running processes shown by the Activity Monitor.

[ More Info ]

[/os/os-x] permanent link

Sun, Jun 11, 2017 2:39 pm

CPU Information for a MacBook Pro (Retina, 15-inch, Mid 2015)

The sysctl command can be used on a Mac OS X/macOS system to determine some machine dependent (machdep) features, such as Central Processor Unit (CPU) features. E.g., the output of sysctl machdep.cpu run on a MacBook Pro (Retina, 15-inch, Mid 2015) system with an Intel Core i7 processor is shown below:

$ sysctl machdep.cpu
machdep.cpu.max_basic: 13
machdep.cpu.max_ext: 2147483656
machdep.cpu.vendor: GenuineIntel
machdep.cpu.brand_string: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
machdep.cpu.family: 6
machdep.cpu.model: 70
machdep.cpu.extmodel: 4
machdep.cpu.extfamily: 0
machdep.cpu.stepping: 1
machdep.cpu.feature_bits: 9221960262849657855
machdep.cpu.leaf7_feature_bits: 10155
machdep.cpu.extfeature_bits: 142473169152
machdep.cpu.signature: 263777
machdep.cpu.brand: 0
machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA C
MOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES6
4 MON DSCPL VMX SMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC MOVBE P
OPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C
machdep.cpu.leaf7_features: SMEP ERMS RDWRFSGS TSC_THREAD_OFFSET BMI1 AVX2 BMI2 
INVPCID FPU_CSDS
machdep.cpu.extfeatures: SYSCALL XD 1GBPAGE EM64T LAHF LZCNT RDTSCP TSCI
machdep.cpu.logical_per_package: 16
machdep.cpu.cores_per_package: 8
machdep.cpu.microcode_version: 19
machdep.cpu.processor_flag: 5
machdep.cpu.mwait.linesize_min: 64
machdep.cpu.mwait.linesize_max: 64
machdep.cpu.mwait.extensions: 3
machdep.cpu.mwait.sub_Cstates: 270624
machdep.cpu.thermal.sensor: 1
machdep.cpu.thermal.dynamic_acceleration: 1
machdep.cpu.thermal.invariant_APIC_timer: 1
machdep.cpu.thermal.thresholds: 2
machdep.cpu.thermal.ACNT_MCNT: 1
machdep.cpu.thermal.core_power_limits: 1
machdep.cpu.thermal.fine_grain_clock_mod: 1
machdep.cpu.thermal.package_thermal_intr: 1
machdep.cpu.thermal.hardware_feedback: 0
machdep.cpu.thermal.energy_policy: 1
machdep.cpu.xsave.extended_state: 7 832 832 0
machdep.cpu.xsave.extended_state1: 1 0 0 0
machdep.cpu.arch_perf.version: 3
machdep.cpu.arch_perf.number: 4
machdep.cpu.arch_perf.width: 48
machdep.cpu.arch_perf.events_number: 7
machdep.cpu.arch_perf.events: 0
machdep.cpu.arch_perf.fixed_number: 3
machdep.cpu.arch_perf.fixed_width: 48
machdep.cpu.cache.linesize: 64
machdep.cpu.cache.L2_associativity: 8
machdep.cpu.cache.size: 256
machdep.cpu.tlb.inst.large: 8
machdep.cpu.tlb.data.small: 64
machdep.cpu.tlb.data.small_level1: 64
machdep.cpu.tlb.shared: 1024
machdep.cpu.address_bits.physical: 39
machdep.cpu.address_bits.virtual: 48
machdep.cpu.core_count: 4
machdep.cpu.thread_count: 8
machdep.cpu.tsc_ccc.numerator: 0
machdep.cpu.tsc_ccc.denominator: 0
$

[ More Info ]

[/os/os-x] permanent link

Sat, Jun 10, 2017 8:18 pm

Automated email for Let's Encrypt certificate expiration

The Let's Encrypt certificate I use for an email server again wasn't automatically renewed - see Let's Encrypt certificate expired. The Let's Encrypt certificates exipre every 90 days, so I wanted the system to automatically email me a message at least a week before the certificate expires. I manually renewed the certificate today by running the command letsencrypt renew from the root account and checked the new expiration date with the command openssl x509 -enddate -noout -i cert_pem_file_location where cert_pem_file_location is the location of the relevant cert.pem file.

# openssl x509 -enddate -noout -in /etc/letsencrypt/live/moonpoint.com/cert.pem
notAfter=Sep  8 19:14:00 2017 GMT
#

Since the new certificate expiration date is September 8, 2017, I wanted an email notice sent to me on September 1. I can then manually renew the certificate, if needed. I would then want to be notified every 3 months again indefinitely. Since the mailx utility is a standard email program found on Linux and OS X/macOS systems, I use it for sending scheduled email messages.

[ More Info ]

[/network/email] permanent link

Fri, Jun 09, 2017 11:01 pm

Obtaining public IP address from a command line interface

One way to determine the public IP address for a system, i.e., the IP address that systems on the Internet will see for the system when you connect to those external systems, from a command-line interface (CLI) on a Linux or Mac OS X/macOS system is to use the dig command dig +short myip.opendns.com @resolver1.opendns.com. E.g.:

$ dig +short myip.opendns.com @resolver1.opendns.com
137.103.94.167
$

Alternatively, you can use an nslookup command as shown below:

$ nslookup myip.opendns.com resolver1.opendns.com
Server:		resolver1.opendns.com
Address:	208.67.222.222#53

Non-authoritative answer:
Name:	myip.opendns.com
Address: 137.103.94.167

$

The nslookup method will work on Microsoft Windows systems as well as OS X/macOS and Linux sysems.

c:\Users\Public\>nslookup myip.opendns.com resolver1.opendns.com
Server:  resolver1.opendns.com
Address:  208.67.222.222

Non-authoritative answer:
Name:    myip.opendns.com
Address:  137.103.94.167


c:\Users\Public\>

Both commands submit a Domain Name System (DNS) query to the DNS server resolver1.opendns.com, a name server maintained by OpenDNS. When you look up the fully qualified domain name (FQDN) myip.opendns.com, the OpenDNS server will return the IP address of the system from which the DNS query originated, i.e., the system on which you ran the dig or nslookup command.

[/network/dns] permanent link

Tue, Jun 06, 2017 9:22 pm

Removing whitespace from lines in Vi

To remove whitespace characters, such as spaces and/or tabs from a line while editing a file in the vi and Vim text editor you can use a regular expression (regexp) that incorporates \s (lowercase letter "s"), which respresents a white space character. E.g., supposing the lines below appear in a file:

450 SN/GN Tech  Edit Delete
ACE     Edit Delete
ADO             Edit Delete
AGO     Edit Delete
AGS     Edit Delete
AIM     Edit Delete
ASF         Edit Delete

I could hit the colon key and type s/\s*Edit Delete// to delete the white space after the project name that appears at the beginning of the line and the "Edit Delete" at the end of the line, so that only the project name remains. To perform the substitution for all lines, I could use 1,$ s/\s*Edit Delete//.

The 1,$ represents every line from the 1st to the last and 1,$ s/old_pattern/new_pattern/ would indicate that a substitution is to be performed on every line with new_pattern replacing old_pattern on each line. The \s represents any whitespace character and the asterisk after it indicates to look for zero or more occurrences of any whitespace character. So s/\s*Edit Delete// indicates to delete white space characters followed by the words Edit Delete.

I could also use \W, instead; \W represents any non-alphanumeric character.

Related articles:

  1. gVim Portable for Windows

Reference:

  1. Lesson 9: All this whitespace
    RegexOne - Learn Regular Expressions with simple, interactive exercises.

[/software/editors/vi] permanent link

Sun, Jun 04, 2017 11:21 pm

ISURL

If you wish to know whether a cell holds a Uniform Resource Locator (URL), such as http://example.com, in Google Sheets you can use the ISURL function. E.g., if I wanted to know whether cell A5 contains a URL, elsewhere in the spreadsheet I could use the formula =ISURL(A5). The value returned will be either TRUE or FALSE. Note: this will return the Boolean value TRUE or FALSE only if the text in the cell is a URL. If, instead, I have =hyperlink("http://superuser.com","Super User"), i.e., I have text in the cell that is hyperlinked, the value will be FALSE, because, in the example, the text that appears in the cell will be Super User.

This function is not available in Microsoft Excel, at least as of Excel 2013 for Windows and Microsoft Excel for Mac 2016 (version 15.29), which is part of Microsoft Office 2016 for OS X and macOS systems. Nor is it available for Apache OpenOffice Calc, at least as of version 4.1.1. If you try using ISURL as a formula in those applications, you will see #NAME? appear in the cell where you place the formula, since its usage is an incompatibility between those versions and Google Sheets.

The ISURL formula will return TRUE for other URLs besides HTTP or HTTPS ones. E.g., FTP and mailto URLs will also result in a value of TRUE. E.g., if a cell contains any of the following URLs, an ISURL formula that checks the content of the cell will return TRUE.

http://example.com
https://www.example.com
ftp://ftp.microsoft.com
mailto:someone@example.com

[/software/office/excel] permanent link

Fri, Jun 02, 2017 10:44 pm

Using nslookup to check an email blocklist

I was notified by someone today that yesterday he had sent an email to a mailing list on an email server I maintain, but the email had not been delivered to recipients. When I checked yesterday's email log, I didn't see any email from his email address, so I asked him to resend the message. He did so, but that email message was also not delivered and I didn't see any log entry for his email address in today's email log, /var/log/maillog. He has a verzion.net email address and Verizon recently transitioned its email service to AOL. I remembered helping him make that transition last month, so I looked for any aol.com entries in the log file and found the entry below for an attempt by an AOL email server to deliver a message that was rejected at the time he told me he had sent the email today.

# grep aol /var/log/maillog
Jun  2 10:50:16 moonpoint sendmail[23955]: ruleset=check_relay, arg1=omr-a006e.m
x.aol.com, arg2=127.0.0.6, relay=omr-a006e.mx.aol.com [204.29.186.55], reject=55
0 5.7.1 Spam Block:mail from 204.29.186.55 refused - see http://dnsbl.sorbs.net/

[ More Info ]

[/network/email/spam/sorbs] permanent link

Once You Know, You Newegg AliExpress by Alibaba.com

Shop Amazon Local - Subscribe to Deals in Your Neighborhood

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo