notes about the dev18 forwarding setup, kee-agent
Tag: temp_on
QNAP Mustang Card
- setup
- install proxmox with network driver
- was it phone as wi-fi card?
My todo.txt setup
Nice post about my todo.txt setup
Why I love Joplin
Blog about Joplin
- evernote import
Creating new zfs pool mixing previously used drives
# destroy ALL DATA on disk /dev/ada2 sysctl kern.geom.debugflags=0x10 dd if=/dev/zero of=/dev/ada2 bs=1m # now reboot!
Adding a form with autocalculated fields in squarespace
I had to build a form on a squarespace hosted site that has to auto-calculate a couple of fields and also do field validation and offer the option to email the whole calculation to a visitor chosen address. I won’t publish the complete script here, but it shold help get you going.
First of all you will have to build this in the HTML/CSS block, you won’t be able to use the squarespace offered form builder.
First you will need a few javascript functions
[cce_html]
function getField1() {
var theForm = document.forms[“myform”];
var field1Value = theForm.elements[“field1”];
return parseInt(field1Value.value);
}
[/cce_html]
What this function does is return the value of a field named “field1” in your “myform” form. parseFloat might be required if you are going to use floating point values.
[cce_html]
function calculateTotal() {
var outputfield1Value = getField1()*5;
var elem = document.getElementById(“outputfield1Id”);
elem.value = Math.round(outputfield1Value);
}
[/cce_html]
This function is called each time one of your form fields is modified. What it does is change the value of the read-only form field to field1*5. This is of course just an example. You can multiply this to as many form input and output fields you need. Please note that you cannot use “disabled” fields as those cannot be POSTed.
[cce_html]
function validateForm() {
x = document.forms[“myform”][“field1”].value;
if (x == null || x == “”) {
alert(“Please fill in the first field”);
return false;
}
var x = document.forms[“myform”][“emailaddress”].value;
var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
if (x == null || x== “” || !re.test(x)) {
alert(“Please enter a valid email address”);
return false;
}
[/cce_html]
A simple function to do field validation. This one simply checks that the fields were actually filled and that the email field is valid (check RFCs, this is not really the best version but it works for me). Please note that this validation will not stop an attacker or bot to fill bogous data in your fields (as they can POST anything without going trough this javascript)
[cce_html]
[/cce_html]
The first four div’s are there to make the form look like other Squarespace built forms. Your form will call the validation function and onchange the first field will trigger the update of the second. When working with the new “number” input field pay close attention to the step value. The default is 1 which means Chrome (Firefox ignores it I think) will not allow floating point values unless you set the step to be any (or say 0.1, if you require specific values).
I will leave the emailself.php script as an exercise to the reader. It’s really easy to screw it up though, so be sure to secure it – both the form, maybe with google a captcha and your php script that takes POSTed data and emails it as it’s really easy to miss something and open your self to becoming a SPAM sender.
Speed-up WAN-LAN speed on the Cisco E3200 using Tomato
There’s a really long discussion on bcm_nat and fastnat on the various forums like linksysinfo. The short version of this is:
- fastnat and bcm_nat are disabled by default because they break QOS and access restrictions. If you use any of those you’re done, you have to choose features or speed or another router.
- If you, like me, don’t use those you can do the following:
ssh into your router and try: [cci_bash]modprobe bcm_nat[/cci_bash] than speedtest your connection a few times you should see some improvement. Than run [cci_bash]echo “1”> /proc/sys/net/ipv4/netfilter/ip_conntrack_fastnat[/cci_bash] you shold see an even better improvement. If any of those give you issues simply reboot your router, nothing is permanent at this time. - Add the commands to Administration->Scripts->Init.
The instructions are deliberately scarce, if you don’t understand them it’s better not to mess with your router. Check the tomato forums and the linux documentation about those commands until you’re sure you know what they are doing.
Subdomains pointing to private IPs are not resolved on Tomato
Some time ago I used to remember IPs on my home and work network but these days I rely much more on dns and dhcp reservation for this tasks. This has the advantage that I can easy move a service, say git.example.com to a new server.
At home I switched (at least for a while) from a dedicated Debian router/gateway box to a router running Tomato. Suddenly subdomains pointing to private IP addresses were no longer resolved. Turns out the DNS rebinding protection is at fault. Now you could easily just disable it but this is not the secure way to fix a problem. You can actually white list domains to allow private IPs on subdomains.
Go to Advanced => DHCP / DNS Server (LAN)
Don’t uncheck “Prevent DNS-rebind attacks” as this will leave you vulnerable to this attack. Instead add the following to the Dnsmasq
Custom configuration
[cci_bash]rebind-domain-ok=/domain1.com/domain2.com/[/cci_bash]
Where domain1.com, domain2.com, etc. are the domains for which you want to allow subdomains that resolve to private IPs.
Missing 5Ghz WiFi settings on Cisco E3200 with Tomato Shibby
I followed the instructions and installed Tomat on my Cisco E3200 router without issue. I chose Tomato by Shibby specifically because it supports the 5GHz radio in this particular router model. But woe and behold after I installed the settings were not there, I could only see them for the 2.4GHz WiFi.
Well it turns out instructions are made to be followed, I got curious after install and logged right in, but it turns out you really have to do the last 30-30-30 reset.
Sure enough after the final 30-30-30 hard reset the settings for the 5GHz of my Cisco 3200 appeared and were functional.
Quickly disable email for one virtual host
If you discover that one site that you host is sending tons of emails there is an easy and quick way to disable email only for one particular virtual host. Add the following line in it’s virtual host or .httacess file
[cci_bash]php_admin_value sendmail_path “/dev/null”[/cci_bash]
If you add it to the virtual host be sure to reload apache.