Skip to content

Instantly share code, notes, and snippets.

View junaid1460's full-sized avatar
🙃
I may be slow to respond.

J junaid1460

🙃
I may be slow to respond.
View GitHub Profile
@junaid1460
junaid1460 / Bringing_Gun_To_a_Guard_Fight.py
Last active November 5, 2024 16:11
Google Foobar: Bringing a Gun to a Guard Fight
import math
def generate_dist_vector(size, start, tot_length, length):
tmp = [start]
count = 0
l, r = -length, tot_length - length
for i in range(size):
left = tmp[0]
right = tmp[count]
left += (l*2)
right += (r*2)
@junaid1460
junaid1460 / README.md
Last active September 26, 2017 08:43
Floyd-warshall with Distance Vector Generator

Floyd-warshall's algorithm with Distance Vector plugin

The code below is a plugin to this algorithm to generate path.

@junaid1460
junaid1460 / jupyter_html_table.py
Last active January 7, 2023 20:57
Jupyter HTML Table class, Pythonic way of creating Table for jupyter
from IPython.display import HTML, display
class Tag:
def __init__(self, name, value):
self.name = name
self.value = value
def __repr__(self):
return "<%s>%s</%s>"%(self.name, str(self.value), self.name)
class Linear:
def __init__(self, data):
@junaid1460
junaid1460 / slider-css.html
Created August 15, 2018 10:44
Simple slider with no javascript and animation
<html>
<style>
.begin {
background: #f1f1f1;
width : 100%;
}
.anim {
background: red;
width: 0%;
@junaid1460
junaid1460 / thmeservice.ts
Last active January 6, 2019 10:23
theme service
import { Injectable } from '@angular/core';
import { blueGrace } from './themes';
const themeKey = 'app:theme';
export const themeStore = {
'Blue Grace': blueGrace,
'Default': null
};
export const blueGrace = {
appSidebarClass: 'blue_grace_sidebar',
sidebarSectionClass: 'blue_grace_sidebar_section',
'app-inputs': 'blue_grace_app_inputs',
'app-tags': 'blue_grace_app_inputs',
'app-sources': 'blue_grace_app_inputs',
'myCustomThemeKey': 'myCustomClass',
};
import { Directive, Input, OnInit, ElementRef, Renderer2 } from '@angular/core';
import { ThemeService } from './theme.service';
@Directive({
selector: '[appTheme]'
})
export class ThemeDirective implements OnInit {
@Input('appTheme') appTheme: string; // appTheme="customClassKey"
constructor(
private themeService: ThemeService,
div(class="overflow-fix")
app-inputs(
#myCustomInput
appTheme
)
app-inputs(
#myCustomInput
appTheme="myCustomThemeKey"
)
.blue_grace_preview_button {
box-shadow: 0 3px 2px #e0e0e0;
margin-left: 11px !important;
}
.blue_grace_toolbar_buttons {
color: #3F51B5 !important;
margin-right: 5px !important;
@junaid1460
junaid1460 / asyncBatchMap.ts
Last active August 16, 2019 11:30
typescript snippets
// Create batches out of big array
// Map those batches to a lambda
export async function asyncBatchMap<T, F>(
items: ReadonlyArray<T>,
predicate: (input: T[]) => Promise<F>,
batchSize: number = 10,
): Promise<F[]> {
const newContainer = items.map((e) => e);
const result: F[] = [];
while (newContainer.length > 0) {