Skip to content

Instantly share code, notes, and snippets.

Avatar

Serge Shirokov kurokikaze

View GitHub Profile
View test.js
/**
* 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 Oct 3, 2014
install chrome from powershell
View gist:350fe1713591641b3b42
(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 Apr 4, 2014
Получает с togif.me гифки с кол-вом просмотров и выдает в stdout в виде csv
View togif.py
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 Aug 29, 2015
Переработка текстовых экспортированных кубов с CubeTutor в формат, подходящий для SPMF
View process.py
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 Dec 22, 2015
Получает текущий CPS по номеру варианта (0 - курсор, 1 - бабушка и т.д.) и цену следующего айтема по номеру.
View getCPS.js
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 Dec 2, 2011
Алгоритм Тезея для черепашки: http://www.kurilo.su/programmers/
View theseus.js
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 Oct 26, 2011
Calculate dividends per share price and dividends per portfolio value on EmpireAvenue
View gist:1316636
$('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 Sep 30, 2011
Remove comments from Go/C program (simple way)
View removecomment.go
package main
import bufio "bufio"
import fmt "fmt"
import os "os"
func main() {
var state = "0"
var cache = " "
View server.js
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 Jan 26, 2011
Websocket 76 opening handshake demo for Node.js
View test.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);
You can’t perform that action at this time.