Standard escape codes are prefixed with Escape:
- Ctrl-Key:
^[ - Octal:
\033 - Unicode:
\u001b - Hexadecimal:
\x1B - Decimal:
27
| 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 |
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.
# enumerate: iterate with index *and* item
>>> strings = ['123', '0', 'x']
>>> for i, s in enumerate(strings):
... print(f'{i} - {s}') # f-strings!| $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; | |
| } |
| package main | |
| import ( | |
| "crypto/sha512" | |
| "encoding/base64" | |
| "fmt" | |
| "log" | |
| "math/rand" | |
| "net/http" | |
| "strings" |
| // Tracking cursor position in real-time without JavaScript | |
| // Demo: https://twitter.com/davywtf/status/1124146339259002881 | |
| package main | |
| import ( | |
| "fmt" | |
| "net/http" | |
| "strings" | |
| ) |
| #!/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; | |
| } |
| # 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 |