Skip to content

Instantly share code, notes, and snippets.

View circleupx's full-sized avatar

Yunier circleupx

  • South Florida
  • 02:32 (UTC -04:00)
View GitHub Profile
@thearn
thearn / opencv-python-ipcam.py
Last active January 12, 2023 17:01
python-opencv ip camera example
import base64
import time
import urllib2
import cv2
import numpy as np
"""
Examples of objects for image frame aquisition from both IP and
@chaoaretasty
chaoaretasty / WebAPI HttpContext for Autofac
Created October 14, 2013 16:53
Hackily enable HttpContext in WebAPI and Autofac
/*
While generally using HttpContext, and all of the related properties such as
Cookies and Session, in WebAPI is not the right way sometimes it needs to be
done, especially when migrating existing code before doing a full rewrite but
could happen in any legacy MVC project you want to bring WebAPI into.
When using Autofac there is the AutofacWebTypesModule which allows you to resolve
these dependencies, all of which come from resolving HttpContextBase.
WebAPI doesn't provide HttpContext directly but if hosted in IIS rather than
@tugberkugurlu
tugberkugurlu / WebApiSimplePatchSample.cs
Last active January 20, 2022 13:08
ASP.NET Web API Patch Sample.
public class Car {
public int Id { get; set; }
[Required]
[StringLength(20)]
public string Make { get; set; }
[Required]
[StringLength(20)]
@benbrandt22
benbrandt22 / ExceptionMessages.cs
Last active February 7, 2024 11:26
C# Extension method that generates a list of exception messages from the top level down through all inner exceptions
using System;
using System.Collections.Generic;
using System.Linq;
namespace System {
public static partial class ExceptionExtensions {
/// <summary>
/// Returns a list of all the exception messages from the top-level
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing
@davidfowl
davidfowl / dotnetlayout.md
Last active May 5, 2024 02:03
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/
@janv8000
janv8000 / AsyncRunner.cs
Created January 12, 2015 13:32
Start background tasks from MVC actions using Autofac
public interface IAsyncRunner
{
void Run<T>(Action<T> action);
}
public class AsyncRunner : IAsyncRunner
{
public ILifetimeScope LifetimeScope { get; set; }
public AsyncRunner(ILifetimeScope lifetimeScope)
@RohanBhanderi
RohanBhanderi / Git_mergetool_commands
Last active March 13, 2024 12:16
Git Mergetool and difftool with Beyond Compare 4
//Git Mergetool and difftool with Beyond Compare 4
//For Windows
//IF running this command in git bash then escape $ with \
git config --global diff.tool bc4
git config --global difftool.bc4.cmd "\"C:/Program Files (x86)/Beyond Compare 4/BCompare.exe\" \"\$LOCAL\" \"\$REMOTE\""
git config --global difftool.prompt false
git config --global merge.tool bc4
git config --global mergetool.bc4.cmd "\"C:/Program Files (x86)/Beyond Compare 4/BCompare.exe\" \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""
git config --global mergetool.bc4.trustExitCode true
@yutelin
yutelin / String+AES.swift
Last active January 22, 2024 12:36
String+AES.swift
import Foundation
import CryptoSwift
extension String {
func aesEncrypt(key: String, iv: String) throws -> String{
let data = self.dataUsingEncoding(NSUTF8StringEncoding)
let enc = try AES(key: key, iv: iv, blockMode:.CBC).encrypt(data!.arrayOfBytes(), padding: PKCS7())
let encData = NSData(bytes: enc, length: Int(enc.count))
let base64String: String = encData.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0));
@dvdsgl
dvdsgl / Monads for a C# dev.md
Last active January 8, 2024 06:11
Monads explained (sort of) to a C# developer

A monad is a fancy word for a generic type of the form MyMonad<T> (a generic type of arity 1).

A monad is special because it adds 'special powers' to the T that it wraps. These 'special powers' won't sound very special to an imperative programmer, so you have to squint to see them but bear with me.

  • IEnumerable<T> is a monad that gives values of type T the special power of nondeterminism, or the ability to 'be' multiple values at once.
  • Nullable<T> is a monad that gives values of type T the special power of nullability, or the ability to be absent.
  • Task<T> is a monad that gives values of type T the special power of asynchronicity, or the ability to be used before they are computed.

The trick with monads comes when you want to play with the T values, because they are inside another type. C# introduced language changes to make dealing with values inside these monads easier: