Force touch #Javascript #3DTouch

Force touch is a feature of iPhone 6S and above, and Android N devices (Huawei 7P) – it’s by no means widely supported, but if you fancy doing something special for your high-end users, then it’s an option to use for a “hidden feature” or shortcut. – A Peek to view master-detail anyone?
In Javascript it’s easily implemented; touchforcechange event, and ensure that “force” is set to 1 (maximum). If you don’t check the “force” value, then this will react to gentle clicks too – confusing the interface with the”click” event.
var element = document.getElementById(‘forceMe’);
function addForceTouchToElement(elem) {elem.addEventListener(‘webkitmouseforcechanged’, onClickForceChange, false);
elem.addEventListener(‘touchforcechange‘, onTouchForceChange, false);
}function onClickForceChange(e) {
alert(“onClickForceChange”);
}function onTouchForceChange(e) {
if (e.changedTouches[0].force == 1)
{
alert(“onTouchForceChange”);
}
}
addForceTouchToElement(element);
HTTP #Proxy #API by country

Looking to make your HTTP request appear to come from a particular country?, we’ve got an API for that…
There’s no business model behind this yet, so it’s all free. But the proxies listed are checked daily, and must exceed 50% reliability and under 3 seconds latency before they are listed. – There’s an API, so you can request by country.
Here’s some sample data of US proxies:
| Address | Reliability (%) | Last Checked |
|---|---|---|
| Address | Reliability (%) | Last Checked |
| http://104.199.146.27:3128 | 100 | 2/16/2017 2:05:27 AM |
| http://107.178.4.214:8181 | 80 | 2/16/2017 2:04:44 AM |
| http://138.197.21.105:8080 | 100 | 2/16/2017 2:05:04 AM |
| http://173.192.21.89:8123 | 100 | 2/16/2017 2:02:02 AM |
| http://205.234.15.12:80 | 60 | 2/15/2017 8:50:45 AM |
| http://35.162.243.238:8083 | 100 | 2/16/2017 2:05:38 AM |
| http://35.185.23.131:80 | 100 | 2/16/2017 2:04:32 AM |
| http://35.185.57.41:80 | 100 | 2/16/2017 2:05:43 AM |
| http://40.138.64.36:8080 | 60 | 2/15/2017 8:52:21 AM |
| http://47.52.2.135:8080 | 100 | 2/16/2017 2:02:58 AM |
Call an #ASMX #webservice with #Android

This may not be the best way to call a Microsoft .NET ASMX webservice via Java for Android, but it seems to work OK for my needs. All you need to do, is call it asynchronously, and handle the data returned.
Here’s my class that I’m using to call the ASMX webservice;
package uk.org.regcheck.regcheck;
import android.os.AsyncTask;
import android.util.Log;
import org.json.JSONObject;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
public class RegCheckAPI extends AsyncTask<String, String, String> {
DataDownloadListener dataDownloadListener;
public static interface DataDownloadListener {
void dataDownloadedSuccessfully(String data);
void dataDownloadFailed();
}
public void CheckUK(String RegistrationNumber,String username)
{
try {
this.execute("https://www.regcheck.org.uk/api/reg.asmx/Check?" +
"&RegistrationNumber=" + URLEncoder.encode(RegistrationNumber, "utf-8") +
"&username=" + URLEncoder.encode(username, "utf-8"));
Log.i(RegistrationNumber, username);
}
catch(UnsupportedEncodingException ex){
Log.i("error",ex.getMessage());
}
}
@Override
protected String doInBackground(String... uri) {
String responseString = "";
try {
URL url = new URL(uri[0]);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
responseString = new String(readFully(in), "utf-8");
}
catch(IOException ex)
{
responseString = ex.toString();
}
return responseString;
}
private byte[] readFully(InputStream inputStream)
throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length = 0;
while ((length = inputStream.read(buffer)) != -1) {
baos.write(buffer, 0, length);
}
return baos.toByteArray();
}
@Override
protected void onPostExecute(String result) {
if(result != null)
{
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new InputSource(new StringReader(result)));
NodeList nJson = doc.getElementsByTagName("vehicleJson");
String strJson = nJson.item(0).getTextContent();
JSONObject jObject = new JSONObject(strJson);
String strDescription = jObject.getString("Description");
dataDownloadListener.dataDownloadedSuccessfully(strDescription);
}
catch(Exception ex)
{
dataDownloadListener.dataDownloadFailed();
}
}
else
dataDownloadListener.dataDownloadFailed();
}
}
Then my main activity is as follows;
package uk.org.regcheck.regcheck;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);TextView t = (TextView)findViewById(R.id.tbOutput);
t.setText(“Please wait…”);RegCheckAPI api = new RegCheckAPI();
api.dataDownloadListener = (new RegCheckAPI.DataDownloadListener()
{
@SuppressWarnings(“unchecked”)
@Override
public void dataDownloadedSuccessfully(String data) {
TextView t = (TextView)findViewById(R.id.tbOutput);
t.setText(data);
}
@Override
public void dataDownloadFailed() {
// handler failure (e.g network not available etc.)
TextView t = (TextView)findViewById(R.id.tbOutput);
t.setText(“Failed”);
}
});
api.CheckUK(“{{valid UK plate}}”,”{{Your username here}}”);
}
}
A simple app to learn #HTML and #CSS on your iPhone

Just starting to learn HTML and CSS? want an environment you can take with you in your pocket?
We’ve just re-launched our HTMl & CSS iOS app, with a fresh new interface; which you can download from here;
https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=464094473&mt=8
Domain Deflect #app just launched #IOS

Domain deflect is a new app available for iOS, which allows you use a custom domain name on an existing website that you do not host – for example, it’s a free website provider, and they want you to pay to connect your own domain instead of using their freely allocated subdomain.
There are other applications too, like if you just don’t have full access to the webserver that is hosting your website – like many shared hosting environments may limit the number of domains you use, or want to charge extra for this.
Or simply, you don’t have the will or desire to figure out how to configure your Linux server via some archaic command line interface, but your website is running on the wrong domain name.
It’s SEO friendly, and this isn’t a 301 redirect, or cloak, it’s more akin to the CDN type systems employed by Amazon Cloudfront, although not geo-redundant.
If you think this would be useful – please download the app here: https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=521448034&mt=8
Use your computer’s spare time to help #cure #diseases. @rosettaathome

If you leave your office PC on all night, whether to tun nightly tests, or long tasks, then there is something more useful you can do with your computer’s time, that can really give back to society.
By installing Rosetta@home (boinc.bakerlab.org) – your computer can be used to run virtual experiments on proteins that could one day lead to a cure to a disease.
It doesn’t lock up your computer, your computer is still usable, and you can pause it whenever you want. It just means that your PC can do something truly useful during the night, when it would normally just be consuming electricity.
But what is the experiment?, I’m not a biologist, so I can just say in layman’s terms. – Our bodies have DNA in every cell. DNA is nature’s way of encoding millions of different types of Proteins. These are chemicals that do everything the body needs, literally.
Proteins are encoded in blocks called “Amino acids”, which are chained together, then curl up into complex 3D shapes. It is the shape of these chemicals that define the function of the Protein, and thus, what it does, and more importantly, if it can be modified to do something else – perhaps preventing a virus entering a cell, or recognising a cancer.
These complex shapes are often not experimentally view-able in the real world, if the protein cannot be made in enough quantity to be seen under under NMR or X-Rays – so it’s up to computers to take these long chains of amino acids, and fold them virtually, to a point where the shape is stable, and of least energy. It’s like having a thousand elastic bands tied together, and seeing what shape it would fall into when it fell.
So, It’s great work, and if your computer needs to be left on, then this is a great way to use it’s spare capacity for the betterment of society. Of course, if it doesn’t need to be left on, then turn it off, and stop contributing to global warming ! 🙂
Create your own #AudioBooks with C#

Say you’ve got a book in text format; for example a book from Gutenberg.org, and you’d like to convert it to mp3, so you can listen to the book – read by a machine, of course.
Here’s the code in C#
WebClient wc = new WebClient();
var strUrl = “{{Wherever your ebook text is}}”;
var strText = wc.DownloadString(strUrl);
var strPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
using (SpeechSynthesizer reader = new SpeechSynthesizer())
{
reader.Volume = 100;
reader.Rate = 0; //medium
MemoryStream ms = new MemoryStream();
reader.SetOutputToWaveStream(ms);//do speaking
reader.Speak(strText);
ConvertWavStreamToMp3File(ref ms, strPath + @”\54135.mp3″);
}
You need to install the Nuget package: Install-Package NAudio.Lame for the mp3 functionality. ConvertWavStreamToMp3File is defined as:
public static void ConvertWavStreamToMp3File(ref MemoryStream ms, string savetofilename)
{
//rewind to beginning of stream
ms.Seek(0, SeekOrigin.Begin);using (var retMs = new MemoryStream())
using (var rdr = new WaveFileReader(ms))
using (var wtr = new LameMP3FileWriter(savetofilename, rdr.WaveFormat, LAMEPreset.VBR_90))
{
rdr.CopyTo(wtr);
}
}
To give an idea of filesizes, I used an input file of 33,790 words, which resulted in a WAV file on 705MB, and Mp3 file of 63 MB.
Which you can hear here:
https://app.box.com/s/vb5jsaria7sd9iaxdrbguz58ufqwo0co
Of course, if you prefer to read a Gutenberg book onscreen, then you can use our app:
https://itunes.apple.com/us/app/book-searcher/id464083711?mt=8
This can further be converted to a FLV using FFMPEG ;
ffmpeg -i audio-book.jpg -i 54135.mp3 final.flv
Which takes about 2 minutes, an generates a 73 MB FLV file.
#Webcam on your #Wrist- monitor your house at a glance.

App Download link:
https://itunes.apple.com/us/app/mobile-webcam/id652758590?mt=8
Got a webcam or IP cam at home, and you’d like to check up on your pets / kids or just to check that everything is OK? This new update to our Mobile Webcam App – gives you the ability to check out your webcam from your wrist.
It’s a first version, so the image stream is slow, but it’s a practical application of WatchOS, paired with an existing app.
A quick WatchOS tip; you can’t use the following code to download an image on a real device, even through it works on the simulator:
NSData * imageData = [[NSData alloc]
initWithContentsOfURL: [NSURL URLWithString: self.strUrl ]];
[self.imgOutput setImage:[UIImage imageWithData: imageData]];
Instead, you have to use asynchronous code as follows;
NSURL *url = [NSURL URLWithString:
@”http://upload.wikimedia.org/wikipedia/commons/7/7f/Williams_River-27527.jpg”%5D;
NSURLSessionDownloadTask *downloadPhotoTask = [[NSURLSession sharedSession]
downloadTaskWithURL:url completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
UIImage *downloadedImage = [UIImage imageWithData:
[NSData dataWithContentsOfURL:location]];
[self.imgOutput setImage:downloadedImage ];
}];
[downloadPhotoTask resume];
Hope this helps! 🙂
#Startcom #SSL certs no longer valid in Chrome 58 & Firefox

StartCom was a popular SSL cert issuer before the days of LetsEncrypt, as it was one of the few providers that offered SSL certs for free, and thus was very popular. However, after failing to play ball with Mozilla, and were using the obsolete Hashing cypher SHA-1.
This means, if you have an SSL cert issued by StartCom, then you better get a new cert quickly. I personally recommend LetsEncrypt, since it’s free, but others are available. – Otherwise Google Chrome, and Firefox will say your website is insecure.
Mozilla’s official word is:
Mozilla has discovered that a Certificate Authority (CA) called WoSign has had a number of technical and management failures. Most seriously, we discovered they were backdating SSL certificates in order to get around the deadline that CAs stop issuing SHA-1 SSL certificates by January 1, 2016. Additionally, Mozilla discovered that WoSign had acquired full ownership of another CA called StartCom and failed to disclose this, as required by Mozilla policy. The representatives of WoSign and StartCom denied and continued to deny both of these allegations until sufficient data was collected to demonstrate that both allegations were correct. The levels of deception demonstrated by representatives of the combined company have led to Mozilla’s decision to distrust future certificates chaining up to the currently-included WoSign and StartCom root certificates.
#Sentry #JS #Error reporting @getsentry

Ever had an idea, and thought, I wonder does this already exist. You do a quick search on Google, and you find someone has done it really well. That’s what I found with Sentry.io
I’ve always been plagued with clients or customers saying vague things like, “this form doesn’t work”, when the fact was, that they put a hyphen in the mobile phone input box – which seems normal to them, but you didn’t think of it. It’s those type of “non-reproducible” errors that cause most heartache, because you can’t see them, but the client can.
With two lines of code (yes, honestly, 2), Sentry.io can capture these errors and report them on a screen that even highlights the exact line of code where the error happened. Even better than the console window.
Looks a great bit of kit!