Skip to content

Instantly share code, notes, and snippets.

View kristof-mattei's full-sized avatar
🦀
Rusting?

Kristof Mattei kristof-mattei

🦀
Rusting?
View GitHub Profile

Keybase proof

I hereby claim:

  • I am kristof-mattei on github.
  • I am kristofmattei (https://keybase.io/kristofmattei) on keybase.
  • I have a public key ASCtQyd-9VA2StBNECcWVfRZeQu9zKgSp4Zw974SFZ-iSQo

To claim this, I am signing this object:

@kristof-mattei
kristof-mattei / Rakefile
Created July 30, 2022 00:02 — forked from dmshvetsov/Rakefile
Use rails webpacker gem with npm instead of yarn, Rails recipe.
# Rakefile
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks
# Replace yarn with npm
Rake::Task['yarn:install'].clear if Rake::Task.task_defined?('yarn:install')
Rake::Task['webpacker:yarn_install'].clear
Rake::Task['webpacker:check_yarn'].clear
@kristof-mattei
kristof-mattei / python_lambda_closure.py
Last active October 29, 2021 18:02
Comparing lambda closure capturing in Python and javascript
# sorry, python doesn't have a built-in table printer
from tabulate import tabulate
max = 3
def get_functions():
lst = []
for i in range(0, max):
lst.append(lambda: i)
return lst
@kristof-mattei
kristof-mattei / cleanup_all_workflow_runs.js
Created October 29, 2021 16:42
Clean up all workflow runs.
const { Octokit } = require("@octokit/rest");
const { serializeError } = require("serialize-error");
const octokit = new Octokit({
auth: "PUT TOKEN HERE"
});
const baseRef = {
owner: "Kristof-Mattei",
@kristof-mattei
kristof-mattei / javascript_lambda_closure.js
Last active October 29, 2021 17:04
Comparing lambda closure capturing in Python and javascript
const max = 3;
function get_functions() {
lst = []
for (const i of [...Array(max).keys()]) {
lst.push(() => i)
}
return lst
}
function* get_functions_yield() {
@kristof-mattei
kristof-mattei / neo4j_tx.run_swallows_errors.py
Created August 31, 2020 19:07
Neo4j tx.run swallows errors
from neo4j import GraphDatabase
driver = GraphDatabase.driver("bolt://localhost:7687", auth=("neo4j", "****"))
query = """WITH {} AS x
CALL apoc.util.validate(x IS NOT NULL, 'A query that fails', [x])
RETURN false"""
def read_transaction():
def _callback(tx):
module Engine.Functions
let rec Calculate columns =
match columns with
| h::[] -> [ [ h ] ]
| h::t ->
let x = Calculate t
List.fold (fun acc elem -> (h::elem)::acc) ([h]::x) x
| [] -> []
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication41
{
class Program
{