Skip to content

Instantly share code, notes, and snippets.

View sa-tasche's full-sized avatar

Sara Tasche sa-tasche

  • mitgedanken
  • Germany
  • 16:17 (UTC +02:00)
View GitHub Profile
@shadow-prince
shadow-prince / TimSort.py
Created July 26, 2021 02:59
Timsort Algorithm
import random
def InsertionSort(array):
for x in range (1, len(array)):
for i in range(x, 0, -1):
if array[i] < array[i - 1]:
t = array[i]
array[i] = array[i - 1]
array[i - 1] = t
@benhoyt
benhoyt / python-stdlib.md
Created October 17, 2019 00:08
Overview of (parts of) the Python standard library

I'm going to demo a bunch of Python builtin and stdlib functions. There's a lot to get through, so I'll be going fast, but please stop me and ask questions as we go. The goal is to give you a taste of Python's power and expressivity if you're not a Python person, or maybe teach you a few new tricks if you are already.

Built-in functions

# enumerate: iterate with index *and* item
>>> strings = ['123', '0', 'x']
>>> for i, s in enumerate(strings):
...     print(f'{i} - {s}')  # f-strings!
@xmeng1
xmeng1 / wsl2-network.ps1
Created July 14, 2019 06:50
WSL2 Port forwarding port to linux
$remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '"
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
if( $found ){
$remoteport = $matches[0];
} else{
echo "The Script Exited, the ip address of WSL 2 cannot be found";
exit;
}
@wybiral
wybiral / sri-profile.go
Created May 7, 2019 20:46
Experiment to get average time of SRI hash calculation from visiting browsers
package main
import (
"crypto/sha512"
"encoding/base64"
"fmt"
"log"
"math/rand"
"net/http"
"strings"
@wybiral
wybiral / noscript-tracking.go
Last active October 28, 2024 23:01
Tracking cursor position in real-time with remote monitoring (without JavaScript)
// Tracking cursor position in real-time without JavaScript
// Demo: https://twitter.com/davywtf/status/1124146339259002881
package main
import (
"fmt"
"net/http"
"strings"
)
@ruminations
ruminations / timsort.py
Last active August 13, 2021 21:05
An educational version of the timsort algorithm written in python.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Module : timsort.py
Website: https://gist.github.com/ruminations/89a045dc0ef7edfb92304a0de0752ee0
License: https://github.com/ruminations/Licenses#design-license
Initial Copyright September 2018
This is a python implementation of the ideas presented by Tim Peters at:
<!DOCTYPE html>
<html>
<head>
<title>Drag test</title>
<style>
#zone {
position: relative;
background: yellow;
height: 800px;
}
@bee-san
bee-san / timsort.py
Last active August 15, 2021 10:28
An Python implementation of Timsort
# based off of this code https://gist.github.com/nandajavarma/a3a6b62f34e74ec4c31674934327bbd3
# Brandon Skerritt
# https://skerritt.tech
def binary_search(the_array, item, start, end):
if start == end:
if the_array[start] > item:
return start
else:
return start + 1
@vurtun
vurtun / _readme_quarks.md
Last active March 29, 2025 00:56
Quarks: Graphical user interface

gui

Proposal for a PSR for message translator

The main aim of this proposal is to provide a common interface for the interoperability of message translations across different packages

What is the scope?

  • Provide a way to consume message translations in different languages.
  • Allow handling plurals
  • Allow using translations from different contexts and domains