Skip to content

Instantly share code, notes, and snippets.

View vzarytovskii's full-sized avatar
🐱
Slacking

Vlad Zarytovskii vzarytovskii

🐱
Slacking
View GitHub Profile
@vzarytovskii
vzarytovskii / gist:1375984
Created November 18, 2011 09:20
Randomize phrase
#!perl
use warnings 'all';
use strict;
use diagnostics;
my $phrase = '{Пожалуйста|Просто} сделайте так, чтобы это {удивительное|крутое|простое} тестовое предложение {изменялось {быстро|мгновенно} случайным образом|менялось каждый раз}';
my $regex;
my (@match);
my $idx = 0;
$regex = qr/\{((?:[^{}]+|(??{$regex}))*)\}(?{$match[$idx++]=$1;})/s;
(function (window,undefined) {
var Interface = function(interface) { return interface };
Object.prototype.clone = function () {
var o = this;
if(!o || "object" !== typeof o)
return o;
var c = "function" === typeof o.pop ? [] : {};
var p, v;
for(p in o) {
if(o.hasOwnProperty(p)) {
var Stemmer = function ( word ) {
var _re = /^(разо|надо|недо|подо|пред|предо|без|бес|взо|изо|над|обо|ото|под|пра|про|до|за|на|вы|во|ко|об|не|от|па|по|су|в|о)?(.*?)(ствова|ичес|льник|льщик|льщиц|итель|тельн|анин|еват|оват|енск|инск|овит|ский|ость|янин|ение|еств|есть|тель|нича|изм|ниц|изн|ник|ист|ени|ниe|ств|чик|чиц|щик|ошк|ушк|ёшк|ышк|юшк|аст|овый|енн|онн|лив|ейш|айш|жды|учи|ючи|чив|чат|ева|ова|ыва|ива|еет|ин|то|ец|ун|ан|ян|ач|иц|их|ия|лк|ик|ни|ал|ит|ат|ев|ов|ив|ен|уч|юч|яч|шн|от|нн|ил|к|а|c|ы|и(^иб))(.*)?$/gi;
this.wordForm = word.toLowerCase();
this.Type = function () { return typeof this.wordForm }
this.getRoot = function () { return this.wordForm.match("/a-z0-9/i") ? this.wordForm : this.wordForm.replace(_re,"$2"); }
}
var res = new Stemmer('турист');
alert(res.getRoot());
#include <iostream>
#include <complex>
#include <vector>
#include <omp.h>
using namespace std;
int main() {
int number_to = 1000000;
vector<int> primes;
#!perl
use warnings;
use strict;
use MR::Tarantool::Box;
my $params = {
account => '[email protected]',
application => 'mail',
--- ~/dbd-pg-hstore » make test
cp lib/Pg/hstore.pm blib/lib/Pg/hstore.pm
/opt/local/bin/perl /opt/local/lib/perl5/5.12.4/ExtUtils/xsubpp -typemap /opt/local/lib/perl5/5.12.4/ExtUtils/typemap hstore.xs > hstore.xsc && mv hstore.xsc hstore.c
/usr/bin/clang -c -I. -pipe -O2 -fno-common -DPERL_DARWIN -I/opt/local/include -no-cpp-precomp -fno-strict-aliasing -fstack-protector -I/opt/local/include -O3 -DVERSION=\"1.02\" -DXS_VERSION=\"1.02\" "-I/opt/local/lib/perl5/5.12.4/darwin-thread-multi-2level/CORE" hstore.c
clang: warning: argument unused during compilation: '-no-cpp-precomp'
hstore.xs:70:13: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while( ent = hv_iternext(hash) ) {
~~~~^~~~~~~~~~~~~
hstore.xs:70:13: note: place parentheses around the assignment to silence this warning
while( ent = hv_iternext(hash) ) {
#include <stdio.h>
#include <netinet/in.h>
#include <ev.h>
#define PORT_NO 3033
#define BUFFER_SIZE 1024
int total_clients = 0;
void accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents);
#include <stdio.h>
#include <netinet/in.h>
#include <ev.h>
#define IP 127.0.0.1
#define PORT_NO 3033
#define BUFFER_SIZE 1024
#define TIMER 5.5 // Timer to free some threads queue, in seconds
#!/usr/bin/perl
use Data::Dumper;
$LOVE= AMOUR.
true.cards. ecstacy.crush
.hon.promise.de .votion.partners.
tender.truelovers. treasure.affection.
devotion.care.woo.baby.ardor.romancing.
enthusiasm.fealty.fondness.turtledoves.
#!perl
use warnings;
use strict;
my $x = [1,2,3];
my $y = [2,3,4];
my $t = [3,4,5];
sub substract {
my @arrays = @_;