How do I check whether a value in a string is an IP address

Ruby has already the needed Regex in the standard library. Checkout resolv. require “resolv” “192.168.1.1” =~ Resolv::IPv4::Regex ? true : false #=> true “192.168.1.500” =~ Resolv::IPv4::Regex ? true : false #=> false “ff02::1” =~ Resolv::IPv6::Regex ? true : false #=> true “ff02::1::1” =~ Resolv::IPv6::Regex ? true : false #=> false If you like it the … Read more

How to store a 128 bit number in a single column in MySQL?

I found myself asking this question and from all the posts I read never found any performance comparisons. So here’s my attempt. I’ve created the following tables, populated with 2,000,000 random ip address from 100 random networks. CREATE TABLE ipv6_address_binary ( id SERIAL NOT NULL AUTO_INCREMENT PRIMARY KEY, addr BINARY(16) NOT NULL UNIQUE ); CREATE … Read more

Configure git to use IPv4 instead of IPv6 by default

The more generic solution (that also works for BSD) is to edit the global /etc/ssh/ssh_config or per-user ~/.ssh/config and add/replace the entry: AddressFamily any with the following line (where inet corresponds to ipv4): AddressFamily inet You can also set this for just a single host: Host example.com AddressFamily inet

Getting `Can’t assign requested address` java.net.SocketException using Ehcache multicast

This was caused by an IPv6 address being returned from java.net.NetworkInterface.getDefault(). I’m on a Macbook and was using wireless — p2p0 (used for AirDrop) was returned as the default network interface but my p2p0 only has an IPv6 ether entry (found by running ipconfig). Two solutions, both of which worked for me (I prefer the … Read more

How can I disable IPv6 stack use for IPv4 IPs on JRE?

I wanted to use this for some program I hadn’t control for running that Java app so ended with this _JAVA_OPTIONS=-Djava.net.preferIPv4Stack=true environment variable. (read about _JAVA_OPTIONS here) If you are using Windows, just run this command on Windows cmd: setx _JAVA_OPTIONS -Djava.net.preferIPv4Stack=true Thanks to Jason Nichols for reminding this JVM argument 🙂

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)