Skip to content

Instantly share code, notes, and snippets.

View samuell's full-sized avatar
💻
Hacking away

Samuel Lampa samuell

💻
Hacking away
View GitHub Profile
package main
import (
"fmt"
"math"
"runtime"
"strings"
)
const (
@samuell
samuell / animated3Dplot.py
Created June 17, 2022 09:58 — forked from markjay4k/animated3Dplot.py
animated 3D example using PyQtGraph and OpenGL
# -*- coding: utf-8 -*-
"""
Animated 3D sinc function
"""
from pyqtgraph.Qt import QtCore, QtGui
import pyqtgraph.opengl as gl
import pyqtgraph as pg
import numpy as np
import sys
@samuell
samuell / luigi_time_tasks_example.py
Last active June 14, 2022 19:32
How to output the execution time of tasks in the luigi workflow system, as discussed [here](https://groups.google.com/d/msg/luigi-user/uivbf-luX9w/z0GCKKsIefoJ)
import luigi
import time
class TimeTaskMixin(object):
'''
A mixin that when added to a luigi task, will print out
the tasks execution time to standard out, when the task is
finished
'''
@luigi.Task.event_handler(luigi.Event.PROCESSING_TIME)
# change to postgres user and open psql prompt
sudo -u postgres psql postgres
# list databases
postgres=# \l
# list roles
postgres=# \du
# create role
// Workflow written in SciPipe.
// For more information about SciPipe, see: http://scipipe.org
package main
import sp "github.com/scipipe/scipipe"
func main() {
// Create a workflow, using 4 cpu cores
wf := sp.NewWorkflow("my_workflow", 4)
import luigi
import sciluigi as sl
# ... snip ...
class GlobFiles(sl.Task):
globdir = luigi.Parameter()
in_depend = None
SELECT node.title,timestamp,node_revisions.body
FROM node
LEFT JOIN node_revisions ON node.vid=node_revisions.vid
INTO OUTFILE '/tmp/nodes.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
@samuell
samuell / luigi_dynamic_dependency_graph_definition.py
Last active March 21, 2020 14:57
Dynamically specify luigi data flow
import luigi
class ATask(luigi.Task):
def output(self):
return luigi.LocalTarget("atask_output.txt")
def run(self):
with self.output().open("w") as outfile:
outfile.write("Test")
@samuell
samuell / select_parent_luigi_task_by_param.py
Created December 3, 2013 18:51
Demonstrates how one can select which parent task a luigi task should depend on, by specifying the parent task class name via a parameter.
import luigi
class ATask(luigi.Task):
def output(self):
return luigi.LocalTarget("atask_output.txt")
def run(self):
with self.output().open("w") as outfile:
outfile.write("Test")
@samuell
samuell / Makefile
Created September 12, 2019 13:45
Example Makefile for building a coverage report for .Net Core 2.2 projects on Windows 10 in MSYS2/Bash
#!/bin/bash
# --------------------------------------------------------------------------------
# This script uses the coverlet tool to generate code coverage statistics about the tests
# For more info about coverlet: https://github.com/tonerdo/coverlet
# Author: Samuel Lampa
# --------------------------------------------------------------------------------
./bin/Debug/netcoreapp2.2/MyApp.Tests.dll:
echo "Installing any uninstalled dependencies, by executing dotnet restore ..."
dotnet restore
dotnet build