This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {PropTypes} from 'react' | |
export default class TextareaAutoSize extends React.Component { | |
constructor(props) { | |
super(props); | |
} | |
recalcHeight() { | |
var borders = 2; | |
var innerHeight = Math.floor(this.textarea.scrollHeight / 2) * 2 + 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package WSTest::WebSocket::Echo; | |
sub on_message { | |
my ($self, $message) = @_; | |
$self->send($message); | |
} | |
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use Benchmark qw(:all); | |
use Storable; | |
use Clone; | |
use CBOR::XS; | |
use Data::MessagePack; | |
use Panda::Lib; | |
use Sereal; | |
use Sereal::Dclone; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openssl speed md5 sha1 | |
Doing md5 for 3s on 16 size blocks: 11619577 md5's in 3.00s | |
Doing md5 for 3s on 64 size blocks: 8749864 md5's in 3.00s | |
Doing md5 for 3s on 256 size blocks: 5139920 md5's in 3.00s | |
Doing md5 for 3s on 1024 size blocks: 1940245 md5's in 3.00s | |
Doing md5 for 3s on 8192 size blocks: 279680 md5's in 3.00s | |
Doing sha1 for 3s on 16 size blocks: 12632845 sha1's in 3.00s | |
Doing sha1 for 3s on 64 size blocks: 8988413 sha1's in 3.00s | |
Doing sha1 for 3s on 256 size blocks: 4959988 sha1's in 3.00s | |
Doing sha1 for 3s on 1024 size blocks: 1791757 sha1's in 2.99s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
sub ccmap ($) { | |
my $name = $_[0]; | |
$name =~ s/([[:upper:]])/_\l$1/g; | |
$name =~ s/^_//; | |
return $name; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use DBI; | |
use strict; | |
use warnings; | |
my $dbh; | |
sub db_connect { | |
my $usename = (getpwuid $>)[0]; | |
$dbh ||= DBI->connect("dbi:Pg:dbname=$usename", $usename, "") or die DBI->errstr(); | |
$dbh; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/wish | |
package require Tk | |
tk scaling [expr {240/72}] | |
canvas .cv -width 180m -height 270m -bg white | |
pack .cv | |
set font {Arial 24} | |
set l .label0 | |
label $l -bd 0 -padx 0 -pady 0 -highlightthickness 0 -font $font -text "0" | |
set zero_width [expr { 1.3 * [winfo reqwidth $l]}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use PDF::Haru; | |
use strict; | |
use warnings; | |
# create new document | |
my $pdf = PDF::Haru::New(); | |
#$pdf->LoadTTFontFromFile("/usr/share/fonts/truetype/msttcorefonts/arial.ttf",1); | |
# add page | |
my $page = $pdf->AddPage(); | |
# set page size and orientation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $font = '^<"AAA"^<^(^8(^(^(^(>>A^!>@@^_>A^!>^!A>@BBB^_^"^"^_@@~^!A>>A@~AA>^_B^$^(^0^0^0>AA>AA>>AA?^!A>'; | |
$font =~ s/\^(.)/chr(ord($1)^32)/eg; | |
sub draw { | |
my $digits = $_[0]; | |
for my $l (0 .. 6) { | |
for my $d (split //, $digits) { | |
my $lv = substr($font, $d * 7 + $l, 1); | |
print unpack("B*", pack "C", ord $lv) =~ tr/01/ #/r; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub draw {$_='';for$l(0..6){for$d(split//,$_[0]){$_.=unpack("B*",pack"C",ord substr('^<"AAA"^<^(^8(^(^(^(>>A^!>@@^_>A^!>^!A>@BBB^_^"^"^_@@~^!A>>A@~AA>^_B^$^(^0^0^0>AA>AA>>AA?^!A>'=~s/\^(.)/chr(ord($1)^32)/egr,$d*7+$l,1))=~tr/01/ #/r;}$_.="\n";}$_} | |
print draw "2234"; |
OlderNewer