Skip to content

Instantly share code, notes, and snippets.

* Reducing executable size:
http://developer.xamarin.com/guides/cross-platform/deployment,_testing,_and_metrics/memory_perf_best_practices/#Reducing_Executable_Size
* Use the linker (iOS [1], Android [2]) to remove unnecessary code from your assemblies
[1] https://developer.xamarin.com/guides/ios/advanced_topics/linker
[2] https://developer.xamarin.com/guides/android/advanced_topics/linking
* Reference third-party libraries judiciously
* Applying constraints to generics may reduce app size, since less code would need to be included (haven’t verified this)
@sunnyy02
sunnyy02 / WebhooksFilterProvider.cs
Created May 1, 2018 01:18
Create web hook event filter
public class WebhooksFilterProvider : IWebHookFilterProvider
{
private readonly Collection<WebHookFilter> filters = new Collection<WebHookFilter>
{
new WebHookFilter
{
Name = "NewInquiry",
Description = "new inquiry is raised."
},
new WebHookFilter
@sunnyy02
sunnyy02 / NotifyController.cs
Created May 1, 2018 01:49
MVC Controller for Webhook
public class NotifyController : Controller
{
[HttpPost]
public async Task<ActionResult> SubmitNewInquiry(string inquiryMessage)
{
await this.NotifyAsync("NewInquiry", new { Message = inquiryMessage });
return new EmptyResult();
}
}
@sunnyy02
sunnyy02 / WebhookHandler.cs
Created May 1, 2018 01:51
Webhook handler
public class WebHookHandler : Microsoft.AspNet.WebHooks.WebHookHandler
{
public override Task ExecuteAsync(string receiver, WebHookHandlerContext context)
{
return Task.FromResult(true);
}
}
//
// the following code is extraction from https://code.msdn.microsoft.com/How-to-use-SqlDependency-5c0da0b3/sourcecode?fileId=158219&pathId=775745477
//
public class ImmediateNotificationRegister<TEntity> : IDisposable where TEntity : class 
    { 
        private SqlConnection connection = null; 
        private SqlCommand command = null; 
        private IQueryable iquery = null; 
        private ObjectQuery oquery = null; 
#Create a workspace project
ng new demo-ng6-lib-app
#Generate a new Library
ng generate library demo-ng6lib --prefix=dnl
#Build the Library
ng build --prod demo-ng6lib
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let notificationTypes: UIUserNotificationType = [UIUserNotificationType.alert, UIUserNotificationType.badge, UIUserNotificationType.sound]
let pushNotificationSettings = UIUserNotificationSettings(types: notificationTypes, categories: nil)
application.registerUserNotificationSettings(pushNotificationSettings)
application.registerForRemoteNotifications()
return true
}
func application(_: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
var certificateFilePath = "C:\\dev\\PushNotificationDemo\\cert.p12";
var certificatePassword = ""; // We keep password empty
var config = new ApnsConfiguration (ApnsConfiguration.ApnsServerEnvironment.Sandbox,certificateFilePath, certificatePassword);
var broker = new ApnsServiceBroker (config);
broker.OnNotificationFailed += (notification, exception) => {
failed++;
};
broker.OnNotificationSucceeded += (notification) => {
succeeded++;
};
function onConnected(cardHandle, protocol)
{
//Load default encription key FF FF FF FF FF FF
APDU_SELECTKEY = [0xFF, 0x82, 0x20, 0x00, 0x06,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF];
api.SCardTransmit(
cardHandle,
protocol == API.SCARD_PROTOCOL_T0 ?
API.SCARD_PCI_T0 : API.SCARD_PCI_T1,
APDU_SELECTKEY).then(function(result) {
result.get(function (ioRecvPci, response) {
function onAuthenticated(protocol, response)
{
sw = response.slice(-2);
if (sw[0] == 0x90 && sw[1] == 0x00)
{
// Read block 1 (16 bytes)
APDU_READ = [0xFF, 0xB0, 0x00, 0x01, 0x10];
readData(APDU_READ);
}
}