Skip to content

Instantly share code, notes, and snippets.

@ccpu
ccpu / C#
Created June 30, 2017 08:28 — forked from conrjac/C#
C# Encrypt and Decrypt File - using http://support.microsoft.com/kb/307010
using System;
using System.IO;
using System.Security;
using System.Security.Cryptography;
using System.Runtime.InteropServices;
using System.Text;
namespace CSEncryptDecrypt
{
class Class1
@ccpu
ccpu / CredentialManager.cs
Created June 8, 2017 18:50 — forked from meziantou/CredentialManager.cs
Using the Windows Credential API (CredRead, CredWrite, CredDelete, CredEnumerate)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.Win32.SafeHandles;
public static class CredentialManager
{
public static Credential ReadCredential(string applicationName)
@ccpu
ccpu / example.js
Created March 10, 2017 13:33 — forked from Gozala/example.js
Workaround for lack of "tail call optimization" in JS
// Lack of tail call optimization in JS
var sum = function(x, y) {
return y > 0 ? sum(x + 1, y - 1) :
y < 0 ? sum(x - 1, y + 1) :
x
}
sum(20, 100000) // => RangeError: Maximum call stack size exceeded
// Using workaround
@ccpu
ccpu / .gitignore
Created February 6, 2017 14:58 — forked from abernier/.gitignore
domvertices.js
node_modules/
@ccpu
ccpu / convertPointFromPageToNode.js
Created February 6, 2017 10:56 — forked from Yaffle/convertPointFromPageToNode.js
function to get the MouseEvent coordinates for an element that has CSS3 Transforms
/*jslint plusplus: true, vars: true, indent: 2 */
/*
convertPointFromPageToNode(element, event.pageX, event.pageY) -> {x, y}
returns coordinate in element's local coordinate system (works properly with css transforms without perspective projection)
convertPointFromNodeToPage(element, offsetX, offsetY) -> {x, y}
returns coordinate in window's coordinate system (works properly with css transforms without perspective projection)
*/