View update_packages_to_new_r_version.r
library(gtools) | |
update <- function(p) { | |
pd <- packageDescription(p, fields=c('Built')) | |
pd <- gsub(";.*", "", pd) | |
if (!is.na(pd) && pd != 'R 4.0.1') { # mention the target versions here | |
for (d in getDependencies(p)) { | |
update(d) | |
} | |
install.packages(p) |
View hostfile
localhost slots=9 |
View python_performance1.py
import random | |
import statistics | |
from timeit import default_timer as timer | |
def time_function(f, data): | |
times = [] | |
for _ in range(0, 20): | |
start = timer() | |
f(data) | |
times.append(timer() - start) |
View modification_time_based_file_organizer.py
import argparse | |
import glob | |
import hashlib | |
import logging | |
import os | |
import pathlib | |
import re | |
import shutil | |
import sys | |
import time |
View variance.kt
class Producer<out T: Any>(val e:T) { | |
fun read(): T = e | |
} | |
class Consumer<in T: Any>() { | |
private lateinit var e: T | |
fun write(v: T): Unit { e = v } | |
} | |
fun main() { |
View howManyLongsCanWeLoad.scala
import scala.collection.mutable.ArrayBuffer | |
import scala.util.Random | |
object M { | |
def main(args: Array[String]) { | |
val t = new ArrayBuffer[Long]() | |
while (true) { | |
t += Random.nextLong | |
if (t.length % 10000 == 0) { | |
System.gc() |
View parallelStreamAndAsSequence.kts
import kotlin.streams.asSequence | |
import kotlin.system.measureTimeMillis | |
val k = 500000000L | |
println(measureTimeMillis { | |
java.util.stream.LongStream.range(1, k) | |
.parallel() | |
.asSequence() | |
.map { it.toString().length.toLong() } |
View permutations.kt
class PermutationGenerator(numOfValues:Int) : Iterator<List<Int>> { | |
private val maxPos = numOfValues - 1 | |
private val values = (0..maxPos).shuffled() | |
private var currPerm = (0..maxPos).toMutableList() | |
@Synchronized override fun hasNext() = currPerm.isNotEmpty() | |
@Synchronized override fun next(): List<Int> { | |
val perm = currPerm.toList() | |
val j = (maxPos - 1 downTo 0).find { currPerm[it] < currPerm[it + 1] } |
View io-measure.cpp
#include <chrono> | |
#include <fstream> | |
#include <iostream> | |
using namespace std; | |
int k = 256; | |
int numOfNums = k * 1024 * 1024; | |
int reps = 6; | |
void writeUsingFile(string fileName) { |
NewerOlder