Skip to content

Instantly share code, notes, and snippets.

View Amice13's full-sized avatar

Kyrylo Zakharov Amice13

View GitHub Profile
@Amice13
Amice13 / Ukrainian.EXCEL.yaml
Created November 9, 2022 16:58
Proper Ukrainian Transliteration
name: Ukrainian
description: Proper Ukrainian Transliteration
host: EXCEL
api_set: {}
script:
content: |
var latin = /[ABCEHIKMOPTXaceiopyx]/g;
var latinToCyrillic = {
A: "А",
B: "В",
@Amice13
Amice13 / Alternative.R
Last active January 5, 2022 00:41
Visualization of statistical hypothesis testing by Ruslana Moskotina (Refactoring)
# Include necessary libraries
library(foreign)
library(igraph)
library(ggraph)
# Download data here
# https://www.europeansocialsurvey.org/download.html?file=ESS6UA&c=UA&y=2012
dataESS <- read.spss('ESS6UA.sav', to.data.frame = T)
@Amice13
Amice13 / checkIPN.js
Created December 27, 2020 14:18
Перевірка ІПН
const mult = [-1, 5, 7, 9, 4, 6, 10, 5, 7]
const sourceDate = new Date('1899-12-31')
const checkIPN = str => {
const daysSinceBirthday = parseInt(str.slice(0, 5))
let birthday = new Date(sourceDate).setDate(sourceDate.getDate() + daysSinceBirthday + 1)
birthday = new Date(birthday)
const sex = parseInt(str.slice(8,9)) % 2 === 0 ? 'Жінка' : 'Чоловік'
const numbers = str.slice(0,9).split('').map(el => parseInt(el))
const checkSum = numbers.reduce((acc, val, i) => acc + val * mult[i], 0) % 11 % 10
@Amice13
Amice13 / drv_curl_examples.sh
Last active February 3, 2023 23:26
Запросы в CURL для данных Реестра избирателей
# Человекочитаемое описание результатов запроса здесь: https://www.drv.gov.ua/ords/portal/!cm_core.cm_index?option=ext_static_page&ppg_id=262&pmn_id=161
# Получение данных про органы распорядителей и ведения Реестра избирателей
curl --header "Content-Type: text/xml;charset=UTF-8" --data "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:drv=\"http://www.drv.gov.ua/\"><soap:Header/><soap:Body><drv:GetOrgansService /></soap:Body></soap:Envelope>" https://www.drv.gov.ua/ords/svc/personal/API/Opendata
# Получение данных про избирательные округи
curl --header "Content-Type: text/xml;charset=UTF-8" --data "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:drv=\"http://www.drv.gov.ua/\"><soap:Header/><soap:Body><drv:GetAreas /></soap:Body></soap:Envelope>" https://www.drv.gov.ua/ords/svc/personal/API/Opendata
# Получение данных про избирательные участки. Необходимо менять параметр Area (получаются из сервиса GetAreas)
curl --header "Content-Type: text/xml;charse
@Amice13
Amice13 / gist
Created May 16, 2018 13:55
some gist
{
"drv" : {
"aliases" : { },
"mappings" : {
"drv" : {
"properties" : {
"ATOCode" : {
"type" : "keyword"
},
"all" : {
@Amice13
Amice13 / topicmodels_json_ldavis.R
Created September 9, 2016 07:23 — forked from christophergandrud/topicmodels_json_ldavis.R
Convert the output of a topicmodels Latent Dirichlet Allocation model to JSON for use with LDAvis
#' Convert the output of a topicmodels Latent Dirichlet Allocation to JSON
#' for use with LDAvis
#'
#' @param fitted Output from a topicmodels \code{LDA} model.
#' @param corpus Corpus object used to create the document term
#' matrix for the \code{LDA} model. This should have been create with
#' the tm package's \code{Corpus} function.
#' @param doc_term The document term matrix used in the \code{LDA}
#' model. This should have been created with the tm package's
#' \code{DocumentTermMatrix} function.
@Amice13
Amice13 / ajaxListener.js
Created August 31, 2016 12:32 — forked from icodejs/ajaxListener.js
JS: Listen to ajax calls from Javascript
var open = window.XMLHttpRequest.prototype.open,
send = window.XMLHttpRequest.prototype.send,
onReadyStateChange;
function openReplacement(method, url, async, user, password) {
var syncMode = async !== false ? 'async' : 'sync';
console.warn(
'Preparing ' +
syncMode +
' HTTP request : ' +
@Amice13
Amice13 / README.md
Created April 21, 2016 07:47 — forked from emeeks/README.md
An online tool for interactive teaching of network visualization and representation principles.

The range sliders at the top change the values for the force-directed algorithm and the buttons load new graphs and apply various techniques. This will hopefully serve as a tool for teaching network analysis and visualization principles during my Gephi courses and general Networks in the Humanities presentations.

Notice this includes a pretty straightforward way to load CSV node and edge lists as exported from Gephi.

It also includes a pathfinding algorithm built for the standard data structure of force-directed networks in D3. This requires the addition of .id attributes for the nodes, however.

Now with Clustering Coefficients!

Also, it loads images for nodes but the images are not in the gist. The code also refers to different network types but the data files on Gist only refer to the transportation network.

read.gspreadsheet <- function(key) {
require(RCurl)
myCsv <- getURL(paste("https://docs.google.com/spreadsheet/pub?hl=en_US&hl=en_US&key=",
key, "&single=true&gid=0&output=csv", sep = ""),
.encoding = "UTF8")
read.table(textConnection(myCsv), header = T, sep = ",", stringsAsFactors = FALSE)
}