Skip to content

Instantly share code, notes, and snippets.

@JanPetr
JanPetr / list_all_copies.py
Created January 10, 2023 08:38
List all the copies for a specific asset via Pex Discovery API
import requests
# This example shows how to list all the copies for a specific asset via Pex Discovery API.
# Documentation for listing copies can be found here: https://docs.api.pex.com/#copies
# Use your actual key from page https://drm.pex.com/settings/api-keys
token = "FIXME"
# Use ID of your specific asset.
# It can be found in URL of asset detail page, eg. https://drm.pex.com/asset/5812359003677950988 <- asset ID.
@JanPetr
JanPetr / main.go
Last active December 22, 2022 05:19
Upload asset to Pex via TUS client - Golang example
package main
import (
"bytes"
"crypto/sha256"
"fmt"
"io"
"os"
"github.com/eventials/go-tus" // install with `$ go get github.com/eventials/go-tus`
This file has been truncated, but you can view the full file.
[
{
"id": 379693831,
"title": "Audible audio books & podcasts",
"icon": "https:\/\/is3-ssl.mzstatic.com\/image\/thumb\/Purple118\/v4\/5b\/8a\/23\/5b8a23f7-df0f-3558-5c25-6ef47132e7c9\/AppIcon-1x_U007emarketing-0-0-GLES2_U002c0-512MB-sRGB-0-0-0-85-220-0-0-0-5.png\/180x180bb.png",
"developer": "Audible, Inc.",
"price": "$0.00",
"genres": [
6018,
6016
@JanPetr
JanPetr / auth.json-example
Last active September 28, 2018 09:31
Install M2 with Algolia extension
{
"http-basic": {
"repo.magento.com": {
"username": "[[FIXME]]",
"password": "[[FIXME]]"
}
}
}
@JanPetr
JanPetr / hooks.js
Created February 7, 2018 12:56
Code to replace Magento extension's query suggestions by Algolia powered query suggestions Raw
function algoliaHookBeforeAutocompleteStart(sources, options, algoliaClient) {
for (var i = 0; i < sources.length; i++) {
if (sources[i].name === 'suggestions') {
var index = algoliaClient.initIndex('products_suggestions_query_suggestions'),
suggestionsSource = algoliaBundle.$.fn.autocomplete.sources.hits(index, {
hitsPerPage: 2 // FIX IT
});
sources[i] = {
source: suggestionsSource,
@JanPetr
JanPetr / ClearDocker.sh
Created November 14, 2016 12:21
Clear docker
#!/bin/bash
# Stop all containers
docker stop $(docker ps -a -q)
# Remove all containers
docker rm $(docker ps -a -q)
# Remove all images
docker rmi $(docker images -q)
@JanPetr
JanPetr / RedisIntersectTagInvalidator.php
Last active November 14, 2016 12:23
Nette + Redis - delete cache based on tag intersection
<?php
use Kdyby\Redis\RedisClient;
use Kdyby\Redis\RedisStorage;
use Nette\Caching\Cache;
use Nette\Caching\IStorage;
use Nette\DI\Container;
class RedisIntersectTagInvalidator
{