Skip to content

Instantly share code, notes, and snippets.

Edwin Rodríguez edwrodrig

  • Instituto Milenio de Oceanografía
  • Concepción, Chile
Block or report user

Report or block edwrodrig

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@edwrodrig
edwrodrig / select_to_file_format_sqlite3
Last active Jan 3, 2016
Output select query to file in format in SQLite3
View select_to_file_format_sqlite3
.mode list
.separator \n---\n
.output somefile.txt
SELECT column1, column2 || char(10) || '###' FROM table;
@edwrodrig
edwrodrig / undef_eq.pl
Last active Jan 3, 2016
Behavior of different equal comparison considering different boolean values and undefined
View undef_eq.pl
use strict;
my $var1;
my $var2 = undef;
my $var3 = (1 == 0);
sub printEval
{
my ($evalString) = @_;
my $evalResult = eval($evalString);
@edwrodrig
edwrodrig / ad_activity
Last active Jan 3, 2016
AdMob activity for android
View ad_activity
package com.edwrodrig.ui;
import com.edwrodrig.R;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
public class AdActivity extends FragmentActivity {
@edwrodrig
edwrodrig / multiple_assignation.pl
Created Jan 21, 2014
Example of vector assignation in Perl
View multiple_assignation.pl
use strict;
{
my ($a, $b) = split(/,/, "A,B");
print "[$a] [$b]\n";
# output: [A] [B]
}
{
my $foo = {};
@edwrodrig
edwrodrig / sort_hash_by_value.pl
Created Jan 21, 2014
Sort hash by value in Perl
View sort_hash_by_value.pl
use strict;
my $coins = { "Quarter" => .25,
"Dime" => .10,
"Nickel" => .05
};
foreach my $key (sort {$coins->{$a} cmp $coins->{$b} } keys %$coins)
{
my $value = $coins->{$key};
@edwrodrig
edwrodrig / if_inline_assignation.pl
Created Jan 21, 2014
If inline assigment behavior
View if_inline_assignation.pl
use strict;
if ( my $result = 0 )
{
print "No se imprime:[$result]\n";
}
if ( my $result = undef )
{
print "No se imprime:[$result]\n";
@edwrodrig
edwrodrig / hash_setting_in_scope.pl
Created Jan 21, 2014
Example of behavior of setting a hash in different scopes
View hash_setting_in_scope.pl
use strict;
use Data::Dumper;
sub hashRef {
my ($var) = @_;
print "Before:\n" . Dumper($var);
$var = { 'hhh' => 'ggg'};
print "After In:\n" . Dumper($var);
}
@edwrodrig
edwrodrig / filter_array_of_hash.pl
Created Jan 21, 2014
Filter an array of hashes by value
View filter_array_of_hash.pl
use strict;
use Data::Dumper;
my $array = [{ 'key' => 'value1' },{ 'key' => 'value2' },{ 'key' => 'value3' }];
@{$array} = grep($_->{'key'} ne 'value2', @$array);
print Dumper($array);
@edwrodrig
edwrodrig / dumper_filter.pl
Created Jan 21, 2014
Filter values of Dumper in Perl
View dumper_filter.pl
use strict;
use Data::Dumper;
#This filter sort the keys and ignores AAA keys
sub dumperFilter
{
my ($hash) = @_;
my @array;
@edwrodrig
edwrodrig / delete_key_hash.pl
Created Jan 21, 2014
Delete key from hash in perl
View delete_key_hash.pl
use strict;
use Data::Dumper;
my $hash = {};
$hash->{'A'}{'AA'} = 'AA';
$hash->{'A'}{'AB'} = 'AB';
$hash->{'B'}{'BA'} = 'BA';
$hash->{'B'}{'BB'} = 'BB';
You can’t perform that action at this time.