Skip to content

Instantly share code, notes, and snippets.

mport System.Environment
import System.Directory
import Control.Monad
import Data.List
import Control.Applicative
import qualified Data.ByteString.Char8 as L
import qualified Data.ByteString as B
import System.IO
import System.IO.Error
@varnie
varnie / fix_broken_format_css_files
Created January 21, 2014 16:55
fix broken/ill-formatted CSS file
perl -00 -i.bak -pe 's/\s+//g; s/\}/\}\n/g ' test_data.css
#!/usr/bin/perl
use Carp qw(croak);
use 5.010;
use Test::Simple tests => 6;
use strict;
use warnings;
sub to_roman {
@varnie
varnie / JAPH
Last active December 18, 2015 17:09
#!/usr/bin/perl
use strict;
use warnings;
my$k='my@a=((-4
,26,10,-4,-104,-
56,-61,-79,-94,-
127,-152,-162,-
268,-245,-250,-
264,-298,-403,-
361,-399,-429,-
#prints values from 1 to 10 inclusively
1: v : <
5
2
*
`
@ _ :.:1+ ^
@varnie
varnie / smartTextCutting.sql
Created April 12, 2012 20:05
Smart text trimming procedure in PostgreSQL
CREATE OR REPLACE FUNCTION th.prc_th_rate_titles_create()
RETURNS integer AS
$BODY$
DECLARE
p_title VARCHAR := '';
p_sql VARCHAR := '';
p_item RECORD;
total_rows INTEGER := 0;
BEGIN
p_sql := 'SELECT id, comment, title FROM th.th_rates';
@varnie
varnie / changeColorUsingEmbeddedJS.html
Created September 9, 2011 12:14
an example of changing a style of td using embedded js
<html>
<head>
<title>change color using embedded javascript</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<style>
table .c { color: red }
.a.c {color: green}
</style>
@varnie
varnie / changeTdStyleUsingPrototype.html
Created September 9, 2011 04:40
an example of changing a style of td using prototype js
<html>
<head>
<title>getElementById example#3</title>
<style>
table .c { color: red }
.a.c {color: green}
</style>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
@varnie
varnie / someQueries.sql
Created September 8, 2011 17:32
several SQLs
1) SELECT * FROM category c WHERE c.parent_category_id IS NULL AND name LIKE 'авто%';
2) SELECT * FROM category c1 WHERE (SELECT COUNT(c2.id) FROM category c2 WHERE c2.parent_category_id = c1.id
AND c2.id NOT IN (SELECT parent_category_id FROM category c3 WHERE parent_category_id IS NOT NULL)
) BETWEEN 1 AND 3;
3)
SELECT * FROM category с1 LEFT JOIN category с2 ON с1.id = с2.parent_category_id WHERE с2.id IS NULL
or:
SELECT * FROM category AS c1 WHERE NOT EXISTS (SELECT id FROM category AS c2 WHERE c1.id = c2.parent_category_id);
@varnie
varnie / changeTdStyleUsingJquery.html
Created September 8, 2011 11:10
an example of changing a style of td using JQuery
<html>
<head>
<title>getElementById example</title>
<style>
table .c { color: red }
.a.c {color: green}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>