Skip to content

Instantly share code, notes, and snippets.

@ncalm
ncalm / excel-lambda-SUMPRODUCT2.txt
Created April 30, 2024 17:14
This Excel LAMBDA functions mimics SUMPRODUCT but allows a single 2D array as its only argument
IFOMITTED = LAMBDA(arg,then,IF(ISOMITTED(arg),then,arg));
SUMPRODUCT2 = LAMBDA(array, [axis],
SUM(IF(IFOMITTED(axis,0)=0, BYROW, BYCOL)(array, PRODUCT))
);
@mostafabahri
mostafabahri / decrypt.py
Last active May 2, 2024 00:37
Fernet encryption example with password
#!/usr/bin/env python3
from cryptography.fernet import Fernet
from kdf import derive_key
passphrase = b"hunter2"
f = Fernet(derive_key(passphrase))
with open('encrypted.txt', 'rb') as file:
encrypted = file.read() # binary read

Установка приватного пакета с помощью composer

  1. Необходимо создать ssh ключ и добавить его в настройки профиля GitHub, которому пренадлежит нужный репозиторий, если это не было сделано ранее.

Tip: вы можете использовать данный скрипт для создания и добавления SSH ключа.

  1. Указать url приватного репозитория в composer.json следующим образом:
"repositories": [
@pcuenca
pcuenca / openelm-coreml.py
Created April 30, 2024 09:55
Convert OpenELM to Core ML (float32)
import argparse
import numpy as np
import torch
import torch.nn as nn
import coremltools as ct
from transformers import AutoTokenizer, AutoModelForCausalLM
# When using float16, all predicted logits are 0. To be debugged.
compute_precision = ct.precision.FLOAT32
compute_units = ct.ComputeUnit.CPU_ONLY
@alexreardon
alexreardon / how-this-works.md
Created August 7, 2022 00:29
How `this` works in javascript

this binding

  • this is the runtime context of a function.
  • this is determined by the call site
  • the same function can be executed with different this runtime contexts. You can think of this as another arguement to the function
  • Comparison: scopes are generally defined at compile time (exception: eval)
const person = {
 name: 'Alex',
@nikolovlazar
nikolovlazar / keybindings.json
Created April 29, 2024 01:12
VSCode key bindings to navigate like Neovim
[
// Navigation
{
"key": "ctrl-h",
"command": "workbench.action.navigateLeft"
},
{
"key": "ctrl-l",
"command": "workbench.action.navigateRight"
},
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows, calc, chains, positioning}
\begin{document}
\begin{tikzpicture}[node distance = 4mm and 0mm,
box/.style = {shape=rectangle, draw, minimum size=2em, outer sep=0pt, on chain=#1},
sum/.style = {shape=circle, draw, inner sep=0pt, node contents={$+$}},
every path/.append style = {-latex'}
@jimkring
jimkring / image.py
Last active May 2, 2024 00:16
fastui raw html component example
import io
import base64
from typing import Union
from PIL import Image # requires `pillow` package
from fastui.components import Iframe
def iframe_from_html_raw(
raw_html: str,
@naviocean
naviocean / git_large_file.md
Created September 14, 2020 07:36
Fixing the “GH001: Large files detected. You may want to try Git Large File Storage.”

Fixing the “GH001: Large files detected. You may want to try Git Large File Storage.”

I just migrated my repositories from BitBucket to GitHub but, suddenly, I received an interesting error when I tried to push a repo with some large files inside.

remote: error: GH001: Large files detected. You may want to try Git Large File Storage — https://git-lfs.github.com.
remote: error: Trace: b5116d865251981c96d4b32cdf7ef464
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File fixtures/11_user_answer.json is 131.37 MB; this exceeds GitHub’s file size limit of 100.00 MB
@y0ngb1n
y0ngb1n / docker-registry-mirrors.md
Last active May 2, 2024 00:14
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized

Docker Hub 镜像加速器

国内从 Docker Hub 拉取镜像有时会遇到困难,此时可以配置镜像加速器。Docker 官方和国内很多云服务商都提供了国内加速器服务。

Dockerized 实践 https://github.com/y0ngb1n/dockerized

配置加速地址

Ubuntu 16.04+、Debian 8+、CentOS 7+