Skip to content

Instantly share code, notes, and snippets.

View ccpu's full-sized avatar

cyrus ccpu

  • Planet Earth, Milky Way
View GitHub Profile
@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)
*/
@ccpu
ccpu / .gitignore
Created February 6, 2017 14:58 — forked from abernier/.gitignore
domvertices.js
node_modules/
@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 / 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 / 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 / encryptfiles.cs
Created June 30, 2017 08:29 — forked from PartTimeLegend/encryptfiles.cs
Encrypt Files C#
public void EncrpytFiles(IList<Documents> documentsList)
{
foreach (var document in documentsList)
{
TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
tdes.Padding = (PaddingMode.ISO10126);
tdes.Mode = CipherMode.CBC;
tdes.GenerateIV();
tdes.GenerateKey();
tdes.CreateEncryptor();
@ccpu
ccpu / TrigStuff.cs
Created July 30, 2017 15:09 — forked from musicm122/TrigStuff.cs
C# Trig Functions
//Some old math stuff I wrote when in Trig class
using System;
using System.IO;
public class Geometry
{
//-----Area of a circle A= pi^2--------------------------------------------
public static double Area_Circle(double radius)
{
double area = 2*(Math.PI*(radius*radius));
@ccpu
ccpu / IQueryableExtensions
Created November 14, 2017 20:34 — forked from rionmonster/IQueryableExtensions
Resolve the SQL being executed behind the scenes in Entity Framework Core
public static class IQueryableExtensions
{
private static readonly TypeInfo QueryCompilerTypeInfo = typeof(QueryCompiler).GetTypeInfo();
private static readonly FieldInfo QueryCompilerField = typeof(EntityQueryProvider).GetTypeInfo().DeclaredFields.First(x => x.Name == "_queryCompiler");
private static readonly PropertyInfo NodeTypeProviderField = QueryCompilerTypeInfo.DeclaredProperties.Single(x => x.Name == "NodeTypeProvider");
private static readonly MethodInfo CreateQueryParserMethod = QueryCompilerTypeInfo.DeclaredMethods.First(x => x.Name == "CreateQueryParser");
/* jQuery ui-datepicker extension */
/**
*
* https://gist.github.com/Artemeey/8bacd37964a8069a2eeee8c9b0bd2e44/
*
* Version: 1.0 (15.06.2016)
* Requires: jQuery v1.8+
* Requires: jQuery-UI v1.10+
*
@ccpu
ccpu / Sortable.jsx
Created January 10, 2018 19:07 — forked from superKalo/ Sortable.jsx
How to use jQuery UI with React JS? You can use this approach to integrate almost any jQuery plugin! Full details and explanation here: http://stackoverflow.com/a/40350880/1333836
class Sortable extends React.Component {
componentDidMount() {
// Every React component has a function that exposes the
// underlying DOM node that it is wrapping. We can use that
// DOM node, pass it to jQuery and initialize the plugin.
// You'll find that many jQuery plugins follow this same pattern
// and you'll be able to pass the component DOM node to jQuery
// and call the plugin function.