Skip to content

Instantly share code, notes, and snippets.

View bast's full-sized avatar
🦀
rusting

Radovan Bast bast

🦀
rusting
View GitHub Profile
@bast
bast / increment-problem.c
Last active January 11, 2017 09:19
Example demonstrating increment problem with 32-bit float.
#include "stdio.h"
/* example obtained from Ole Martin Bjoerndalen */
int main()
{
float a = 16777216;
printf("before increment %f\n", a);
float b = a + 1;
printf("after increment by one %f\n", b);
@bast
bast / grep.py
Last active October 26, 2016 16:37
Example with check_output: uses output from a command and splits it into a list.
from subprocess import check_output
# extract output
out = check_output('grep -l foo *', shell=True).decode("utf-8")
# split into a list
l = out.split('\n')
# print the list
print(l)
#!/usr/bin/env python
"""
Example for user 'someuser':
$ rocks run host compute 'python /home/user/find-undead.py someuser' | grep -v down | grep -v untrusted
"""
def run_command(command):
import subprocess

Keybase proof

I hereby claim:

  • I am bast on github.
  • I am radovan (https://keybase.io/radovan) on keybase.
  • I have a public key whose fingerprint is 36CE DAE1 6274 B9FF BACD ABDD 7FC5 E51C FC10 DD3A

To claim this, I am signing this object:

@bast
bast / jekyll-installation-arch.sh
Last active March 15, 2024 20:13
Jekyll installation on Arch Linux.
sudo pacman -S ruby ruby-rdoc gcc make
gem update --user-install
gem install jekyll --user-install
# finally add $HOME/.gem/ruby/2.7.0/bin to your PATH variable
@bast
bast / profile-memory.py
Created January 26, 2016 21:38
Memory profiling example.
def gauss1(n):
j = 0
for i in range(1, n+1):
j += i
return j
def gauss2(n):
j = 0
for i in xrange(1, n+1):
@bast
bast / profile-speed.py
Created January 26, 2016 21:24
Profiling example.
def concat_words(n, w):
concat = ''
for i in range(n):
concat += w
def concat_words_append(n, w):
s = []
for i in range(n):
s.append(w)
@bast
bast / impure.py
Last active April 19, 2016 18:45
impure-python-example
def my_function(parameters=[]):
parameters.append(100)
return parameters
print(my_function())
print(my_function())
print(my_function())
print(my_function())
print(my_function())
@bast
bast / hybrid-hello-world-slurm
Last active August 29, 2015 14:16
Hello world MPI/OpenMP with Slurm.
Copyright (c) 2015 Radovan Bast
Licensed under the MIT license - http://opensource.org/licenses/MIT
Example source code (hello.cpp):
#include <stdio.h>
#include <omp.h>
#include "mpi.h"
@bast
bast / ubuntu-dirac-gnu-openmpi-int64
Last active November 14, 2015 21:48
Installation walkthru for DIRAC14 with GNU and OpenMPI (64bit-integers) on Ubuntu 14.04 x86_64.
#!/usr/bin/env bash
# complete installation walkthru for DIRAC14
# with GNU and OpenMPI (64bit-integers)
# on Ubuntu 14.04 x86_64
# Copyright (c) 2015 Radovan Bast
# Licensed under the MIT license - http://opensource.org/licenses/MIT
# ADAPT locations: