Skip to content

Instantly share code, notes, and snippets.

View mishin's full-sized avatar
💭
if you fail to prepare you prepare to fail

Nikolay Mishin mishin

💭
if you fail to prepare you prepare to fail
View GitHub Profile
@mishin
mishin / Google2Translate.java
Created August 28, 2013 12:07
run perl from java in OmegaT
/**************************************************************************
OmegaT - Computer Assisted Translation (CAT) tool
with fuzzy matching, translation memory, keyword search,
glossaries, and translation leveraging into updated projects.
Copyright (C) 2010 Alex Buloichik, Didier Briel
2011 Briac Pilpre, Alex Buloichik
Home page: http://www.omegat.org/
Support center: http://groups.yahoo.com/group/OmegaT/
# Written by Olivier Mengué
use utf8;
use strict;
use warnings;
use AnyEvent;
use AnyEvent::HTTP;
my @urls = qw(
# Alternate implementation of https://metacpan.org/module/STEVAN/Promises-0.03/lib/Promises/Cookbook/TIMTOWTDI.pod
# that can run the requests in parallel
# See also a more concrete application of this: https://gist.github.com/dolmen/6306377
my $all_product_info = {};
my $cv = AnyEvent->condvar;
$cv->begin;
http_get('http://rest.api.example.com/-/product/12345', sub {
function getFileExtension(i) {
// i will be a string, but it may not have a file extension.
// return the file extension (with no period) if it has one, otherwise false
var pat1= /(.*\.)(\w+)/i;
if (i.match(pat1)){
//alert( i.replace( /(.*\.)(\w+)/i ,'$2') ) ;
var out=i.replace( pat1 ,'$2') ;
alert(out);
function longestString(i) {
// i will be an array.
// return the longest string in the array
var max_elem='';
for(j=i.length; --j;){
if (typeof i[j] == 'string' && i[j].length>max_elem.length){
max_elem=i[j];
}
}
@mishin
mishin / css_parser.pl
Last active August 29, 2015 14:06 — forked from wki/css_parser.pl
use strict;
use warnings;
use feature ':5.10';
use Marpa::XS;
use Data::Dumper;
#
# a simple CSS snippet for testing
#
my $text = q{
@mishin
mishin / css_parser.pl
Last active August 29, 2015 14:06 — forked from wki/css_parser.pl
use strict;
use warnings;
use feature ':5.10';
use Marpa::XS;
use Data::Dumper;
#
# a simple CSS snippet for testing
#
my $text = q{
@mishin
mishin / gtrans.pl
Last active August 29, 2015 14:06 — forked from jl2/gtrans.pl
#!/usr/bin/perl
# By: Jeremiah LaRocco
# Use translate.google.com to translate between languages.
# Sample run:
# gtrans.pl --to french --from english This is a test
# Ceci est un test
#
use strict;
@mishin
mishin / gtrans2.pl
Last active August 29, 2015 14:06 — forked from ruz/gtrans2.pl
#!/usr/bin/env perl
# By: Jeremiah LaRocco, Nikolay Mishin (refactoring)
# Use translate.google.com to translate between languages.
# Sample run:
#gtrans.pl --from en --to ru --text "This is a test"
use Modern::Perl;
use LWP::UserAgent;
use Getopt::Long;
#!/usr/bin/env perl
use strict;
use warnings;
use Carp;
use Getopt::Long;
use Pod::Usage;
use File::Basename qw/fileparse/;
use File::Spec;
use Spreadsheet::ParseExcel;