Skip to content

Instantly share code, notes, and snippets.

/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
const S = readline();
// Write an answer using console.log()
// To debug: console.error('Debug messages...');
console.error(S)
@kurokikaze
kurokikaze / gist:350fe1713591641b3b42
Created October 3, 2014 11:40
install chrome from powershell
(new-object System.Net.WebClient).DownloadFile('http://dl.google.com/chrome/install/375.126/chrome_installer.exe', 'c:/temp/chrome.exe');. c:/temp/chrome.exe /silent /install;rm c:/temp -rec
@kurokikaze
kurokikaze / togif.py
Created April 4, 2014 07:31
Получает с togif.me гифки с кол-вом просмотров и выдает в stdout в виде csv
from bs4 import BeautifulSoup
from urllib2 import urlopen
from urlparse import urljoin
import re
for num in range(1, 150):
url = "http://togif.me/catalog/" + str(num)
res = urlopen(url)
soup = BeautifulSoup(res.read())
links = soup.select('td a')
@kurokikaze
kurokikaze / process.py
Last active August 29, 2015 13:56
Переработка текстовых экспортированных кубов с CubeTutor в формат, подходящий для SPMF
import re, os
from random import shuffle
r_unwanted = re.compile("[\n\t\r]")
r_file = re.compile("cube([\d]+).txt") # шаблон имени файла
dic = dict()
num = 1000 # с чего начинаем нумерацию карт
censored = ["Temple Garden",
"Blood Crypt",
@kurokikaze
kurokikaze / getCPS.js
Last active December 22, 2015 08:49
Получает текущий CPS по номеру варианта (0 - курсор, 1 - бабушка и т.д.) и цену следующего айтема по номеру.
var getCPS = function(num) {
var text = document.getElementById('rowInfoContent' + num.toString()).innerText.split('\n');
var count = parseInt(text[0].replace(/,/g, '').match(/\s(\d+)\s/)[1]);
var production = parseFloat(text[1].replace(/,/g, '').match(/\s([\d,.]+)\s/)[1]);
return production/count;
}
var getPrice = function(num) {
return parseInt(document.getElementById('product' + num.toString()).children[1].children[1].innerText.replace(/,/g,''))
}
@kurokikaze
kurokikaze / theseus.js
Created December 2, 2011 13:38
Алгоритм Тезея для черепашки: http://www.kurilo.su/programmers/
var dirs = {'north':0,'east':1,'south':2,'west':3};
var names = ['north','east','south','west'];
var obs = {'north':north,'south':south,'west':west,'east':east};
result='east';
if (!direction) direction = 'east';
var left = function() {
return names[(dirs[direction] + 3) % 4];
};
@kurokikaze
kurokikaze / gist:1316636
Created October 26, 2011 15:09
Calculate dividends per share price and dividends per portfolio value on EmpireAvenue
$('div.item').find('li').each(function(i, el) {
var price = parseFloat($(el).find('span.float-right.large').eq(0).text().split(' ')[0]);
var dividend = $(el).find('span.portfolio-meta').eq(0).text();
var pattern = /Last Dividend: ([\d\.]+)/
var pattern_pval = /Portfolio Value:\s([\d\.,]+)e/
var nums = dividend.match(pattern);
if (nums) {
var divperprice = parseFloat(nums[1]) / price;
console.log('Dividend per price for ' + $(el).find('div.influencer-portrait').find('a').eq(0).attr('href') + ': ' + divperprice);
}
@kurokikaze
kurokikaze / removecomment.go
Created September 30, 2011 16:27
Remove comments from Go/C program (simple way)
package main
import bufio "bufio"
import fmt "fmt"
import os "os"
func main() {
var state = "0"
var cache = " "
@kurokikaze
kurokikaze / server.js
Created February 26, 2011 20:32
Delaying proxy, xkcd-style http://wp.me/pfjwm-me
var oc = function(a) {
var o = {};
for(var i=0;i<a.length;i++) {
o[a[i]]='';
}
return o;
}
var http = require('http'),
url = require('url'),
@kurokikaze
kurokikaze / test.js
Created January 26, 2011 15:25
Websocket 76 opening handshake demo for Node.js
var crypto = require('crypto');
var key1 = 155712099;
//var key1 = 829309203;
var key2 = 173347027;
// var key2 = 259970620;
//var sign = '^n:ds[4U';
var sign = 'Tm[K T2u';
function intToBigEndian(intstr){
var st = new Buffer(4);