Skip to content

Instantly share code, notes, and snippets.

View forcewake's full-sized avatar

Pavel Nasovich forcewake

View GitHub Profile
@forcewake
forcewake / cuda_11.8_installation_on_Ubuntu_22.04
Created November 20, 2023 20:26 — forked from agentcoops/cuda_11.8_installation_on_Ubuntu_22.04
Instructions for CUDA v11.8 and cuDNN 8.7 installation on (wsl) Ubuntu 22.04 for PyTorch 2.0.0
#!/bin/bash
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
### to verify your gpu is cuda enable check
@forcewake
forcewake / lut3d.py
Created May 16, 2019 16:37 — forked from arsenyinfo/lut3d.py
Apply 3D LUT to an image. It's not optimized yet, however works as an acceptable PoC
from functools import partial
import numpy as np
from tqdm import tqdm
LUT_SIZE = 33
def _convert(pixel, lut):
r, g, b = map(lambda x: round((x / 255) * LUT_SIZE - 1), pixel)
idx = r + g * LUT_SIZE + b * (LUT_SIZE ** 2)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add
key="nuget.org"
value="https://api.nuget.org/v3/index.json"
protocolVersion="3" />
<add
key="sharper-c"
value="https://www.myget.org/F/sharper-c/api/v3/index.json"
/**
* check if a selector match a given Node element
* see https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
* @param element element to check
* @param selector selector to check
* @return true if there is a match
*/
export function matches(element: HTMLElement, selector: string): boolean {
var matches = (<any> element).matches || (<any> element).webkitMatchesSelector || element.msMatchesSelector || (<any> element).mozMatchesSelector || (<any> element).oMatchesSelector;
matches = matches.bind(element);
@forcewake
forcewake / HomeController.cs
Created May 18, 2016 13:24 — forked from ahmad-moussawi/HomeController.cs
A view Render for Razor (aspnetcore RC2)
public class HomeController : Controller {
private readonly ViewRender view;
public HomeController (ViewRender view) {
this.view = view
}
public string Test () {
// render ~/Views/Emails/ResetCode
@ignore
Feature: UserAccess
@web
Scenario: Try to get access to Some_Part_Of_The_Application
Given I open 'Application_Name' application as 'User'.
When I navigate to 'Some_Part_Of_The_Application'.
Then Menu navigation causes exception.
@forcewake
forcewake / extractTextBetweenCurlyBraces.js
Created June 5, 2015 12:55
Getting content between curly braces in javascript regex
var found = [], // an array to collect the strings that are found
rxp = /{([^}]+)}/g,
str = "a {string} with {curly} braces",
curMatch;
while( curMatch = rxp.exec( str ) ) {
found.push( curMatch[1] );
}
console.log( found ); // ["string", "curly"]
@forcewake
forcewake / SerializeExtensions.cs
Created November 11, 2014 08:16
Serialize XML
public static class SerializeExtensions
{
/// <summary>
/// Serializes the specified obj.
/// </summary>
/// <param name="obj">The obj.</param>
/// <returns>A string representing serialized data</returns>
public static string Serialize(this object obj)
{
//Check is object is serializable before trying to serialize
[
{
"title": "Design patterns and practices in .NET: the Adapter Pattern",
"link": "http://dotnetcodr.com/2013/04/25/design-patterns-and-practices-in-net-the-adapter-pattern/"
},
{
"title": "Design patterns and practices in .NET: the Strategy Pattern",
"link": "http://dotnetcodr.com/2013/04/29/design-patterns-and-practices-in-net-the-strategy-pattern/"
},
{
namespace System
{
using System.Collections.Generic;
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
public class Switch<T>
{