Skip to content

Instantly share code, notes, and snippets.

@jeffdonthemic
jeffdonthemic / httparty.rb
Last active May 2, 2024 00:45
HTTParty Examples
options = { :body =>
{ :username => 'my',
:password => 'password'
}
}
results = HTTParty.post("http://api.topcoder.com/v2/auth", options)
##
## example for post with papertrail and basic auth
##
@olih
olih / jq-cheetsheet.md
Last active May 2, 2024 00:42
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@dhh
dhh / linux-setup.sh
Last active May 2, 2024 00:39
linux-setup.sh
# CLI
sudo apt update -y
sudo apt install -y \
git curl \
docker.io docker-buildx \
build-essential pkg-config autoconf bison rustc cargo clang \
libssl-dev libreadline-dev zlib1g-dev libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev libjemalloc2 \
libvips imagemagick libmagickwand-dev mupdf mupdf-tools \
redis-tools sqlite3 libsqlite3-0 libmysqlclient-dev \
rbenv apache2-utils
@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'}