Skip to content

Instantly share code, notes, and snippets.

// use, merge and append share-modules with ease:
// Usage:
* simply type "share" before use,merge and append commands
* replace path with "module wave", e.g. "dn 9", see examples below
// Setup:
* copy-paste the share-programme in the beginning of your do-file (or in profile.do so that the programme is loaded automatically when you launch stata)
* check the lines with "NB!" below. You will need to make some minor changes to the code in order to update the directories, release numbers etc.
//Credit:
import sqlite3
import os
os.chdir(os.path.dirname(__file__))
print(os.getcwd())
db = sqlite3.connect("bikes.db")
db.isolation_level = None
def distance_of_user(user):
verbose=False
from random import randint
class Risk:
def __init__(self):
self.results_counter=[0]*3
self.percentages=[None]*3
def throw_dice(self):
def add_edge(a,b,x):
graph[a][b]+=x
n=5
graph=[[0]*(n+1) for _ in range(n+1)]
seen=[False]*(n+1)
path=[]
@samuelsaari
samuelsaari / z1det_MVE_biofam_POSSIBLE_SOLUTION.R
Last active November 17, 2022 16:46
Latent Class Growth Modelling with multinomial response in R - attempt to solve
#-------------------------------------------------------------------------------------------------
# libraries
rm(list=ls())
# install.packages("TraMineR") # example data
# install.packages("OpenRepGrid")# random words for headings
# install.packages("khroma") # color palletttes
# install.packages("tidyverse")
# install.packages("modeldb")
# install.packages("car")
@samuelsaari
samuelsaari / z1det_MVE_biofam.R
Created November 1, 2022 10:12
Latent Class Growth Modelling with multinomial response in R
#---------------------------------------------------------
# libraries
rm(list=ls())
library(flexmix) # GMM & LCGM
library(TraMineR) # example data
library(OpenRepGrid)# random words for headings
library(khroma) # color palletttes
library(tidyverse)
library(car)
[makimiik@puhti-login12 ~]$ sinteractive --account project_2003758 --mem 64000 --tmp 640 --cores 4
Launching a new interavtive job
Interactive batch job is launched with following resources:
Maximum run time (hours:min:sec): 24:00:00
Maximum memory (MB): 64000
$TMPDIR size (GB): 640
Number of cores/threads: 4
Accounting project: project_2003758
@samuelsaari
samuelsaari / a1det_MVE.sh
Last active September 7, 2022 08:33
Batch job specification for stepFlexmix parallel wrapper
#!/bin/bash -l
#SBATCH --job-name=r_multicore_flh
#SBATCH --account=project_2003758
#SBATCH --output=x_output_all_%j.R
#SBATCH --error=x_errors_%j.R
#SBATCH --partition=large # small # test # hugemem_longrun # hugemem
#SBATCH --time=00:09:59 # 2-23:58:00 # 00:14:54 # 6-23:49:00 # 2-23:49:00
#SBATCH --nodes=12 #nr_of_classses
@samuelsaari
samuelsaari / z1det_MVE.R
Last active September 7, 2022 08:33
Parallel wrapper for stepFlexmix
# Parallel wrapper test for stepFlexmix
# Miika Maki
# R-code
Sys.time()
rm(list=ls())
# NB! Set interactive to TRUE or FALSE
INTERACTIVE=F
# TexPublish - Preparing LaTeX Projects for Publication with Ease
# URL: https://gist.github.com/samuelsaari/07cfff92e157fad84cd9d1988e108d95
# Author: Miika Mäki https://github.com/samuelsaari
# - creates a new directory for publishable files
# - copies files matching user defined regular expressions to the new directory
# - copies all desired files that are used by the main tex document (like figures and tables)
# - creates a parsed bibliography that includes only entries used by the main tex file
# - flattens the tex file (inserts \input and \include commands and custom preambles in the main tex file)
# - pastes the parsed bibliography to the flattened tex file if desired