Skip to content

Instantly share code, notes, and snippets.

View ccpu's full-sized avatar

cyrus ccpu

  • Planet Earth, Milky Way
View GitHub Profile
@lakeman
lakeman / AutoMigration.cs
Last active October 9, 2023 00:30
Automatic database migration with EF Core 3.0
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations.Design;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
using Microsoft.EntityFrameworkCore.Storage;
@intergalacticspacehighway
intergalacticspacehighway / cloudSettings
Last active November 2, 2020 12:03
useReducer with thunks and redux dev-tools.
{"lastUpload":"2020-11-02T12:03:38.255Z","extensionVersion":"v3.4.3"}
/* This uses a modified version of puppeteer-to-istanbul and v8-to-istanbul */
// There are a lot of diffs here but most of it is just prettier changes :(
// https://github.com/istanbuljs/puppeteer-to-istanbul/compare/master...Friss:master
// Mostly just converting it to handle the new async v8-to-istanbul code. Also fetches sourcemaps if availabile.
// https://github.com/istanbuljs/v8-to-istanbul/compare/source-maps...Friss:source-maps
// Tweaks to parse the path out to webpack files that I recreated based on the source maps.
@StrongerMyself
StrongerMyself / typescriptreact.json
Last active November 16, 2020 12:23
vs-code tsx snippets
{
"tsx-test-filename": {
"prefix": "tsx-test-filename",
"body": [
"${TM_FILENAME_BASE/^(.)|([.-](.))/${1:/upcase}${3:/upcase}/g}",
],
"description": "TSX filename"
},
"tsx": {
@yairEO
yairEO / events.namespace.js
Last active August 11, 2023 07:08
Event Handler Namespace in Vanilla JavaScript
var events = (function(){
function addRemove(op, events, cb){
if( cb )
events.split(' ').forEach(name => {
var ev = name.split('.')[0]
cb = cb || this._eventsNS[name]
this[op + 'EventListener'].call(this, ev, cb)
if(op == 'add')
@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));
@sergiodxa
sergiodxa / native-create-element.js
Last active September 22, 2023 21:05
Example implementation of the same API of React.createElement but using native DOM elements
// use JSX with el instead of React.createElement
/** @jsx createElement */
const Children = {
only(children) {
if (children.length > 1 || children.length === 0) {
throw new Error('The children must have only one element');
}
return children[0];
}
@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)
@superKalo
superKalo / Sortable.jsx
Last active August 9, 2022 09:31
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.
@publicJorn
publicJorn / jquery-plugin-template-es6.js
Last active June 4, 2023 21:43
jQuery plugin template ES6
/**
* jQuery plugin template by https://github.com/publicJorn
* Features:
* - ES6 (So, it requires a build step to transpile to ES5 for most environments)
* - Dynamic plugin name (only supply once) so it's easy to change later
* - Plugin factory to make it work in the browser, or with AMD / COMMONJS modules
* - Plugin instance is saved on the selector element
* - Default options are saved to the instance in case you need to figure out a difference between passed options
*/
(function(global, factory) {