Skip to content

Instantly share code, notes, and snippets.

View johanrhodin's full-sized avatar

Johan Rhodin johanrhodin

View GitHub Profile
Verifying that +rhodin is my openname (Bitcoin username). https://onename.io/rhodin
@johanrhodin
johanrhodin / BetaAndUniform.m
Created July 9, 2015 16:00
Plot improvement suggestion for "Error and Dimensionality" draft article by Nassim Nicholas Taleb
(*See Figure 1 in https://dl.dropboxusercontent.com/u/50282823/Propagation.pdf*)
With[{a = 10, b = 20},
Plot[{PDF[UniformDistribution[{0, 1}], f],
PDF[BetaDistribution[a, b], f]},
{f, 0, 1},
Filling -> Axis,
AxesLabel -> {Text[Style["f", Italic]], "Pr"},
PlotRange -> All,
Ticks -> {Automatic, None},
PlotLegends ->
@johanrhodin
johanrhodin / frictiondifference.mo
Last active September 9, 2015 16:59
Two different ways to model friction
// New, in https://github.com/dzimmer/ZimmersModelicaTutorial/blob/master/Tutorial2015/BaseComponents/Friction/IdealDryFriction.mo
free = false;
f0 = R;
f0_max = S;
// velocity and acceleration of flanges
v_relfric = der(-s_rel);
a_relfric = der(v_relfric);
// Friction force
-f = if locked then sa * unitForce else if startForward then R else if startBackward then -R else if pre(mode) == Forward then R else -R;
@johanrhodin
johanrhodin / RevolutePosition.mo
Created September 30, 2015 21:20
Small model to illustrate the use of the f_crit parameter for Modelica.Mechanics.Rotational.Sources.Position
model RevolutePosition
Modelica.Blocks.Sources.CombiTimeTable combiTimeTable1(tableName = "var1", tableOnFile = true, smoothness = Modelica.Blocks.Types.Smoothness.ContinuousDerivative, extrapolation = Modelica.Blocks.Types.Extrapolation.HoldLastPoint, fileName = Modelica.Utilities.Files.loadResource("modelica://RevolutePosition/TestProfile1.txt")) annotation(Placement(visible = true, transformation(origin = {20, 20}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
Modelica.Mechanics.Rotational.Sources.Position position1(useSupport = false, f_crit = 0.1, exact = false) annotation(Placement(visible = true, transformation(origin = {-20, 20}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Parts.Body body(r_CM = {0.1, 0, 0}, m = 1) annotation(Placement(visible = true, transformation(origin = {-70, -20}, extent = {{-10, -10}, {10, 10}}, rotation = -540)));
inner Modelica.Mechanics.MultiBody.World world(enableAnimation = false) annotation(Placement(visible = true, transform
@johanrhodin
johanrhodin / StarExample.mo
Created February 2, 2016 16:39
Small example for Wolfram Community, demonstrate how to use "Modelica.Electrical.MultiPhase.Basic.Star"
model StarExample
extends Modelica.Icons.Example;
import Modelica.Constants.pi;
Modelica.Electrical.MultiPhase.Basic.Star star(m = m) annotation(Placement(visible = true, transformation(origin = {-60, 40}, extent = {{-10, -10}, {10, 10}}, rotation = -540)));
Modelica.Electrical.Analog.Basic.Ground ground annotation(Placement(visible = true, transformation(origin = {-80, -80}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Sources.SineVoltage sineVoltage(V = 10, freqHz = 1) annotation(Placement(visible = true, transformation(origin = {-80, -0}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Electrical.MultiPhase.Sources.SineVoltage sineVoltage1(final m = m, V = fill(sqrt(2) * VRMS, m), freqHz = fill(f, m)) annotation(Placement(transformation(origin = {0, 0}, extent = {{10, -10}, {-10, 10}}, rotation = 90), visible = true));
Modelica.Electrical.MultiPhase.Basic.Star star1(final m = m) annotation(Placement(transformation(extent = {{10, -10}, {-10, 10}}, r
@johanrhodin
johanrhodin / e
Last active May 4, 2017 01:32
elixir setup for raspi
echo "deb http://packages.erlang-solutions.com/debian jessie contrib" | sudo tee /etc/apt/sources.list.d/erlang-solutions.list
wget http://packages.erlang-solutions.com/debian/erlang_solutions.asc
sudo apt-key add erlang_solutions.asc
sudo apt update
sudo apt install elixir
# Get Heroku for the RasPi, where we store the credentials
sudo add-apt-repository "deb https://cli-assets.heroku.com/branches/stable/apt ./"
curl -L https://cli-assets.heroku.com/apt/release.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install heroku
With[{text=Text[Style["First Last",Black,FontFamily->"Helvetica",24]],graph=RandomGraph[BernoulliGraphDistribution[RandomInteger[{5,10}],RandomReal[{0.6,0.9}]],GraphHighlight->{RandomInteger[{1,10}]},ImageSize->{50,50}]},
Grid[{{Rotate[text,\[Pi]],graph},{text,graph}},
Frame->{{},{True,True}},
Alignment->{{Right,Left},{Center,Center}}]
]
@johanrhodin
johanrhodin / keybase.md
Created July 20, 2017 16:47
keybase.md

Keybase proof

I hereby claim:

  • I am johanrhodin on github.
  • I am rhodin (https://keybase.io/rhodin) on keybase.
  • I have a public key whose fingerprint is EA19 078F FA2D 8CDE 5E08 A969 14C0 9651 1140 D11D

To claim this, I am signing this object:

#!/bin/bash
# Creates 400 vhosts
# Related to https://github.com/rabbitmq/rabbitmq-server/pull/1770 & https://groups.google.com/d/msg/rabbitmq-users/ZbTNp6YqZeo/53JLiy2zAQAJ
# Clean up with rabbitmqctl eval '[garbage_collect(P) || P <- processes()].'
# To see this behavior (for a longer time) in 3.7.9 you need to turn off background_gc_enbaled: {background_gc_enabled, false} in rabbitmq.config
for i in `seq 1 400`;
do
echo $i