Skip to content

Instantly share code, notes, and snippets.

@mrknmc
mrknmc / gist:1992443dc5a7b26c24c6
Last active August 29, 2015 14:08
Python hashing functions performance
>>> def md5(s):
... return hashlib.md5(s).hexdigest()
...
>>> def sha1(s):
... return hashlib.sha1(s).hexdigest()
...
>>> def sha256(s):
... return hashlib.sha256(s).hexdigest()
...
>>> def sha512(s):
@mrknmc
mrknmc / shopping.sh
Last active June 1, 2023 02:30
ASDA Groceries parsing
#!/usr/bin/env bash
### This only works assuming that you have all the necessary cookies in ./cookies.txt.
### I use this plugin: https://chrome.google.com/webstore/detail/cookiestxt/njabckikapfpffapmjgojcnbfjonfjfg
### Execute as follows: ./shopping.sh ./cookies.txt output.csv
# get last order id
order_id=$(curl -s -b $1 'https://groceries.asda.com/api/order/view?showmultisave=true&showrefund=true&pagenum=1&pagesize=25&requestorigin=gi' | jq -r '.orders | .[0] | .orderId')
# get url for last order
@mrknmc
mrknmc / pizza.sh
Created February 27, 2015 18:53
Snapfax Pizza Codes
#!/bin/zsh
ERROR="Invalid discount code!"
for run in {1..1000}
do
NEW_UUID=$(cat /dev/urandom | LC_ALL=C tr -cd "[:upper:]" | head -c 9)
echo -e "Trying out ${NEW_UUID}"
RESPONSE=$(curl -s "http://www.snapfaxtakeaways.co.uk/discount/usersnapcode" --data "promocode=${NEW_UUID}&code_type=2" --compressed)
echo "$RESPONSE"
if [[ "$RESPONSE" != "$ERROR" ]]
@mrknmc
mrknmc / wsus-update.ps1
Last active August 29, 2016 04:21 — forked from jacobludriks/wsus-update.ps1
wsus-update
Function WSUSUpdate {
$LogFile = "UpdateLogs\" + (Get-Date -format yyyy-MM-dd--HH-mm) + ".log"
Start-transcript $LogFile
$Criteria = "IsInstalled=0 and Type='Software'"
$Searcher = New-Object -ComObject Microsoft.Update.Searcher
try {
$SearchResult = $Searcher.Search($Criteria)
[Object[]] $Critical = $SearchResult.updates | where { $_.MsrcSeverity -eq "Critical" }
[Object[]] $Important = $SearchResult.updates | where { $_.MsrcSeverity -eq "Important" }
[Object[]] $Moderate = $SearchResult.updates | where { $_.MsrcSeverity -eq "Moderate" }

Keybase proof

I hereby claim:

  • I am mrknmc on github.
  • I am mrknmc (https://keybase.io/mrknmc) on keybase.
  • I have a public key ASBnBlIOALinHweBJaXKr6VPqPwCIQmBxPaApeIPNaNrdQo

To claim this, I am signing this object:

China

16/6 Edinburgh - 17/6 Beijing

17/6 - X/6 Beijing

X/6 Beijing - Y/6 Xi’An?

Z/7 TODO - 2/7 Chengdu

2/7 Chengdu - 2/7 Vienna

Trains

  • Beijing -> Xi’an: 4h30m
  • Xi’an -> Chengdu: 4h13m
$ docker run -it --entrypoint=/bin/bash datadog/agent
root@c2c1c5bb0c16:/# python
Python 3.7.4 (default, Dec 31 2019, 19:02:30)
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> # create socket for receive
>>> sock_read = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
>>> sock_read.bind('/tmp/socket-test')
>>> # create socket for send
@mrknmc
mrknmc / workflow.py
Created September 8, 2023 11:12
workflow.py
from dataclasses import dataclass
from datetime import timedelta
from uuid import UUID
from temporalio import activity
from temporalio import workflow
from parrot.core.logging import get_logger
logger = workflow.LoggerAdapter(get_logger(__name__), None)