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 / 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);
}
@kakopappa
kakopappa / nostradamus.js
Last active December 15, 2017 05:29
nostradamus example
var request = require("request");
var forecast = require('nostradamus');
var stockQuotes = []; var nostroData = []; var predictions = [];
var alpha = 0.5; var beta = 0.4; var gamma = 0.6; var period = 5; var m = 2;
var url = "http://www.google.com/finance/getprices?i=900&p=5d&f=d,o,h,l,c,v&df=cpct&q=(ticker)";
url = url.replace('(ticker)', 'AAPL');
request({
@kakopappa
kakopappa / gist:e4b5fce3de4285eaaaa523a186a1c964
Created January 5, 2018 05:24
Scan coinmarketcap and find good coins to buy
// Scan coinmarketcap and find good coins to buy
const CoinMarketCap = require('coinmarketcap-api')
const client = new CoinMarketCap()
client.getTicker({limit: 1000}).then( pairs => {
let filteredResult = pairs.filter(function(key) {
return (key.available_supply < 1500000);
});