Skip to content

Instantly share code, notes, and snippets.

@moelody
moelody / feedbro-locale-zh_CN.json
Last active June 21, 2023 08:30
feedbro中文翻译
View feedbro-locale-zh_CN.json
{
"meta": {
"manifest_version": 3,
"locale_version": "1.3",
"locale_name": "简体中文",
"locale_type": "zh_CN",
"locale_last_updated": "2020-08-07 18:00:00 UTC",
"locale_author_name": "moelody",
"locale_author_email": "yfsmallmoon@gmail.com",
"locale_source_url": "https://gist.github.com/moelody/3159316ce726fc629fae15278bbce429"
@vkhorikov
vkhorikov / CustomerController.cs
Last active June 21, 2023 08:30
Handling failures and input errors in a functional way
View CustomerController.cs
[HttpPost]
public HttpResponseMessage CreateCustomer(string name, string billingInfo)
{
Result<BillingInfo> billingInfoResult = BillingInfo.Create(billingInfo);
Result<CustomerName> customerNameResult = CustomerName.Create(name);
return Result.Combine(billingInfoResult, customerNameResult)
.OnSuccess(() => _paymentGateway.ChargeCommission(billingInfoResult.Value))
.OnSuccess(() => new Customer(customerNameResult.Value))
.OnSuccess(
@usametov
usametov / topics-search.txt
Created February 16, 2021 01:50
how to search github.com for multiple topics
View topics-search.txt
Github.com ui .currently does not natively supoport search for multiple topic tags as of now. However their api allows you to query multiple tags. Below is a simple example to query github.com with ecs and go topic tags.
curl -H "Accept: application/vnd.github.mercy-preview+json" \
https://api.github.com/search/repositories?q=topic:ecs+topic:go
Response from the github can be rather verbose so lets filter only relavant info such repo url and description.
curl -H "Accept: application/vnd.github.mercy-preview+json" \
https://api.github.com/search/repositories\?q\=topic:ecs+topic:go | jq '.items[] | {url:.url, description:.description}'
@Koziev
Koziev / finetune_chitchat_fredt5_with_trainer.py
Created April 26, 2023 05:47
Файнтюн FRED T5 XL via transformers.Trainer
View finetune_chitchat_fredt5_with_trainer.py
"""
Тренировка модели болталки Axioma на FRED T5 для проекта https://github.com/Koziev/chatbot
Эксперимент с файнтюном: токены истории диалога не включаем в backprop, присваивая соответствующим целям (labels) значение -100
Прочие хинты по тренировке: https://kelijah.livejournal.com/315826.html
"""
import os
import json
import sys
import io
@bradtraversy
bradtraversy / eslint_prettier_airbnb.md
Created July 19, 2019 17:54
ESLint, Prettier & Airbnb Setup
View eslint_prettier_airbnb.md

VSCode - ESLint, Prettier & Airbnb Setup

1. Install ESLint & Prettier extensions for VSCode

Optional - Set format on save and any global prettier options

2. Install Packages

npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-plugin-node eslint-config-node
@darekkay
darekkay / trakt-backup.php
Last active June 21, 2023 08:26
Trakt.tv backup script
View trakt-backup.php
<?php
/*
Backup script for trakt.tv (API v2).
Live demo: https://darekkay.com/blog/trakt-tv-backup/
*/
// create a Trakt app to get a client API key: http://docs.trakt.apiary.io/#introduction/create-an-app
$apikey = "CLIENT_API_KEY";
@Igor-Shvab
Igor-Shvab / differential_evolution.py
Created August 23, 2020 08:12
Differential Evolution optimization
View differential_evolution.py
def de(fobj, bounds, mut=0.8, crossp=0.7, popsize=200, its=500):
dimensions = len(bounds)
# random (0-1) positions for all particles
pop = np.random.rand(popsize, dimensions)
min_b, max_b = np.asarray(bounds).T
diff = np.fabs(min_b - max_b)
# scale particle positions according to bounds
pop_denorm = min_b + pop * diff
# initial objective function value
fitness = np.asarray([fobj(ind) for ind in pop_denorm])
@tykurtz
tykurtz / grokking_to_leetcode.md
Last active June 21, 2023 08:24
Grokking the coding interview equivalent leetcode problems
View grokking_to_leetcode.md

GROKKING NOTES

I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.

So below I made a list of leetcode problems that are as close to grokking problems as possible.

Pattern: Sliding Window

View picow_ntp_client.py
import network
import socket
import time
import struct
from machine import Pin
NTP_DELTA = 2208988800
host = "pool.ntp.org"