Store Zipped data in #SqlLite BLOB with C#

SQLite370.svg_

SqlLite is great if you want to include pre-prepared data with your app or website, but if you find your .sqlite file becoming massive, you might look at how you are storing your data.

This approach is only relevant, if you have one or more fields that contain large blocks of text. It also comes in handy if you are storing base64 encoded binary data or text with UTF8 / UTF16 chars

First, use the BLOB data type, rather than TEXT for storing your big-data field.

Next, you’ll need these two C# functions to Compress and Decompress byte arrays in-memory:

static byte[] Compress(byte[] data)
{
using (var compressedStream = new MemoryStream())
using (var zipStream = new GZipStream(compressedStream, CompressionMode.Compress))
{
zipStream.Write(data, 0, data.Length);
zipStream.Close();
return compressedStream.ToArray();
}
}

static byte[] Decompress(byte[] data)
{
using (var compressedStream = new MemoryStream(data))
using (var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress))
using (var resultStream = new MemoryStream())
{
zipStream.CopyTo(resultStream);
return resultStream.ToArray();
}
}

Then, when inserting into the Sqlite file, then use the functions;

To Insert a row;

var bXml = System.Text.Encoding.UTF8.GetBytes(strXML);
var bCompress = Compress(bXml);
var command = new SQLiteCommand(connection)
{
CommandText = “insert into Table (ID,xml) values (” + ID + “,@xml)”
};
var parameter = new SQLiteParameter(“@xml”, System.Data.DbType.Binary) {Value = bCompress};
command.Parameters.Add(parameter);
command.ExecuteNonQuery();

Then to read the value back out again;

var connection = new SQLiteConnection(“Data Source=” + strDbFile);
connection.Open();
var strSql = “select xml from Table limit 1;”;
var command = new SQLiteCommand(strSql, connection);
var obj = command.ExecuteScalar();
var bArray = (byte[])obj;
var bXml = Decompress(bArray);
var strXML = System.Text.Encoding.UTF8.GetString(bXml);

Categories: Uncategorized

Database of 1.2 Million #iOS apps available for download.

IOS

Check out this download: https://payhip.com/b/7NIg

A database of over 1.2 million iOS apps listed on the Apple App store, including the following details;

  • url
  • name
  • developer Name
  • developer Url
  • price
  • is Free
  • thumbnail Url
  • compatibility
  • category
  • update Date
  • version
  • size
  • minimum Age
  • developer Website
  • support Website
  • license Agreement
  • description
Categories: Uncategorized

Install #IPA – An over-the-air IOS app installation service

install-ipa

InstallIPA.com – is a website that helps you install .IPA files on your iOS device by automatically creating the OTA Manifest file, and creating a email-installable link, or QR code.

It’s designed so that you can provide an easy-to-install link to demo your app to your client, without asking them to plug their iPhone into iTunes.

Or, from the tester’s perpective – If you’ve been sent an .ipa file from your developer, and want an easy way to install it on your phone, then you can use this site to easily install this app on your phone.

Categories: Uncategorized

#RoyalMail #PAF UK Postcode database

Categories: Uncategorized

50,000 Web Design Sales Leads for €5

Categories: Uncategorized

Google #OAuth Login using #PhantomJS

articleocw-5860f28ac5f1c

So here’s some handy code to use PhantomJS to perform a Google OAuth Login in a headless browser. The exact login url and username/password have been omitted from this example;

page.open(‘https://accounts.google.com/o/oauth2/auth?redirect_uri=http://……’, function (status) {

page.evaluate(function() {
var usernameField = “Email”;
var elUsername = document.getElementById(usernameField);
elUsername.value = ‘xxxx@gmail.com’;
var buttonId = “next”;
var elNext = document.getElementById(buttonId);
elNext.click();
setTimeout(function(){
var passwordId = “Passwd”;
var elPassword = document.getElementById(passwordId);
elPassword.value = “xxxxxxx”;
var btnNext = document.getElementById(“signIn”);
btnNext.click();
},2000);
});
page.onLoadFinished = function(){
page.evaluate(function(){
setTimeout(function(){
var btnAllow = “submit_approve_access”;
var elAllow = document.getElementById(btnAllow);
elAllow.click();

},2000);
});
page.onLoadFinished = function(){
// Now you can continue processing.
};
};
});

Categories: Uncategorized

Clean up expired #S3 files in #AWS using C#

s3

If you use Amazon S3 to store temporary files, that are perhaps autogenerated, then emailed to customers, or are otherwise obsolete after a few hours, then it’s a good idea to delete them – to keep your storage costs low, and prevent any leaks of sensitive data later down the line.

Here is some C# code that reads all files in a specified bucket, and deletes files older than 12 hours old. – This example is hard-coded to the EU West Region (Ireland).

First, you need to install the NUGET package:

Install-package AWSSDK.S3

Then, create a class called S3, with the following code – I’ve ommited the keys, that you can get from IAM

using Amazon.S3;
using Amazon.S3.Transfer;
using System;
using System.Collections.Generic;
using System.IO;
using Amazon.S3.Model;

namespace S3Cleanup
{
/// <summary>
/// Amazon S3 functionality
/// </summary>
public static class S3
{
private static readonly AmazonS3Config Cfg = new AmazonS3Config { RegionEndpoint = Amazon.RegionEndpoint.EUWest1 };
private static readonly AmazonS3Client S3Client = new AmazonS3Client(“xxxx”, “xxx”, Cfg);

public static IEnumerable<S3Object> ListBucket(string bucket)
{

var request = new ListObjectsRequest {BucketName = bucket};
var lS3 = new List<S3Object>();
do
{
var response = S3Client.ListObjects(request);
lS3.AddRange(response.S3Objects);
if (response.IsTruncated)
{
request.Marker = response.NextMarker;
}
else
{
request = null;
}
} while (request != null);
return lS3;
}

public static void DeleteObject(string bucket, S3Object s3Object)
{
var request = new DeleteObjectRequest { BucketName = bucket, Key = s3Object.Key };
S3Client.DeleteObject(request);
}

public static string Upload(string bucket, byte[] data, string extension)
{
var ms = new MemoryStream(data);
var filename = Guid.NewGuid().ToString(“D”) + extension;
var fileTransferUtility = new TransferUtility(S3Client);
var fileTransferUtilityRequest = new TransferUtilityUploadRequest
{
BucketName = bucket,
InputStream = ms,
StorageClass = S3StorageClass.ReducedRedundancy,
Key = filename,
CannedACL = S3CannedACL.PublicRead
};
fileTransferUtility.Upload(fileTransferUtilityRequest);
return “https://s3-eu-west-1.amazonaws.com/&#8221; + bucket + “/” + filename;
}
}
}

Then you can write come code in your Main() method to do the following:

if (args.Length == 0)
{
Console.WriteLine(“Pass bucket name as argument”);
return;
}
var strBucketName = args[0];
var s3Objects = S3.ListBucket(strBucketName);
Console.WriteLine(“Found ” + s3Objects.Count() + ” objects in bucket”);
foreach (var s3object in s3Objects)
{
var age = DateTime.Now – s3object.LastModified;
if (age.TotalHours <= 12) continue;
Console.WriteLine(“Deleting ” + s3object.Key);
S3.DeleteObject(strBucketName, s3object);
}

Then, if you set that up as a scheduled task, you can delete your old S3 files, and keep your costs down.

Categories: Uncategorized

Create a Real #IOS App with no coding in two minutes.

If you’ve got a mobile-friendly website, then you can also create an app for that website quickly and easily with CreateFreeApp.com – The video above shows just how simple it is to create a real iOS app that can run on your iPhone, you could share with your employees, or even submit to the iOS App store (* Although apple have strict quality guidelines, so you may not pass review)

The video above does gloss over the whole digital signing step – which is the toughest part of the process, and professional iOS developers struggle with this too. However, here are a few steps to create what’s known as an Ad-hoc provisioning profile used in the video above. This allows you to install the app on up to 100 iPhones / iPads without any review by Apple.

If you try to install an app that is not digitally signed, then you get an error message saying “Unable to download App, “CreateFreeApp.com” could not be downloaded at this time.”, and you get a darkened icon on the home screen called “CreateFreeApp”, that says “Unable to Install “CreateFreeApp.com” Please try again later.” if you click it.

You’ll need a developer account at apple, and I’m assuming you’ve got a Distribution certificate set up already – so go log in to developer.apple.com , and select “Certificates, IDs & profiles” – Click Devices > All Then press the plus icon in the top right

Now, on your iphone, go to “get.udid.io” in the Safari browser. Press “Tap to Find UDID”, Press “Allow” then “Install”, “Install”, and your UDID will be displayed on-screen.

Going back to the Apple, enter in the Name of the Device “Dave’s iPhone”, and fill in the UDID in the box below. Press “Continue”.

Now, go to App IDs under Indentifiers on the left hand side, and press the Plus icon in the top right.

Enter the App ID Decription “Create Free App”, and select a wildcard App ID named:

com.createfreeapp.*

Press Continue.

Select iOS provisioning profiles > All, then press the plus icon in the top right. Select Distribution > Ad Hoc then continue.

Select CreateFreeApp in the App ID box then continue.

Select your iOS Distribution Certifcate (Hoping you’ve already set this up!) then continue

Press Select All for the devices list, then press Continue

Enter a name for the profile, i.e. “Create Free App AdHoc” > Continue, then Download the mobileprovision file, and put it in a safe place, as you’ll need it later.

To create your p12 certificate, you will need to open the KeyChain Access utility on your Mac

Select “My Certificates” on the left hand side, and look down to find your “iPhone Distribution” certificate. Control-Click on the certificate, and select Export. Press Save, Enter a password, and again into the verify box, then press OK. You will need this password later, so don’t forget it!. Press “Allow”, and you should have a file on your desktop named Certificates.p12.

When creating an app on Create Free App.com, you will need your mobileprovision file, the p12 certificate, and the password for the certificate, and the app will work on every device that you have obtained a UDID for.

 

 

 

 

 

 

 

 

Categories: Uncategorized

Create an #Android and #iOS app for #free with no coding

Categories: Uncategorized

Own Domain #email backed by #GMail without paying for #GSuite

own-domain

Many domain registrars offer the option for email forwarding on your domain for free, so you can set email sent to info@yourdomain.com to go to you@gmail.com – however, when you reply to an email, the sender is you@gmail.com, not info@yourdomain.com, so the illusion is lost. – But there is a trick.

So, First off, you set up your email forwarding at your registrar, or if your registrar can’t do this, then you can also use the forwarding option at http://www.domaindeflect.com/

Now, you need to set up a SMTP server that will handle outbound email from your domain, I recommend Elastic Email to set this up:

https://elasticemail.com/account#/create-account?r=20b444a2-b3af-4eb8-bae7-911f6097521c

Once you have set up a SMTP server to handle your outbound email, then you go into Gmail, click Settings > Accounts and Import > Add another Email Address

Enter in your name, email address (info@yourdomain.com), enter in your SMTP server, SMTP username and password from Elastic Email, and then press next step. An email will be sent to info@yourdomain.com from the “Gmail Team”, to verify the process. Click on this link.

You should also select the option to “Reply from the same address the message was sent to”, so that by default, the email address is maintained.

 

 

Categories: Uncategorized