Skip to content

Instantly share code, notes, and snippets.

View goulashify's full-sized avatar

Dániel Gulyás goulashify

View GitHub Profile
@goulashify
goulashify / token.sh
Created November 25, 2024 18:01
Getting a jwt template from clerk easily
export CLERK_URL="https://banano-banani-77.clerk.accounts.dev"
export CLERK_API_KEY="sk_test_aw1gJRqDW4Yzw4DFJAkR9UPOnaFmrX3uJ9VGDVG1qw"
export CLERK_JWT_TEMPLATE="corp_jwt_template"
export CLERK_USER_ID="user_2pLHczvpbEi5asZOozZPH6Q8afM"
export SIGN_IN_TOKEN=$(printf '{"user_id": "%s"}' "$CLERK_USER_ID" | curl -d @- -X POST -H "Authorization:Bearer $CLERK_API_KEY" -H 'Content-Type: application/json' "https://api.clerk.com/v1/sign_in_tokens" | jq -r '.token')
export SESSION_ID=$(curl "$CLERK_URL/v1/client/sign_ins?__clerk_api_version=2021-02-05&_clerk_js_version=5.35.0" -X POST -H 'content-type: application/x-www-form-urlencoded' --data-raw "strategy=ticket&ticket=$SIGN_IN_TOKEN" | jq -r '.response.created_session_id')
export TOKEN=$(echo '{"expires_in_seconds":315360000}' | curl -d @- -X POST "https://api.clerk.com/v1/sessions/$SESSION_ID/tokens/$CLERK_JWT_TEMPLATE" -H 'Content-Type: application/json' -H "Authorization: Bearer $CLERK_API_KEY" | jq -r '.jwt')
@goulashify
goulashify / Convert.swift
Created August 26, 2021 12:11
Converting a SemVer to an integer version
import Foundation
let smallerSemVer = "3.1.279"
let largerSemVerA = "3.1.280"
let largerSemVerB = "3.2.0"
let largerSemVerC = "3.3"
let largerSemVerD = "4"
let largerSemVerE = "3.3"
String(format: "%03d", 0)
// This works perfectly, OnCommittedResponseWrapper#onResponseCommitted is called.
@ResponseBody
@RequestMapping(method = DELETE)
public String invalidate() {
sharedSession.invalidate();
return "lol ok";
}
// This works perfectly too, OnCommittedResponseWrapper#onResponseCommitted is called.
@RequestMapping(method = DELETE)
@goulashify
goulashify / spec_extractor.py
Created November 14, 2018 13:32
Extract mac specs from advertisements (basic)
import re
MATCHER = {
# Matches years from 2010-2020.
'YEAR': '20(10|11|12|13|14|15|16|17|18|19|20)',
# Matches the CPU type, i7 / i5.
'CPU_TYPE': '(i7)|(i5)',
# Matches the CPU clock rate, 2.3 Ghz, 3,1ghz, 2,9 GHZ, should use re.IGNORECASE for this.
@goulashify
goulashify / VSelectGroup.js
Last active May 30, 2018 11:12
Groupable <VSelect /> in Vuetify.
import {VSelect, VList, VCard, VSubheader} from 'vuetify/src/components'
import {VListTile} from "vuetify/src/components/VList"
import {getObjectValueByPath} from "vuetify/src/util/helpers"
/**
* Vuetify's VSelect extended to be groupable, example usage:
*
* <code>
* <template>
@goulashify
goulashify / MetaValueCache.java
Created March 23, 2017 09:01
How to access Hibernate's MetadataContributor before Spring boots
package com.danigu.fancypants.core.persistence;
import org.hibernate.annotations.AnyMetaDef;
import org.hibernate.annotations.MetaValue;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Meta value cache used by {@link com.danigu.fancypants.rating.persistence.RatingRepositoryImpl} to
@import url(https://fonts.googleapis.com/css?family=Roboto:400,700,500,300);@import url(https://fonts.googleapis.com/css?family=Roboto+Mono:400,700,500,300);@keyframes a{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes b{0%{opacity:1}50%{opacity:0}to{opacity:1}}[src$="blue.png"]{background-image:url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4IiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIxOCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBmaWxsPSIjMDA5Njg4IiBkPSJNMTIgMkM2LjQ4IDIgMiA2LjQ4IDIgMTJzNC40OCAxMCAxMCAxMCAxMC00LjQ4IDEwLTEwUzE3LjUyIDIgMTIgMnptLTIgMTVsLTUtNSAxLjQxLTEuNDFMMTAgMTQuMTdsNy41OS03LjU5TDE5IDhsLTkgOXoiLz48L3N2Zz4=)}[src$="red.png"]{background-image:url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4IiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIxOCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBmaWxsPSIjRjQ0MzM2IiBkPSJNMTIgMkM2LjQ4IDIgMiA2LjQ4IDIgMTJzNC40OCAxMCAxMCAxMCAxMC00LjQ4IDEwLTEwUzE3LjUyIDIgMTIgMnptMSAxNWgtMnYtMmgydjJ6bTAtNGgtMlY3aDJ2NnoiLz48L3N2Zz4=)}[src$="yellow.png
defmodule Streamrand do
@moduledoc """
Module responsible for taking a stream in stdin and constructing a k char long representative random sample from it.
k is from the argument --sample-length.
"""
@doc "The Enum.take_random is using reservoir sampling."
def main(args) do
parse_args(args) |> read_stdio_and_take_random |> IO.write
end