Skip to content

Instantly share code, notes, and snippets.

@farukcan
farukcan / RemoteText.cs
Last active October 8, 2022 12:32
Unity Easy Set Texts Remotely
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(Text))]
public class RemoteText : MonoBehaviour
{
@farukcan
farukcan / spread.js
Last active October 5, 2022 17:59
JS Spread Operator
// source : https://www.sitepoint.com/javascript-spread-operator/
const evenNumbers = [2, 4, 6, 8];
const oddNumbers = [1, 3, 5, 7];
const allNumbers = [...evenNumbers, ...oddNumbers];
console.log(...allNumbers); //[2, 4, 6, 8, 1, 3, 5, 7]
const obj1 = { name: 'Mark', age: 20};
const obj2 = { age: 30 };
const clonedObj = { ...obj1, ...obj2 };
@farukcan
farukcan / ordinal.js
Last active October 5, 2022 18:04
JS getOrdinal(n)
// check : https://byjus.com/maths/ordinal-numbers/
function getOrdinal(n) {
let ord = 'th';
if (n % 10 == 1 && n % 100 != 11)
{
ord = 'st';
}
else if (n % 10 == 2 && n % 100 != 12)
{
@farukcan
farukcan / Dockerfile
Last active October 20, 2022 23:31
111MB dotnet core 6.0 alpine docker file
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
WORKDIR /source
COPY /. ./
# Install npm - we need node_modules folder
RUN apk add --update nodejs npm
RUN npm install
# Build the app
RUN dotnet restore
@farukcan
farukcan / .gitignore
Created October 20, 2022 23:32
gitignore file for asp dotnet core 6
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
@farukcan
farukcan / note.md
Created October 20, 2022 23:36
Use npm and asp dotnet together

use node_modules folder as static folder /lib

app.UseStaticFiles(new StaticFileOptions
{
    FileProvider = new PhysicalFileProvider(
            Path.Combine(Directory.GetCurrentDirectory(), "node_modules")),
    RequestPath = "/lib",
        
    OnPrepareResponse = ctx =>
 {
@farukcan
farukcan / net.md
Created October 21, 2022 14:48
.NET Core/Framework diff

.NET Core is a free open source, a general-purpose development platform for developing modern cloud-based software applications on Windows, Linux, and macOS operating systems. It operates across several platforms and has been revamped to make .NET fast, scalable, and modern. .NET Core is one of Microsoft’s big contributions and released under the MIT License. It offers the following features:

Cross-Platform Open Source High Performance Multiple environments and development mode etc.

What to use .NET Framework or .NET Core?

.NET Core is to be used for the server application when –

@farukcan
farukcan / vscode-omnisharp.md
Created October 26, 2022 17:58 — forked from stormwild/vscode-omnisharp.md
Visual Studio Code Restart OmniSharp
@farukcan
farukcan / SessionExtension.cs
Last active November 3, 2022 14:36
DotNetCore Session Extension
using System.Text.Json;
using Microsoft.AspNetCore.Http;
// source : https://www.learmoreseekmore.com/2020/05/dotnet-core-session.html
// usage : InfoModel info = HttpContext.Session.Get<InfoModel>("info");
// usage : HttpContext.Session.Set<InfoModel>("info", info);
namespace SessionMvc.App.Utilities
{
public static class SessionExtension
{
public static void Set<T>(this ISession session, string key, T value)
@farukcan
farukcan / Sha256Helper.cs
Created November 3, 2022 14:38
C# SHA256 Helper
using System.Security.Cryptography;
using System.Text;
namespace FarukCan.Helpers
{
public static class Sha256Helper
{
public static string GetSha256Hash(this string input,string salt="")
{
using (SHA256 sha256Hash = SHA256.Create())