Skip to content

Instantly share code, notes, and snippets.

Avatar

Sebastian Hütter martok

View GitHub Profile
@martok
martok / opt-ruby.sh
Last active Apr 7, 2020
Ruby source installation manager
View opt-ruby.sh
#!/bin/bash
CONF=/etc/profile.d/optruby.sh
INSTALLED=/opt/ruby
do_status() {
current=$(OPTRUBY=system ; [ -f $CONF ] && . $CONF ; echo $OPTRUBY )
echo "Currently enabled version via profile.d: $current"
echo "Currently selected by this shell: $(ruby -v)"
}
View gist:3bc302651b318861425897e67319fc18
#include <iostream>
using namespace std;
/*
template<typename T, typename std::enable_if<std::is_enum<T>::value>::type* = nullptr>
static inline bool set_in(T val, T a1, T a2) { return (val==a1||val==a2); }
template<typename T, typename std::enable_if<std::is_enum<T>::value>::type* = nullptr>
static inline bool set_in(T val, T a1, T a2, T a3) { return (val==a1||val==a2||val==a3); }
template<typename T, typename std::enable_if<std::is_enum<T>::value>::type* = nullptr>
static inline bool set_in(T val, T a1, T a2, T a3, T a4) { return (val==a1||val==a2||val==a3||val==a4); }
@martok
martok / systemdTOTD.markdown
Last active Sep 11, 2020
systemdTOTD archive
View systemdTOTD.markdown

Meta

This is @LucasWerkmeistr's #systemdTOTD thread, gathered using Spooler and reposted here with only some typographic adjustments by me.

Part 1

Alright everyone, how about some systemd Tip Of The Day goodness?

@martok
martok / 122032.css
Created Jul 1, 2018
YouTube Real Cinema Mode
View 122032.css
@-moz-document domain(youtube.com) {
body {
overflow-x: hidden;
}
#masthead-positioner {
z-index: 10;
}
.watch-stage-mode #player .player-api {
@martok
martok / mpinice.sh
Created Mar 28, 2018
Start a program using mpirun with multi-user-friendly options
View mpinice.sh
#!/bin/bash
{
NPROCS=4
NICE=10
STDOUT=/dev/stdout
print_usage()
{
cat <<END
View xrd_mo.lmp
units metal
dimension 3
boundary p p p
atom_style atomic
timestep 0.001
variable min2th index 20
variable max2th index 90
lattice bcc 3.147
@martok
martok / Al.meam
Created Jun 15, 2017
Testcase LAMMPS MEAM/C #1
View Al.meam
Cmin(1,1,1) = 1
repuls(1,1) = 0.4770183040558415
nn2(1,1)=1
rc = 5.0
ialloy=1
augt1=0
delr=1
emb_lin_neg=1
bkgd_dyn=1
@martok
martok / syncrotron.cmd
Created Apr 17, 2017
Sync/Backup script based on Robocopy
View syncrotron.cmd
@echo off
setlocal
echo ************************************************
echo **** Martok's Syncrotron ****
echo ************************************************
echo **** 1: Copy from this machine to exHDD ****
echo **** 2: Copy from exHDD to this machine ****
echo **** anything else: exit ****
echo ************************************************
set /p select="Choose option: "
View gist:6f855c8887fd4f33454d
<?php
define('IND','&nbsp;&nbsp;');
function hex2bin( $str ) {
$sbin = "";
$len = strlen( $str );
for ( $i = 0; $i < $len; $i += 2 ) {
$sbin .= pack( "H*", substr( $str, $i, 2 ) );
}
@martok
martok / counter.py
Created Jan 13, 2015
MCEdit Block/Height filter
View counter.py
from pymclevel import items
def itembyname(name):
if name in items.items.items:
return items.items.itewms[name]["id"]
return 0
def namebyitem(id):
item = items.items.findItemID(id)
if type(item["name"]) == str or type(item["name"]) == unicode:
You can’t perform that action at this time.