Skip to content

Instantly share code, notes, and snippets.

View tsyber1an's full-sized avatar
🎯
Focusing

Tsyren O. tsyber1an

🎯
Focusing
View GitHub Profile
var drawCharWithInfo = function(base, dataset){
$(base+" > .total.counters > .ways span").html(dataset.length);
$(base+" > .total.counters > .searches span").html(get_count_by(dataset, 'x'));
drawBarChart(base+" > .ways", dataset);
};
var drawBarChart = function(container, dataset){
@tsyber1an
tsyber1an / Cakefile
Created March 21, 2013 11:15
cakefile for js
fs = require 'fs'
{print} = require 'sys'
{exec} = require 'child_process'
{spawn} = require 'child_process'
option '-o', '--output [DIR]', 'output dir'
task 'minify', 'Minify mongo production scripts', ->
exec 'uglifyjs --overwrite lib/mongo/lib/*.js', (err, stdout, stderr) ->
class @LogsMapReduce extends MapReduce
constructor: ->
super("logs", "statistics")
@init()
init: ->
@before()
@map_reduce()
@after()
@tsyber1an
tsyber1an / random_helper.js
Created April 16, 2013 08:08
javascript random helpers
function getRandomArbitary(min, max)
{
return Math.random() * (max - min) + min;
}
function getRandomInt(min, max)
{
return Math.floor(Math.random() * (max - min + 1)) + min;
}
@tsyber1an
tsyber1an / cut_to_cyrcle.rb
Created April 18, 2013 11:51
make my images cyrcled
require 'rubygems'
require 'RMagick'
include Magick
def cut_to_cyrcle(path_to_image)
folder = path_to_image.split('/')[0..-2].join('/')
name = path_to_image.split('/').last.split('.')[0]
puts "Trying open #{path_to_image}"
@tsyber1an
tsyber1an / hash.rb
Last active December 16, 2015 14:49
Group hash elements by count with some conditions
class Hash
def group_by_count
group = []
i = 0
max = self.values.max
sorted = self.sort{|a, b| a[1] <=> b[1] }
sorted.each do |k,v|
group[i] ||= []
@tsyber1an
tsyber1an / paticular_unique.rb
Created April 29, 2013 12:49
paticular unique
[[['a', 1], ['b',2], ['c',3]], [['b',2],['a',1],['c',3]], [['c',1], ['a',4], ['b',2]]].uniq{|e| e.sort_by{|l| l.first }.map{|l| l.first }.join('') }
# => [[["a", 1], ["b", 2], ["c", 3]]]
@tsyber1an
tsyber1an / mongo.rake
Last active December 17, 2015 06:39
Mongo rake helpers for testing
namespace :mongo do
task :prepare_fixtures do
fixtures_base = "spec/mongo/fixtures"
Dir.entries("#{fixtures_base}/coffeescript").each do |file|
if !['..', '.'].include?(file) and file.split('.')[1] == 'coffee'
system "coffee -b -o #{fixtures_base}/javascript -c #{fixtures_base}/coffeescript/#{file} "
end
end
end
@tsyber1an
tsyber1an / .bash_profile
Last active December 17, 2015 06:48
My dotfiles
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# add local bin path
PATH=$HOME/.bin:$PATH
PATH=/usr/local/bin:$PATH
PATH=/usr/local/sbin:$PATH
PATH=/usr/local/mysql/bin:$PATH
# don't put duplicate lines in the history
@tsyber1an
tsyber1an / for_elya.vbs
Created May 29, 2013 10:39
for_elya.vbs
SetLocale(1049)
msgBox GetLocale()
Dim i, j
Dim diagonalMean, mini, maxi, matrix_dim, printMessage
printMessage = ""
matrix_dim = 3 ' считаем с нуля
diagonalMean = 0
mini = 0