Skip to content

Instantly share code, notes, and snippets.

View dselivanov's full-sized avatar

Dmitry Selivanov dselivanov

View GitHub Profile
# converts slippy map XYZ tile to quadkey
# https://docs.microsoft.com/en-us/bingmaps/articles/bing-maps-tile-system
as_binary = function(x){
tmp = rev(as.integer(intToBits(x)))
id = seq_len(match(1, tmp, length(tmp)) - 1)
tmp[-id]
}
deg2num = function(lat_deg, lon_deg, zoom) {
server <- function(){
while(TRUE) {
writeLines("Listening...")
con <- socketConnection(host="localhost", port = 6011, blocking=TRUE,
server=TRUE, open="w+b")
writeLines("con done")
x = unserialize(con)
writeLines("readRDS done")
writeLines(capture.output(str(x)))
serialize(list(response = Sys.time(), x = x), con)
create_kafka_producer = function(topic, broker_list = "localhost:9092", open = "w") {
prodocer_cmd = "kafka-console-producer"
# kafka-console-producer --topic test2 --broker-list
kafka_pipe = sprintf("%s --topic %s --broker-list %s", prodocer_cmd, topic, broker_list)
pipe(kafka_pipe, open = open)
}
# con = create_kafka_producer("test2", open = "wb")
# writeLines("5", con)
# flush(con)
# close.connection(con)
d3 = function() {
var d3 = {
version: "3.2.7"
};
if (!Date.now) Date.now = function() {
return +new Date();
};
var d3_document = document, d3_documentElement = d3_document.documentElement, d3_window = window;
try {
d3_document.createElement("div").style.setProperty("opacity", 0, "");
@dselivanov
dselivanov / white-helv.css
Created November 23, 2016 16:09 — forked from SlavikBaranov/white-helv.css
Helvetica theme for RevealJS presentation
/**
* White theme for reveal.js. This is the opposite of the 'black' theme.
*
* By Hakim El Hattab, http://hakim.se
*/
section.has-dark-background, section.has-dark-background h1, section.has-dark-background h2, section.has-dark-background h3, section.has-dark-background h4, section.has-dark-background h5, section.has-dark-background h6 {
color: #fff; }
/*********************************************
* GLOBAL STYLES
d3 = function() {
var d3 = {
version: "3.2.7"
};
if (!Date.now) Date.now = function() {
return +new Date();
};
var d3_document = document, d3_documentElement = d3_document.documentElement, d3_window = window;
try {
d3_document.createElement("div").style.setProperty("opacity", 0, "");
d3 = function() {
var d3 = {
version: "3.2.7"
};
if (!Date.now) Date.now = function() {
return +new Date();
};
var d3_document = document, d3_documentElement = d3_document.documentElement, d3_window = window;
try {
d3_document.createElement("div").style.setProperty("opacity", 0, "");
d3 = function() {
var d3 = {
version: "3.2.7"
};
if (!Date.now) Date.now = function() {
return +new Date();
};
var d3_document = document, d3_documentElement = d3_document.documentElement, d3_window = window;
try {
d3_document.createElement("div").style.setProperty("opacity", 0, "");
d3 = function() {
var d3 = {
version: "3.2.7"
};
if (!Date.now) Date.now = function() {
return +new Date();
};
var d3_document = document, d3_documentElement = d3_document.documentElement, d3_window = window;
try {
d3_document.createElement("div").style.setProperty("opacity", 0, "");
d3 = function() {
var d3 = {
version: "3.2.7"
};
if (!Date.now) Date.now = function() {
return +new Date();
};
var d3_document = document, d3_documentElement = d3_document.documentElement, d3_window = window;
try {
d3_document.createElement("div").style.setProperty("opacity", 0, "");