Skip to content

Instantly share code, notes, and snippets.

@nkundu
nkundu / gist:c468249f21c8931bc4cb
Created July 18, 2014 15:00
Data URI for spinner
.spinner {
display: inline-block;
width: 30px;
height: 30px;
background-size: 100%;
background-repeat: no-repeat;
background-image:url(data:image/gif;base64,R0lGODlhgACAAKIAAP///93d3bu7u5mZmQAA/wAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFBQAEACwCAAIAfAB8AAAD/0i63P4wygYqmDjrzbtflvWNZGliYXiubKuloivPLlzReD7al+7/Eh5wSFQIi8hHYBkwHUmD6CD5YTJLz49USuVYraRsZ7vtar7XnQ1Kjpoz6LRHvGlz35O4nEPP2O94EnpNc2sef1OBGIOFMId/inB6jSmPdpGScR19EoiYmZobnBCIiZ95k6KGGp6ni4wvqxilrqBfqo6skLW2YBmjDa28r6Eosp27w8Rov8ekycqoqUHODrTRvXsQwArC2NLF29UM19/LtxO5yJd4Au4CK7DUNxPebG4e7+8n8iv2WmQ66BtoYpo/dvfacBjIkITBE9DGlMvAsOIIZjIUAixliv9ixYZVtLUos5GjwI8gzc3iCGghypQqrbFsme8lwZgLZtIcYfNmTJ34WPTUZw5oRxdD9w0z6iOpO15MgTh1BTTJUKos39jE+o/KS64IFVmsFfYT0aU7capdy7at27dw48qdS7eu3bt480I02vUbX2F/JxYNDImw4GiGE/P9qbhxVpWOI/eFKtlNZbWXuzlmG1mv58+gQ4seTbq06dOoU6vGQZJy0FNlMcV+czhQ7SQmYd8eMhPs5BxVdfcGEtV3buDBXQ+fURxx8oM6MT9P+Fh6dOrH2zavc13u9JXVJb520Vp8dvC76wXMuN5Sepm/1WtkEZHDefnzR9Qvsd9+/wi8+en3X0ntYVcSdAE+UN4zs7ln24CaLagghIxBaGF8kFGoIYV+Ybghh841GIyI5ICIFoklJsigihmimJOLEbL
@nkundu
nkundu / userapp-omxplayer-IZD38X.desktop
Created December 5, 2015 01:31
Raspbian LXDE PCManFM application configuration for omxplayer with keyboard shortcuts
[Desktop Entry]
Type=Application
Name=omxplayer
Exec=lxterminal --command "omxplayer -o hdmi %f"
Categories=Other;
NoDisplay=true
MimeType=video/mp4
Terminal=false
@nkundu
nkundu / program.cs
Created December 5, 2015 01:37
Sample for using Sqlite3 on Raspbian with Mono
// apt-get install scite mono-complete sqlite3
// mcs program.cs -r:System.Data -r:Mono.Data.Sqlite
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
// use with spinner CSS
var showBusyModal = function () {
$.blockUI({
message: '<div class="spinner"></div><br />Please wait...',
css: {
border: 'none',
padding: '15px',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
@nkundu
nkundu / SplitFlatFile.cs
Last active July 24, 2017 18:44
Split a flat file maintaining header
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SplitFlatFile {
class Program {
static void Main(string[] args) {
@nkundu
nkundu / utility.cs
Created May 4, 2017 13:20
Convert a unix time stamp to C# DateTime
public static DateTime UnixTimeStampToDateTime(int unixTimeStamp)
{
// Unix timestamp is seconds past epoch
System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime();
return dtDateTime;
}
@nkundu
nkundu / REST.cs
Created May 4, 2017 13:22
Backend code for calling JSON REST API
protected static bool MakeRequest(string uri, string method, out string message, string body = "", string accept = "application/json")
{
bool success = false;
message = "";
var body_data = Encoding.ASCII.GetBytes(body);
string req = uri;
var webRequest = (HttpWebRequest)WebRequest.Create(req);
webRequest.Method = method;
@nkundu
nkundu / Example.cs
Created May 4, 2017 13:25
Perform a shallow clone of a Dictionary
public Dictionary<string, string> properties;
properties = c.Properties.ToDictionary(entry => entry.Key, entry => entry.Value); // shallow clone
@nkundu
nkundu / ActivityLog.cs
Created May 4, 2017 13:27
Use C# Caller Member Name as a Logger
/*
CREATE PROCEDURE [dbo].[ADD_ACTIVITY_LOG]
-- Add the parameters for the stored procedure here
@activityDate datetime,
@activityDesc nvarchar(100),
@activityDetail nvarchar(MAX)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
@nkundu
nkundu / XML.cs
Created May 4, 2017 13:32
XML Document to string
public static string XmlToString(XmlDocument xmlDoc)
{
using (var stringWriter = new StringWriter())
{
using (var xmlTextWriter = XmlWriter.Create(stringWriter))
{
xmlDoc.WriteTo(xmlTextWriter);
xmlTextWriter.Flush();
return stringWriter.GetStringBuilder().ToString();
}