Skip to content

Instantly share code, notes, and snippets.

@elazarg
elazarg / terraform debug log.txt
Created July 19, 2023 10:48
Debug information for terraform plugin crash
terraform : 2023-07-19T13:45:51.348+0300 [INFO] Terraform version: 1.5.3
At line:1 char:1
+ terraform apply -var-file="variables.tfvars" -auto-approve 2> .\bug_r ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (2023-07-19T13:4... version: 1.5.3:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
2023-07-19T13:45:51.368+0300 [DEBUG] using github.com/hashicorp/go-tfe v1.26.0
2023-07-19T13:45:51.368+0300 [DEBUG] using github.com/hashicorp/hcl/v2 v2.16.2
2023-07-19T13:45:51.368+0300 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.0
@elazarg
elazarg / BadderOffer.gs
Last active November 2, 2022 05:48
Implementation of the Badder Offer algorithm for Google Sheets
// http://bechirot.gov.il/election/about/Pages/CalculatingSeatsMethod.aspx
// http://www.knesset.gov.il/lexicon/eng/seats_eng.htm
// http://main.knesset.gov.il/About/Lexicon/Pages/seats.aspx
/**
* Computes the Badder-Offer score for specific party.
*
* @param {parties} party names
* @param {votes} votes for parties
* @param {agreement_pairs} Two columns, name-name pairs.
@elazarg
elazarg / nakdan.py
Last active March 24, 2022 11:00
Fetching diacritization from Dicta's API
from typing import Literal
import re
from functools import wraps
import requests
__all__ = ['fetch_dicta']
METEG = '\u05BD'
@elazarg
elazarg / AGT-FOL.v
Created September 13, 2021 17:33
Definitions and proofs for simplified constraint-based auction
Require Import PeanoNat.
Inductive Atom {T: Type} : Type :=
| avar: nat -> Atom
| aconst: T -> Atom
.
Inductive prop {T: Type} : Type :=
| Eq : @Atom T -> @Atom T -> prop
| Lt : @Atom nat -> @Atom nat -> prop
from bs4 import BeautifulSoup
import requests
from isoweek import Week
def fetch_table(year, week):
date = Week(year, week).sunday().strftime("%d/%m/%Y")
url = 'http://212.150.52.211/scripts/rating10.asp'
response = requests.post(url, data={
'audience': '1',
@elazarg
elazarg / subsum.py
Created December 22, 2017 11:13
subset sum with memoization
from random import randrange
from functools import lru_cache
from bisect import bisect_right
arr = [randrange(100000) for _ in range(2000)]
arr.sort()
import sys
sys.setrecursionlimit(20000)
@elazarg
elazarg / find_isolated_functions.py
Last active October 22, 2016 13:41
A small script that warns about functions that are not called from within the code
#!/usr/bin/python3
from contextlib import contextmanager
from ast import NodeVisitor
import ast
import sys
import glob
class Flags:
include_strings = True
@elazarg
elazarg / fresh_defaults.py
Last active January 2, 2021 07:53
Python3: A decorator `fresh_defaults` that allows mutable default arguments for functions
from functools import wraps
from copy import deepcopy
from types import FunctionType
def fresh_defaults(f):
'''
A decorator that allows mutable default arguments (such as lists)
to be used without worrying about changes across calls.
@elazarg
elazarg / pretty_print.py
Created June 6, 2016 03:04
use `with`: transform `f=open(...); ... ; f.close()' into `with open(...) as f: ...`
# -*- coding: utf-8 -*-
"""
codegen
~~~~~~~
Extension to ast that allow ast -> python code generation.
:copyright: Copyright 2008 by Armin Ronacher.
:license: BSD.
"""