Skip to content

Instantly share code, notes, and snippets.

View htaghizadeh's full-sized avatar

Hossein Taghi-Zadeh htaghizadeh

View GitHub Profile
@mahdi13
mahdi13 / myket_rollout.py
Last active August 5, 2023 09:25
Release (deploy) new versions of android app (apk file) to myket automatically. Great to be used on CI/CD pipelines
import hashlib
import uuid
import requests
class MyketClient:
def __init__(self, package_name, username, password):
self.url = 'https://developer.myket.ir/api'
self.resource_url = 'https://resource.myket.ir'
@jweinst1
jweinst1 / 8btiwav.py
Created October 7, 2021 16:12
create an 8 bit sound wave file in python
import math
import wave
import struct
# Audio will contain a long list of samples (i.e. floating point numbers describing the
# waveform). If you were working with a very long sound you'd want to stream this to
# disk instead of buffering it all in memory list this. But most sounds will fit in
# memory.
audio = []
sample_rate = 44100
@kissgyorgy
kissgyorgy / listen.py
Created September 4, 2020 16:37
How to use PostgreSQL's LISTEN/NOTIFY as a simple message queue with psycopg2 and asyncio
import asyncio
import psycopg2
# dbname should be the same for the notifying process
conn = psycopg2.connect(host="localhost", dbname="example", user="example", password="example")
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
cursor = conn.cursor()
cursor.execute(f"LISTEN match_updates;")
"""A set of helpers for reversing urls, similar to Django ``reverse``.
Usage:
.. code:: python
@router.get("/class/{class_id}")
async def get_class(request: Request, class_id: int = Path(...)):
student_route = get_route(request.app, "list_students")
class_students_url = URLFactory(student_route).get_path(class_id=class_id)
@kislayverma
kislayverma / steve-yegge-google-platform-rant.md
Created December 26, 2019 07:11
A copy (for posterity) of Steve Yegge's internal memo in Google about what platforms are and how Amazon learnt to build them

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't really have SREs and they make engineers pretty much do everything,

@nayemDevs
nayemDevs / functions.php
Last active February 26, 2025 00:01
Creating a shortcode to show vendor biography anywhere on your page
<?php
/**
* Plugin Name: Dokan Vendor Biography Shortcode
*/
add_shortcode( 'dokan_vendor_bio', 'dokan_vendor_bio_shortcode' );
function dokan_vendor_bio_shortcode() {
$vendor = dokan()->vendor->get( get_query_var( 'author' ) );
$store_info = $vendor->get_shop_info();
if ( empty( $store_info['vendor_biography'] ) ) {
return;
@mrpeardotnet
mrpeardotnet / PVE-HP-ssacli-smart-storage-admin.md
Created November 25, 2019 22:10
HP Smart Storage Admin CLI (ssacli) installation and usage on Proxmox PVE (6.x)

HP Smart Storage Admin CLI (ssacli) installation and usage on Proxmox PVE (6.x)

Why use HP Smart Storage Admin CLI?

You can use ssacli (smart storage administrator command line interface) tool to manage any of supported HP Smart Array Controllers in your Proxmox host without need to reboot your server to access Smart Storage Administrator in BIOS. That means no host downtime when managing your storage.

CLI is not as convenient as GUI interface provided by BIOS or desktop utilities, but still allows you to fully manage your controller, physical disks and logical drives on the fly with no Proxmox host downtime.

ssacli replaces older hpssacli, but shares the same syntax and adds support for newer servers and controllers.

Installation

@renshuki
renshuki / painless_script_compare_current_date_with_index_date.md
Created October 16, 2019 08:57
Elasticsearch - Painless script to compare the current date with a date already indexed into a document

Elasticsearch Painless script which aims to calculate the difference in days between a date indexed into a document and the current date.

GET days_compare/_search
{
  "script_fields": {
    "diffdate": {
      "script": {
        "lang":   "painless",
 "source": """
# https://hakibenita.com/fast-load-data-python-postgresql
from typing import Iterator, Dict, Any, Optional
from urllib.parse import urlencode
import datetime
#------------------------ Profile
import time
@kleptog
kleptog / cnf_index.py
Created October 29, 2018 08:04
Python implementation for boolean expression index
# coding=utf8
# This is a python implementation of the boolean expression algorithm
# described in the paper "Indexing Boolean Expressions" by Whong et al.
# https://theory.stanford.edu/~sergei/papers/vldb09-indexing.pdf
# Note this really only uses the index ideas from the paper, because the
# ctual algorithm it describes involves shuffling through lists, something
# which is extremely difficult to do efficiently in python. I went for the
# easier route of simply counting entries. As such, I don't give any