Skip to content

Instantly share code, notes, and snippets.

@petr999
petr999 / hackerrank-solutions.sh
Last active March 28, 2021 10:09
400+ hackerrank's tasks solutions download
#!/bin/sh
#
# ABSTRACT: use 'ls | grep' to find your particular hackerrank's task solution)
### MAIN ###
#
# URLs found in curl(1) output can be used as a reference to seek for a particular task to solve as files' names are quite descriptive
curl 'https://www.blogger.com/feeds/8068649101764775888/posts/default?max-results=500' \
| perl -Mstrict -nwE 'say join "\n" => m{href='"'"'(https://programs.programmingoneonone.com[^'"'"']*\.html)'"'"'}g;' \
| wget -i -
@petr999
petr999 / index.js
Last active March 21, 2021 20:17
matrix path walkthrough: 0's are no, 1's are go
// ABSTRACT: find route or single short diagonal route
// Returns 2d-array filled with falses
function getArrOfFalses( arr ){
let rv = []
arr.forEach( ( row, i ) => {
let rowRv = []
row.forEach( ( col, j ) => {
rowRv.push( false )
@petr999
petr999 / gist:1364021
Created November 14, 2011 14:13
commits filter doesn't detach history
$ mkdir test00 && cd test00
$ git init && dd if=/dev/random bs=1m count=1 > test00.txt && git add test00.txt && git commit -a -m init
Initialized empty Git repository in /tmp/test01/test00/.git/
1+0 records in
1+0 records out
1048576 bytes transferred in 0.072885 secs (14386712 bytes/sec)
[master (root-commit) 4a45d69] init
1 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 test00.txt
$ dd if=/dev/random bs=1m count=1 >> test00.txt && git commit -a -m 'commit 00'
$ rm -rf .git test00.txt [2/69]
$ dd if=/dev/random bs=1m count=1 >> test00.txt
1+0 records in
1+0 records out
1048576 bytes transferred in 0.070135 secs (14950799 bytes/sec)
$ ls -l
total 1032
-rw-r--r-- 1 meme wheel 1048576 13 ноя 18:38 test00.txt
$ git init
Initialized empty Git repository in /tmp/test00/.git/
--- showdependencygraph.cgi.orig
+++ showdependencygraph.cgi
@@ -269,6 +269,8 @@
print $pngfh $_ while <DOT>;
close DOT;
close $pngfh;
+
+ chmod( 0644, $pngfilename ) or die $!;
# On Windows $pngfilename will contain \ instead of /
1..15
ok 1
ok 2
ok 3 - testing quoting of utf 8 string
ok 4 - testing quoting of blob
ok 5 - INSERT query INSERT INTO t1 (name, bincol, shape, binutf)
# VALUES (?,?, GeomFromText('Point(132865 501937)'), ?)
#
#
ok 6
1..15
ok 1
ok 2
ok 3 - testing quoting of utf 8 string
ok 4 - testing quoting of blob
ok 5 - INSERT query INSERT INTO t1 (name, bincol, shape, binutf)
# VALUES (?,?, GeomFromText('Point(132865 501937)'), ?)
#
#
ok 6
--- bugzilla.orig/createaccount.cgi 2010-01-09 20:41:47.727879656 +0400
+++ bugzilla/createaccount.cgi 2010-01-16 15:27:08.947848543 +0400
@@ -47,6 +47,10 @@
$vars->{'doc_section'} = 'myaccount.html';
+my $captcha_cookie = $cgi->cookie( 'Captcha_cookie' );
+unless( length $captcha_cookie ){ $captcha_cookie = generate_random_password; }
+$cgi->send_cookie( -name => 'Captcha_cookie', -value => $captcha_cookie, );
+
#!/usr/bin/perl
package main;
use strict;
use warnings;
use POSIX qw/setsid/;
use Readonly;
perl -Mstrict -MFile::Find -MConvert::Cyrillic -MFile::Copy -MFile::Basename -we 'my @names = (); find sub{ push @names, $File::Find::name }, "Ноль"; map { my $newname = dirname( $_ ). "/". Convert::Cyrillic::cstocs( "WIN", "UTF8", basename $_ ); print $newname, "\n"; File::Copy::mv( $_, $newname ) or die $!; } reverse @names; '