Skip to content

Instantly share code, notes, and snippets.

View lines_count.hs
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 Jan 21, 2014
fix broken/ill-formatted CSS file
View fix_broken_format_css_files
perl -00 -i.bak -pe 's/\s+//g; s/\}/\}\n/g ' test_data.css
View to_roman.pl
#!/usr/bin/perl
use Carp qw(croak);
use 5.010;
use Test::Simple tests => 6;
use strict;
use warnings;
sub to_roman {
View JAPH
#!/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,-
View Befunge!
#prints values from 1 to 10 inclusively
1: v : <
5
2
*
`
@ _ :.:1+ ^
@varnie
varnie / smartTextCutting.sql
Created Apr 12, 2012
Smart text trimming procedure in PostgreSQL
View smartTextCutting.sql
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 Sep 9, 2011
an example of changing a style of td using embedded js
View changeColorUsingEmbeddedJS.html
<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 Sep 9, 2011
an example of changing a style of td using prototype js
View changeTdStyleUsingPrototype.html
<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>
View someQueries.sql
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 Sep 8, 2011
an example of changing a style of td using JQuery
View changeTdStyleUsingJquery.html
<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>
You can’t perform that action at this time.