Skip to content

Instantly share code, notes, and snippets.

@leberknecht
leberknecht / gist:ea1692a0281fd832ecc68462c0bb6d33
Created March 10, 2022 10:13
Elasticsearch special character meanings
+ => term must be present
- => tern must not be present
&& => not 100% sure, lucene says `can be used in place of the word AND`
|| => not 100% sure, lucene says `can be used in place of the word OR`
> => can be used in comparison on range queries like `age:(+>=10 +<20)`
< => can be used in comparison on range queries like `age:(+>=10 +<20)`
= => can be used in comparison on range queries like `age:(+>=10 +<20)`
( => range query opening
) => range query closing
{ => exclusive range query opening
Computer Information:
Manufacturer: Unknown
Model: Unknown
Form Factor: Desktop
No Touch Input Detected
Processor Information:
CPU Vendor: AuthenticAMD
CPU Brand: AMD Ryzen 7 1800X Eight-Core Processor
CPU Family: 0x17
@leberknecht
leberknecht / web3-1.0-deploy-contract-hd-wallet.js
Last active April 12, 2019 09:32
Web3 v1.0 deploy contract using truffle-hd-wallet provider
/* contract:
pragma solidity ^0.4.23;
contract A {
uint public x = 42;
function someMethod() public view returns(uint)
{
return x;
}
}
*/
@leberknecht
leberknecht / sign-n-deploy-sendRawTransaction-web3-v0.20.x.js
Last active April 9, 2019 12:18
Sign & Deploy contract via sendRawTransaction with web3 0.20.x
/**
pragma solidity >=0.4.25;
contract MyContract {
string someVariable;
constructor(string memory _someVariable) public {
someVariable = _someVariable;
}
@leberknecht
leberknecht / berlin-buergeramt-helper.py
Last active March 15, 2023 10:26
berlin bürgeramt booking help
import os
from pyquery import PyQuery as pq
curl_command = "curl 'https://service.berlin.de/terminvereinbarung/termin/day/' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/110.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' -H 'Accept-Language: en,en-US;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' -H 'Referer: https://service.berlin.de/dienstleistung/121469/' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Cookie: zmsappointment-session=inProgress; wt_rla=102571513503709%2C3%2C1678870510105; Zmsappointment=bdbcgshe0uar50svso3ldd0d5p' -H 'Upgrade-Insecure-Requests: 1' -H 'Sec-Fetch-Dest: document' -H 'Sec-Fetch-Mode: navigate' -H 'Sec-Fetch-Site: same-origin' -H 'Sec-Fetch-User: ?1' -H 'TE: trailers'"
curl_command = curl_command.replace("-H 'Accept-Encoding: gzip, deflate, br'", '') + " 2>/dev/null"
print("reading from website...")
content = os.popen(curl_command).read()
with open('tmppage.html', 'w') as f:
f.write(conte
@leberknecht
leberknecht / web3-v1.0-events.js
Created August 16, 2018 08:08
Using events in web3 v1.0
/* contract:
pragma solidity ^0.4.23;
contract A {
event SomethingHappend(
address indexed _from,
uint _value
);
uint public x = 42;
@leberknecht
leberknecht / gist:383104d68fa355b79046fb98a4273e5c
Created August 10, 2018 12:44
deploy a smart contract with Web3 v1.0
/* contract:
pragma solidity ^0.4.23;
contract A {
uint public x = 42;
function someMethod() public view returns(uint)
{
return x;
}
}
@leberknecht
leberknecht / gist:439d00884a5c49df57a087d49d867eac
Created July 31, 2018 15:04
create hostname entries for docker containers on docker-hosts /etc/hosts
#!/bin/bash
args=("$@")
CONTAINER_IDS=$(docker ps | cut -d" " -f1 | tail -n +2)
cp /etc/hosts /tmp/hosts.bak
cp /etc/hosts /tmp/hosts.tmp
echo "etc/hosts backup saved to /tmp/hosts.bak"
for i in $CONTAINER_IDS; do
if [[ ${args[0]} == '' ]]; then
if [[ "$DOCKER_HOST" != "" ]]; then
@leberknecht
leberknecht / sh
Created May 16, 2018 08:39
AWS: find unused security groups
#!/bin/bash
KNOWN_SECURITY_GROUPS=$(aws ec2 describe-security-groups | jq '.SecurityGroups[].GroupId' | egrep -o '[^"]+')
INSTANCES_DETAILS=$(aws ec2 describe-instances)
ELB_DETAILS=$(aws elb describe-load-balancers)
for SECURITY_GROUP in ${KNOWN_SECURITY_GROUPS[@]}; do
echo "checking '$SECURITY_GROUP':"
EC2_USAGE_COUNT=$(echo $INSTANCES_DETAILS | grep $SECURITY_GROUP | wc -l)
if [[ "$EC2_USAGE_COUNT" == "0" ]]; then
echo "not assigned to any ec2-instance, checking ELBs..."