Skip to content

Instantly share code, notes, and snippets.

View kakopappa's full-sized avatar
🏠
Working from home

Aruna Tennakoon kakopappa

🏠
Working from home
View GitHub Profile
@kakopappa
kakopappa / AppsUtil.cs
Created August 6, 2015 05:01
Get list of install programs with icons in Windows
class AppsUtil
{
public static List<InstalledApp> GetInstalledApps()
{
List<InstalledApp> map = new List<InstalledApp>();
string InstallerKey = @"Installer\Products";
using (RegistryKey installkeys = Registry.ClassesRoot.OpenSubKey(InstallerKey))
{
foreach (string name in installkeys.GetSubKeyNames())
@kakopappa
kakopappa / swift
Created August 9, 2015 10:13
Show UIActivityIndicatorView inside UIImageView
//
// UIImageViewExtention.swift
// MealSpecials
//
// Created by Aruna on 8/9/15.
// Copyright (c) 2015 com.mealspecials. All rights reserved.
//
import Foundation
import UIKit
@kakopappa
kakopappa / WindowUtil.cs
Created March 4, 2016 06:26
How to get the parent window title using child window handle
[DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
static extern IntPtr GetParent(IntPtr hWnd);
[DllImport("user32", CharSet = CharSet.Auto, SetLastError = true)]
static extern int GetWindowText(IntPtr hWnd, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpString, int nMaxCount);
public static String GetWindowTitle(IntPtr handle) {
IntPtr windowParent = IntPtr.Zero;
while (handle != IntPtr.Zero) {
@kakopappa
kakopappa / CachedImage.cs
Last active May 19, 2016 09:15
File based image caching for .NET WPF
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace CachedImage
public static final String allChar = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
public static final String letterChar = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
public static final String numberChar = "0123456789";
public static String generateString(int length)
{
StringBuffer sb = new StringBuffer();
SecureRandom random = new SecureRandom();
for (int i = 0; i < length; i++)
@kakopappa
kakopappa / letsencrypt.sh
Created January 24, 2017 14:52
How to setup Let's Encrypt for Nginx on Ubuntu 14.04
git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
sudo ./letsencrypt-auto --nginx
// OTA Update using ESPhttpUpdate
/* ESPhttpUpdate.update("192.168.0.2", 80, "/arduino.bin");
t_httpUpdate_return ret = ESPhttpUpdate.update("192.168.0.2", 80, "/esp/update/arduino", "optional current version string here");
switch(ret) {
case HTTP_UPDATE_FAILED:
Serial.println("[update] Update failed.");
break;
case HTTP_UPDATE_NO_UPDATES:
Serial.println("[update] Update no Update.");
break;
String to uint8_t pointer
(uint8_t *)content.c_str()
char buf[chunkSize];
file.read((uint8_t *)buf, chunkSize-1);
String(buf);
//How to to append a char array in arduino
char* p = (char*)malloc(sizeof(char)*12);
strcpy(p,"hello world");
cout << p << "\r\n";
p = (char*)realloc(p, sizeof(char)*24);
strcat(p," from Nish");
cout << p << "\r\n";
free(p);
@kakopappa
kakopappa / AsyncTelnetServer.ino
Created May 29, 2017 00:20 — forked from me-no-dev/AsyncTelnetServer.ino
Single Client Telnet Server example
extern "C" {
enum sleep_type {
NONE_SLEEP_T = 0,
LIGHT_SLEEP_T,
MODEM_SLEEP_T
};
bool wifi_set_sleep_type(enum sleep_type type);
void system_set_os_print(uint8 onoff);
void ets_install_putc1(void* routine);
}