February 2013
10 posts
hol vagyunk geci?!: How To Become a Hacker →
The basic difference is this: hackers build things, crackers break them. (…) Again, to be a hacker, you have to enter the hacker mindset. There are some things you can do when you’re not at a computer that seem to help. They’re not substitutes for hacking (nothing is) but many hackers do…
Feb 23rd
1 note
How To Ask Questions The Smart Way (by Eric S....
http://www.catb.org/esr/faqs/smart-questions.html Many project websites link to this document in their sections on how to get help. That’s fine, it’s the use we intended — but if you are a webmaster creating such a link for your project page, please display prominently near the link notice that we are not a help desk for your project! We have learned the hard way that without such a...
Feb 22nd
1 tag
On the cite element: “A person’s name is not the title of a work — even if people call that person a piece of work — and the element must therefore not be used to mark up people’s names.”
Feb 20th
1 note
Feb 18th
1 note
1 tag
“Because HTML conveys meaning, rather than presentation (…)”
Feb 16th
1 tag
HTML5 spec: URL creation and implementation
2.5.5 URL manipulation and creation To fragment-escape a string input, a user agent must run the following steps: Let input be the string to be escaped.Let position point at the first character of input. Let output be an empty string. Loop: If position is past the end of input, then jump to the step labeled end. If the character in input pointed to by position is in the range...
Feb 16th
1 tag
Why are most people from India idiots?
Because most of them can get offended in a sec even on genuine constructive criticism they can’t even get the context right too lazy to at least try http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/404387 ( the most annoying part is, that these idiots may only be 1% of their community but the uncivilized way of their behaviour just make all the stereotypes stronger)
Feb 16th
1 note
Ken Thompson - Reflections on Trusting Trust
“The moral is obvious. You can’t trust code that you did not totally create yourself. (Especially code from companies that employ people like me.)” http://cm.bell-labs.com/who/ken/trust.html
Feb 14th
1 note
1 tag
from HTML5 spec
1.7.1 How to read this specification This specification should be read like all other specifications. First, it should be read cover-to-cover, multiple times. Then, it should be read backwards at least once. Then it should be read by picking random sections from the contents list and following all the cross-references
Feb 14th
1 note
horgoldenembuzi: On Ruby on Rails security issues and on security in general
Feb 12th
1 note
January 2013
4 posts
1 tag
morse
MORSE_CODE = %w[.- -… -.-. -.….-. —. …. .. .—- -.- .-.. — -. —- .—. —.- .-. … - ..- …- .— -..- -.— —..] ENCODING   = Hash[(‘A’..’Z’).to_a.zip MORSE_CODE] gets.chomp.upcase.split(”).each { |c| print ENCODING[ c ], ” ” }
Jan 15th
Programming and Metaprogramming in the Human...
http://en.wikipedia.org/wiki/John_C._Lilly When one learns to learn, one is making models, using symbols, analogizing, making metaphors, in short, inventing and using language, mathematics, art, politics, business, etc. At the critical brain (cortex) size, languages and its consequences appear. To avoid the necessity of repeating learning to learn, symbols, metaphors, models each time, I...
Jan 12th
1 note
1 tag
Jan 11th
1 note
DCI and/or MVC?
best to read this this from the creators of both architecture: http://www.artima.com/articles/dci_vision.html
Jan 11th
November 2012
1 post
10 (?) things you didn't know ruby could do
https://speakerdeck.com/jeg2/10-things-you-didnt-know-ruby-could-do
Nov 1st
1 note
October 2012
1 post
3 tags
ruby: Hash of arrays idioms
http://www.lesismore.co.za/hasharrays.html
Oct 27th
August 2012
10 posts
4 tags
“It might be helpful to remember that, when defining methods, class_eval and...”
– Dave Thomas - Programming Ruby
Aug 29th
1 note
6 tags
some more self
module A   module ClassMethods         # methods here will become class methods     def class_method(name)   # once included        define_method(“#{name}”) do          puts “#class_method in #{self} created instance method #{name.inspect}”       end     end   end #  autoexecuted when mod A is included resulting: “A included in B”   def self.included(masik)  ...
Aug 28th
3 notes
4 tags
a little self
animal = “dog” def animal.speak   puts “The #{self} says WOOF!” end singleton = class « animal   def lie     puts “The #{self} lies down”   end   self     # « return singleton class object end animal.speak animal.lie puts “Singleton class object is #{singleton}” puts “It defines #{singleton.instance_methods  -  ...
Aug 26th
1 note
4 tags
Proc objects
raw procs are basically designed to work as the bodies of control structures such as loops. raw procs can be created by: —-> def meth( p1, p2, &block )        meth(1,2) { “balabab” } —-> block = Proc.new { “balabab” }  Lambdas are intended to act like methods. So, lambdas are stricter when checking the parameters passed to them, and a return in a...
Aug 25th
3 notes
3 tags
ruby aliases
When a method is aliased, the new name refers to a copy of the original method’s body and the aliased name will still invoke the original implementation. def meth      ”original method” end alias original meth def meth      ”new and improved” end meth    # => “new and improved” original # => “original method”
Aug 22nd
In the Beginning was the Command Line →
horgoldenembuzi: by Neal Stephenson About twenty years ago Jobs and Wozniak, the founders of Apple, came up with the very strange idea of selling information processing machines for use in the home. The business took off, and its founders made a lot of money and received the credit they deserved for being daring visionaries. But around the same time, Bill Gates and Paul Allen came up with an...
Aug 18th
2 notes
4 tags
&& in ruby regex
str = “now is the time” str.gsub(/[a-z&&[^aeiou]]/, ‘*’) OUTPUT: “*o* i* **e *i*e”
Aug 15th
4 tags
(g)sub and (g)sub!
(g)sub returns a new string every time ( in case of no match it returns the original string) (g)sub! on the other hand returns the modified string only if there’s been a match. eg. in conditionals: str = “the lion sleeps tonight” puts str if str.sub!( /lion/, “cat” ) puts str if str.sub!( /lion/, “whale” ) OUTPUT: the cat sleeps tonight   # returned...
Aug 15th
1 note
Tale of Why the Lucky Stiff →
horgoldenembuzi: Why’s Poignant Guide to Ruby
Aug 9th
1 note
3 tags
regex debugging
use re ‘debug’; my $sentence = ‘this apple pie is excellent’; print “it matched\n” if $sentence =~ /(pie|apple)/;
Aug 1st
July 2012
23 posts
hol vagyunk geci?! →
horgoldenembuzi: Megyünk ősszel Skandináviába, kaptam egy csomó jó tippet, majd valaki megkérdezi: Ember: Fényképezőgépet visztek? én e:   (???) Nem (mondom de vicces voltam) Ember: ooo, vigyetek mindenképpen!!!  kittimegmondja said: SÁRGULOOOK!  mimiametron said: szerintem is érdemes vinni. semmiképp ne hagyjátok otthon! gépet viszünk, no meg szerencsére szállásra sem kell költeni
Jul 30th
9 notes
1 tag
regex DOS attacks
A good reading on the subject: http://checkmarx.com/wp-content/uploads/2012/07/ReDoS-Attacks.pdf
Jul 30th
1 note
2 tags
simple index
print “provide a test string: “; chomp( my $string = <STDIN> ); print ” … and a substring: “; chomp( my $substring = <STDIN> ); my @foundings; for ( my $hol = -1;;) {      $hol =index($string, $substring, $hol+1);      # precedes push, as -1 should not be in @foundings      last if $hol == -1;         push @foundings,$hol; } say...
Jul 30th
1 note
3 tags
Closures
sub make_iterator {       my @items = @_;       my $count = 0;       return sub {  # returning an anon-sub                         return if $count == @items;                         return $items[ $count++ ];                      } } my $cousins = make_iterator( qw/111 222 333 444 555 666 777/ ); say $cousins->() for 1 .. 5; OUTPUT: 111 222 333 444 555 ...
Jul 28th
Jul 28th
2 notes
Jul 26th
13 notes
2 tags
Check operator precedence with B::Deparse
The core B::Deparse module is an invaluable debugging tool. Run perl -MO=Deparse,-p on a snippet of code to see exactly how Perl handles operator precedence and associativity. The -p flag adds extra grouping parentheses which often clarify evaluation order. actual code: for ( sort keys %vscan_status ) {  print “$_ ===> $vscan_status{ $_ }\n”;     } after perl...
Jul 25th
4 tags
Reference into arrays and hashes
my @new_array = @{ $array_ref }; my %new_hash = %{ $hash_ref };
Jul 24th
1 note
4 tags
Merging hashes with slice
my %addresses = ( … ); my %canada_addresses = ( … ); @addresses{ keys %canada_addresses }= values %canada_addresses;
Jul 23rd
3 tags
$" - List Separator
An useful built-in variable that I keep forgetting: my @list = ( 1..7 ); $” = ‘][‘; say “[@list]”; OUTPUT: [1][2][3][4][5][6][7] 
Jul 23rd
3 tags
initializing hash slices
my %hash; my @keys = qw(perls before swine); @hash{@keys} = (“”) x @keys; same as: $hash{perls} = “”; $hash{before} = “”; $hash{swine} = “”;
Jul 20th
1 note
1 tag
recommended books from Programming Perl →
horgoldenembuzi: • The Art of Computer Programming, by Donald Knuth, Volumes 1–4A: “Fundamental Algorithms,” “Seminumerical Algorithms,” “Sorting and Searching,” and “Combinatorial Algorithms”; Addison-Wesley (2011). xxxvi | Preface • Introduction to Algorithms, by Thomas Cormen, Charles Leiserson, and Ronald
Jul 19th
3 notes
2 tags
simple but useful subroutines
# One argument is true sub any { $_ && return 1 for @_; 0 } # All arguments are true sub all { $_ || return 0 for @_; 1 } # All arguments are false sub none { $_ && return 0 for @_; 1 } # One argument is false sub notall { $_ || return 1 for @_; 0 } # How many elements are true sub true { scalar grep { $_ } @_ } # How many elements are...
Jul 16th
1 note
4 tags
@hits = grep { /regex/ } ;
Jul 13th
3 tags
The Eskimo operator - }{
perl -ne ‘print $_; <===> LINE: while (defined($_ = <ARGV>)) { print $_; } therefore # counts unique lines in the file FOO perl -nle ‘$seen{$_}++ }{ print “$_ => $seen{$_}” for keys %seen’ FOO or  # prints the total number of lines perl -ne ‘}{ print $.’
Jul 13th
5 tags
Reading file into a scalar
my $header; while ( my $line = <> ) {   $header .= $line; } or (with a little more work) open TEXTFILE, ‘some_file’ or die “open not possible: $!”; undef $/;           # making the input record separator undef my $file_in_scalar = <TEXTFILE>; close MORE_CODE; or, the easiest way: my $file = do { local $/ = <$fh> }; $/ is the input record...
Jul 11th
4 notes
4 tags
multi-level sort with Schwartzian-transform
my @output_data =   map $_->[0],   sort { SORT COMPARISON USING $a->[1] AND $b->[1] or           ANOTHER USING $a->[2] AND $b->[2] or       YET ANOTHER USING $a->[3] AND $b->[3] }   map [ $_, SOME FUNCTION OF $_, ANOTHER, YET ANOTHER ],   @input_data;
Jul 11th
3 tags
some concise (or obfuscated) example
my @words = split /-+/, shift;  $, = ‘___’; say @words; OUTPUT of “scripts ‘1-2—3-4-5-6’” 1___2___3___4___5___6
Jul 2nd
split and capturing parentheses
$x = ‘12aba34ba5’; @num = split /(a|b)+/, $x; # @num = (‘12’,’a’,’34’,’a’,’5’) @num = split /(?:a|b)+/, $x; # @num = (‘12’,’34’,’5’)
Jul 2nd
2 tags
global matching and position ( /g and pos() )
my $s = ‘i like pie’; for (my $i=0; $i < length( $s ); $i +=2 ) {   pos( $s ) = $i;   $s =~ /\w*/g;   print “$i —- <$&> \t “,pos($s),”\n”; } OUTPUT: 0 —- <i>        1 2 —- <like>     6 4 —- <ke>       6 6 —- <>         6 (a failed match on a string resets pos()) 8 —- <ie>      ...
Jul 2nd
2 tags
Randal's Rule
(Randal Schwartz) Use capturing or m//g when you know what you want to keep. Use split when you know what you want to throw away.
Jul 2nd
2 tags
greedy vs. non-greedy
my @abc = ‘abcdefghijklmnopqrstuvwxyz’ =~ /.{1,5}/g; OUTPUT (greedy): abcde___fghij___klmno___pqrst___uvwxy___z my @abc = ‘abcdefghijklmnopqrstuvwxyz’ =~ /.{1,5}?/g; OUTPUT (non-greedy): a___b___c___d___e___f___g___h___i___j___k___l___m___n___o___p___q___r___s___t___u___v___w___x___y___z ===================================================== $x =...
Jul 2nd
2 tags
Splitting email header into fields with lookahead
Received: from ni-s.u-net.com ([193.119.182.90] helo=bactrian.ni-s.u-net.com)              by he101war.uk.vianw.net with esmtp (Exim 3.22 #5)              id 17H8J0-0005po-00; Sun, 09 Jun 2002 20:24:51 +0100 Content-Disposition: inline Content-Transfer-Encoding: binary MIME-Version: 1.0 X-Mailer: Id: //depot/mail/tkmail#119 /Perl5.008 Mail::Internet v1.46 Subject: Re: Standard layers,...
Jul 2nd
June 2012
22 posts
2 tags
The best online regex tutorial so far →
Jun 30th