This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bufferedDelay = (function () { | |
var delays = {}; | |
return function (alias, delay, callback) { | |
if (delays[alias]) { | |
clearTimeout(delays[alias]); | |
} | |
delays[alias] = setTimeout(function () { delete delays[alias]; callback(); }, delay); | |
} | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() { | |
char * str { "Hello" }; | |
int * int_hz = (int *) str; | |
cout << str << endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET @from_loc := 'ChIJ2aunYmllQTQRntXu6lNDlCU'; | |
SET @to_loc := 'ChIJ-yRniZpWPEURE_YRZvj9CRQ'; | |
START TRANSACTION; | |
# получение начальных данных | |
SELECT id, path, `level` INTO @from_id, @from_path, @from_level FROM locations WHERE place_id = @from_loc; | |
SELECT id, path, `level` INTO @to_id, @to_path, @to_level FROM locations WHERE place_id = @to_loc; | |
SET @new_path := CONCAT(@to_path, @to_id, ','); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogumbo' | |
require 'uri' | |
def print_parents visited, path | |
parent = path | |
while parent = visited[parent] | |
puts "parent: %s" % URI.unescape(parent) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
использовать: | |
stopwatch 'parsing' do | |
# код, производительность которого надо замерять | |
end | |
=end | |
def stopwatch message, &block |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def detect_language words | |
if Array(words).any? { |w| w =~ /\p{Cyrillic}/ } | |
364 | |
elsif Array(words).any? { |w| w =~ /\p{Hangul}/ } | |
0 # тут корейский код, неебу какой | |
else | |
124 | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def more_than_medium string | |
words = string.split /\W+/ | |
return [] if words.empty? | |
avg = words.inject(0) { |res, w| res += w.size; res } / words.size | |
words.select { |w| w.size > avg } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PS1='\[\e[1;37m\]⌞ \[\e[1;32m\]\u\[\e[0;39m\]@\[\e[1;36m\]\h\[\e[0;39m\]:\[\e[1;33m\]\w\[\e[0;39m\]\[\e[1;35m\]$(__git_ps1 " (%s)")\[\e[0;39m\] \[\e[1;37m\]⌝\[\e[0;39m\]\n$ ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Benchmark = require('benchmark'); | |
var suite = new Benchmark.Suite; | |
// add tests | |
suite.add('lowercase', function() { | |
let input = 'ai'; | |
let dictionary = ['airplane','airport','apple','ball']; | |
var clean_str = input.replace(/[^a-z]+/gi,'').toLowerCase(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var OUTPUT_DIR = 'pics'; | |
var fs = require('fs'); | |
if (!fs.exists(OUTPUT_DIR)) { | |
fs.makeDirectory(OUTPUT_DIR); | |
} | |
var casper = require('casper').create({ | |
verbose: true, |
OlderNewer