Skip to content

Instantly share code, notes, and snippets.

View alpersilistre's full-sized avatar
🧩
Focusing

Alper Silistre alpersilistre

🧩
Focusing
View GitHub Profile
# https://hub.docker.com/_/microsoft-dotnet
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /app
EXPOSE 80
EXPOSE 443
# copy csproj and restore as distinct layers
COPY ComplexApp.Core/*.csproj ComplexApp.Core/
COPY ComplexApp.Web/*.csproj ComplexApp.Web/
RUN dotnet restore ComplexApp.Web
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.Identity.Web;
using Microsoft.Identity.Web.UI;
var builder = WebApplication.CreateBuilder(args);
IEnumerable<string>? initialScopes = builder.Configuration["DownstreamApi:Scopes"]?.Split(' ');
builder.Services.AddMicrosoftIdentityWebAppAuthentication(builder.Configuration, "AzureAd")
.EnableTokenAcquisitionToCallDownstreamApi(initialScopes)
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"applicationName": {
"type": "string",
"metadata": {
"description": "Name of the application."
}
},
@alpersilistre
alpersilistre / HideCommentsButtonForTigranHNWebsite.js
Created May 13, 2020 20:01
This script can be run on the https://hn.tigran.io/post/xxxxxxx page to add Hide buttons to all main comments in the screen. I can hide them by clicking the 'Hide' button to lessen the noise after I read any root comment.
// works on https://hn.tigran.io/post/xxxxxxx page
let parentComments = document.querySelector('main > div').querySelectorAll(':scope > div');
function createHideItem() {
let span = document.createElement('span');
span.textContent = 'Hide';
span.addEventListener('click', x => {
console.log(x);
package automationFramwork;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class RegistrationTestCase {
public class MultiplicationTests {
@Test
public void MultiplicationOfZeroIntegerShouldReturnZero() {
assertEquals(0, Main.Multiplication(10, 0));
assertEquals(0, Main.Multiplication(0, 10));
assertEquals(0, Main.Multiplication(0, 0));
}
@Test
@alpersilistre
alpersilistre / 0_reuse_code.js
Created December 1, 2016 15:42
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@alpersilistre
alpersilistre / forLoop.js
Created February 14, 2016 23:54
IIFE inside for loop
for(var i = 0; i < jsonObj.length ; i++){
(function(i) {
imdb.getImdbInfo(jsonObj[i].imdbId).then(function (data) {
console.log('done ' + i);
jsonObj[i].title = data.Title;
});
@alpersilistre
alpersilistre / angularjs.html
Created December 30, 2015 23:35
Angular JS basic example
<!doctype html>
<html ng-app="app">
<head>
</head>
<body>
<h1 ng-controller="HelloWorldCtrl">{{helloMessage}}</h1>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script type="text/javascript">
angular.module('app', []).controller('HelloWorldCtrl',
@alpersilistre
alpersilistre / server.js
Last active December 29, 2015 10:09
Node.js basic http web server file
var http = require('http');
var fs = require('fs');
const PORT = 8000;
function send404Response(response){
response.writeHead(404, {"Context-Type": "text/plain"});
response.write("Error 404: Page not found!");
response.end();
}