Giter VIP home page Giter VIP logo

evil.r's Introduction

evil: Evil Tricks for R

Collection of subtle tricks to slowly drive R users insane.

Usage

install_github("romainfrancois/evil.R")
evil::evil()

See Also

Contributions

Please contribute your evilness. We need to have a subtle balance on how insidious and evil we are, for example something like trump would be too much, R must still be usable but slowly drive people to insanity.

Everything should stay in the evil.R file, and we must be discreet when adding an evilness.

evil.r's People

Contributors

chrismuir avatar goldingn avatar hughparsonage avatar twolodzko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

evil.r's Issues

Interest in an evil `c`?

Any interest in an evil c() that changes a single char within a random string 5% of the time? Something like this:

unlockBinding("c", baseenv())
assign("c", 
       local({
         function(...) {
           out <- base:::c(...)
           args <- list(...)
           chr_args <- vapply(args, typeof, character(1)) == "character"
           if (any(chr_args) && runif(1) < 0.05) {
             idx <- sample(which(chr_args), 1)
             x_int <- utf8ToInt(out[idx])
             char_to_edit <- which(x_int == sample(x_int, 1))
             x_int[char_to_edit] <- x_int[char_to_edit] + 1
             out[idx] <- intToUtf8(x_int)
           }
           out
         }
       }), 
       pos = baseenv()
)

Which results in:

for (i in 1:100) {
  x <- c("cats", "dogs")
  if (!identical(x, base:::c("cats", "dogs"))) {
    print(x)
  }
}
#> [1] "cats" "eogs"
#> [1] "catt" "dogs"
#> [1] "cbts" "dogs"
#> [1] "caus" "dogs"

I'd be happy to submit a PR if interested. Thanks!

A more permissive test_that()

library(testthat)
test_that <- function(desc, code){ 
  testthat::test_that(desc, {expect_true(TRUE)})
}

test_that("yolo", {
  expect_true(1 == 4)
})
#> Test passed ๐Ÿฅ‡

Created on 2021-05-05 by the reprex package (v2.0.0)

A Truly Evil True

Based off of @wrathematics observation:

> library(inline)
> T <- cfunction(body='
+   SEXP res = allocVector(LGLSXP, 1);
+   LOGICAL(res)[0] = 2;
+   return res;'
+ )()
> T
[1] TRUE
> T == TRUE
[1] FALSE

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.