Skip to content

Instantly share code, notes, and snippets.

View Abdelhak-Bahri's full-sized avatar
:octocat:

BAHRI Abdelhak Abdelhak-Bahri

:octocat:
View GitHub Profile
@Abdelhak-Bahri
Abdelhak-Bahri / weird-sqrt.html
Created June 1, 2021 15:37
it's not meant to be on production. this is just a joke about how to find sqrt using html and yet there are more weird ways
<!DOCTYPE html>
<html>
<head>
<style>
body{
margin:0;
}
.container{
width:25vw;
height: 100vh;
@Abdelhak-Bahri
Abdelhak-Bahri / AzureFunctionControllingAzureVM.ps1
Created January 3, 2021 00:37
This gist is part of cloudericks lab notes (controlling azure vm by a Rest API using azure functions)
using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
# Interact with query parameters or the body of the request.
$rgname = $Request.Query.resourcegroup
if (-not $rgname) {
$rgname = $Request.Body.resourcegroup
}
@Abdelhak-Bahri
Abdelhak-Bahri / BinaryGap.js
Created April 16, 2020 01:25
A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N
function BinaryGap(N) {
//get N binary representation
let Nbin = N.toString(2);
//trim from start to last 1
const lastIndexOfOne = Nbin.lastIndexOf('1')
Nbin = Nbin.substr(0,lastIndexOfOne);
//split by 1
let Gaps = Nbin.split('1').map(el=> el.length);
// take max length
return Math.max(...Gaps);