Skip to content

Instantly share code, notes, and snippets.

@VladimirSaz
VladimirSaz / ut_python_example.py
Created July 27, 2018 14:34
Unit test Python
import unittest
import sys
sys.path.append('PATH') # noqa
from module_name import Module_name
from test_tools import test_name
from pprint import pprint #noqa
class TestUM(unittest.TestCase):
def setUp(self):
@VladimirSaz
VladimirSaz / usefull.R
Created May 6, 2014 11:48
usefull function in R
#stop() - alerts about fatal error
stop("cant create file")
#take only unique values from vector
vect<-unique(vect)
@VladimirSaz
VladimirSaz / vector.R
Created May 6, 2014 11:45
vector operations in R
#initialize named vector
vect<-c("a param 1"=1,"a param 2"=2,"a named param 3"= 6)
#show vector names
names(vect)
#make vector unnamed
unname(vect)
@VladimirSaz
VladimirSaz / data_frame.R
Last active August 29, 2015 14:01 — forked from prasoonsharma/gist:717903
data.frame operation in R
# DATA FRAME OPERATIONS IN R
# Create data frame
# A dataset is ~ table (list of vectors)
id <- c(1,2,3)
name <- c("John", "Kirk", "AJ")
age <- c(21,27,18)
employees <- data.frame(ID=id, Name=name, Age=age)
employees
@VladimirSaz
VladimirSaz / class.pl
Created May 6, 2014 06:38
PERL - simple class
package PackageName;
sub new {
my ($class, $args) = @_;
my $self = {
attr1 => $args->{attr1} || 'some_template_conent',
attr2 => $args->{attr2} || 1,
attr3 => $args->{attr3} || 1,
};
#more code here if u want
@VladimirSaz
VladimirSaz / class.pl
Created May 6, 2014 06:30
PERL - overload class implement
sub new
{
my $class = shift;
my %params = @_;
#
#some code here
#
my $self = $class->SUPER::new(%params);
$class = ref $class if ref $class;
bless $self, $class;