Skip to content

Instantly share code, notes, and snippets.

View groz's full-sized avatar

Tagir Magomedov groz

  • Amsterdam, NL
  • 00:22 (UTC +01:00)
View GitHub Profile
@groz
groz / dijkstra-chatgpt4.md
Created April 3, 2023 13:58
Реализация алгоритма Дейкстры при помощи ChatGPT (GPT-4)

ChatGPT-4 example

Tagir Magomedov:

Напиши функцию на C#, которая выполняет поиск пути во взвешенном ориентированном графе.

ChatGPT:

Для поиска кратчайшего пути во взвешенном ориентированном графе, одним из популярных алгоритмов является алгоритм Дейкстры. Вот пример реализации алгоритма Дейкстры на C#:

using System;
@groz
groz / threads-01.md
Last active February 27, 2018 13:24
For Sultik

Рассмотрим функцию query

func query(address: String) -> String {
    let url = URL(string: address)
    let semaphore = DispatchSemaphore(value: 0)
    
    var result: String = ""
    
    let task = URLSession.shared.dataTask(with: url!) {(data, response, error) in
@groz
groz / sync-http.swift
Created February 15, 2018 22:29
Synchronous http request in Swift
import Foundation
func query(address: String) -> String {
let url = URL(string: address)
let semaphore = DispatchSemaphore(value: 0)
var result: String = ""
let task = URLSession.shared.dataTask(with: url!) {(data, response, error) in
result = String(data: data!, encoding: String.Encoding.utf8)!
@groz
groz / rxjs-backoff.js
Last active July 16, 2017 01:17
Retries with backoff in RxJS
const backoff = (maxRetries, delayFunction) =>
attempts => attempts
.zip(Rx.Observable.range(1, maxRetries), (a, idx) => idx)
.delayWhen(idx => Rx.Observable.timer(delayFunction(idx)));
// usage
const withIncrementalBackoff = observable.retryWhen(backoff(3, nRetry => nRetry * 1000));
const withExponentialBackoff = observable.retryWhen(backoff(3, nRetry => nRetry * nRetry * 1000));
@groz
groz / gomaps.go
Last active December 15, 2016 13:57
Go maps and ranges
package main
import "fmt"
func main() {
m := make(map[int]int)
m[1] = 0
for k, v := range m {
m[k + k] = v
}
@groz
groz / elm.txt
Created December 15, 2016 12:18
Elm talk outline
Elm - Friendly functional programming for the Web
Intro
====
- I'm just learning
- Evan Czaplicki, Harvard, programming for the Web doesn't have to be painful
- Ideas from academia
- Rocks the FP community boat by making ideas approachable
@groz
groz / demo.elm
Created December 15, 2016 12:16
Lunch and learn demo on Elm
module Demo exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
main =
Html.beginnerProgram
{ model = model
@groz
groz / luhn.elm
Last active November 15, 2016 22:03
Luhn algorithm for credit card validation in Elm
import Html exposing (..)
import Html.Events exposing (..)
import Html.Attributes exposing (..)
-- UI part
main =
beginnerProgram { model = { creditCardNumber = "", isValid = False } , view = view, update = update }
//: Playground - noun: a place where people can play
import UIKit
struct Person {
let name: Optional<String>
let age: Optional<Int>
}
let tagir: Person = Person(name: "Tagir", age: 32)
@groz
groz / parse_qs.py
Last active September 30, 2016 11:07
Url encoded query string parser
#!/usr/bin/env python
"""
Parses application/x-www-form-urlencoded string into a json.
Usage example:
~$ echo "a=1&b=2&a=3" | ./parse_qs.py | jq .
{
"a": [
"1",
"3"