Skip to content

Instantly share code, notes, and snippets.

@nazartm
nazartm / transliterator.py
Created October 7, 2022 15:03
Transliterates from cyrillic turkmen alphabet to latin turkmen alphabet
import re
import sys
special_cases = [r'(Ё|Ю|Я)\.', r'(\s)Е\.', r'(\s)е', r'(\s)Е', r'(\s)?("|«|“)е', r'(\s)?("|«|“)Е', r'^Е', r'^е']
special_case_mappings= ['Ý.', r'\1Ý.', r'\1ýe', r'\1Ýe', r'\1\2ýe', r'\1\2Ýe', 'Ýe', 'ýe']
turkmen_cyrillic_lc = ("а", "б", "в", "г", "д", "ъе", "е", "ё", "ж", "җ", "з", "и", "й", "к", "л", "м", "н", "ң", "о", "ө", "п", "р", "с", "т", "у", "ү", "ф", "х", "ц", "ч", "ш", "щ", "ъ", "ы", "ь", "э", "ә", "ю", "я")
turkmen_latin_lc = ("a", "b", "w", "g", "d", "ýe", "e", "ýo", "ž", "j", "z", "i", "ý", "k", "l", "m", "n", "ň", "o", "ö", "p", "r", "s", "t", "u", "ü", "f", "h", "s", "ç", "ş", "ş", "", "y", "", "e", "ä", "ýu", "ýa")
turkmen_cyrillic_uc = ("А", "Б", "В", "Г", "Д", "ъе", "Е", "Ё", "Ж", "Җ", "З", "И", "Й", "К", "Л", "М", "Н", "Ң", "О", "Ө", "П", "Р", "С", "Т", "У", "Ү", "Ф", "Х", "Ц", "Ч", "Ш", "Щ", "Ъ", "Ы", "Ь", "Э", "Ә", "Ю", "Я")
@nazartm
nazartm / add_actions_secret.py
Last active January 24, 2023 09:17
Python script for adding Actions secrets to a Github repository
from base64 import b64encode
from nacl import encoding, public
import requests
MY_PAC = ''
ORG = 'MyOrg'
REPO = 'repo'
secrets = {
'TOOL_USER': 'admin',
#!/bin/bash
# usage `source assume_role.sh prod token`
unset AWS_ACCESS_KEY_ID
unset AWS_SECRET_ACCESS_KEY
unset AWS_SESSION_TOKEN
if (( $# != 2 )); then
echo "Two arguments are required: profile and token"
exit 1
@nazartm
nazartm / InstallCert.java
Created April 24, 2019 08:06
InstallCert for installing a certificate to trustore
/*
* Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
@nazartm
nazartm / import.sh
Created April 24, 2019 08:02
Import RDS certificates to truststore
#!/bin/sh -e
# create a temp dir in which to work
OLDDIR="$PWD"
mkdir /tmp/rds-ca && cd /tmp/rds-ca
# download the bundle
wget https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem
# split the bundle into individual certs (prefixed with xx)
csplit -sz rds-combined-ca-bundle.pem '/-BEGIN CERTIFICATE-/' '{*}'
@Path("/blog")
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, "application/vnd.blog.v2+xml", "application/vnd.blog.v2+json"})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, "application/vnd.blog.v2+xml", "application/vnd.blog.v2+json"})
public interface BlogRestfulService {
...
}
@Path("/blog")
@Consumes({"application/vnd.blog.v2+xml", "application/vnd.blog.v2+json"})
@Produces({"application/vnd.blog.v2+xml", "application/vnd.blog.v2+json"})
public interface BlogRestfulService {
...
}
@Consumes({"application/vnd.blog.v1+xml", "application/vnd.blog.v1+json"})
@Produces({"application/vnd.blog.v1+xml", "application/vnd.blog.v1+json"})
public interface BlogRestfulService {
@GET
@Path("/posts")
List<Post> getPosts();
@GET
@Path("/post/{id}")
@nazartm
nazartm / Configuration.java
Last active December 16, 2015 05:09
Environment configuration property injection using CDI
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.util.Nonbinding;
import javax.inject.Qualifier;
@Qualifier
@Retention(RUNTIME)
@Target({METHOD, FIELD, PARAMETER, TYPE})
public @interface Configuration {
@Nonbinding
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="tutorial"/>
<bean id="org.dozer.Mapper" class="org.dozer.DozerBeanMapper"/>