Skip to content

Instantly share code, notes, and snippets.

@dejnon
dejnon / my-teams-meeting
Last active March 23, 2023 11:09
AppleScript to open a MS Teams meeting and copy the link to clipboard (useful with a global shortcut)
#!/usr/bin/env osascript
global meetingLink
on get_meeting_link(t)
tell application "Microsoft Edge"
tell t to execute javascript "document?.querySelector('iframe')?.contentDocument?.querySelector('div[data-tid=meet_now_calendar_flyout_meeting_link_text_field] input')?.value || ''"
end tell
end get_meeting_link
@dejnon
dejnon / governor.py
Last active August 29, 2015 14:15
Very simple CPU scaling governor based on feedback from httpmon utility
import threading, commands, re, subprocess
from datetime import datetime
class Cpu:
def __init__(self):
self.overload_threshold = 0.7
self.idle_threshold = 0.1
self.possible_steps = [1.4, 1.5, 1.7, 1.9, 2.1]
self.current_step = 0
self._cpu_usage = 0.0
@dejnon
dejnon / nad1.r
Created May 18, 2014 18:33
Numeryczna Analiza Danych - Lista 1
aapl <- read.csv("./aapl.csv", header=TRUE, dec=".", sep=",")
aapl$Date <- as.Date(aapl$Date, "%Y-%m-%d")
plot(Close ~ Date, aapl, xaxt = "n", type = "l")
axis(1, aapl$Date, format(aapl$Date, "%b %y"), cex.axis = .7)
#
# 1. Napisać funkcję obliczającą zwroty przy zadanym horyzoncie czasowym.
#
# ROT - rate of change
@dejnon
dejnon / ASLU2.sh
Created May 5, 2014 14:12
ASLU2.sh
#
# 1. Które pliki konfiguracyjne wczytywane są po zalogowaniu do
# graficznego interfejsu użytkownika i otworzeniu okna terminala?
#
cat /var/log/*org* | grep ".conf"
cat ~/.profile
#
# 2. Ustaw znak zachęty tak, aby oprócz nazw użytkownika i
/*
* This program uses the device CURAND API to calculate what
* proportion of pseudo-random ints have low bit set.
*/
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <curand_kernel.h>
/* include MTGP host helper functions */
#include <curand_mtgp32_host.h>
@dejnon
dejnon / curand.cu
Last active November 28, 2018 09:22
/*
* This program uses the device CURAND API to calculate what
* proportion of pseudo-random ints have low bit set.
*/
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <curand_kernel.h>
/* include MTGP host helper functions */
#include <curand_mtgp32_host.h>
@dejnon
dejnon / 1.py
Last active December 17, 2015 00:39
Python in scientific calculations. Task List 2.
#!/usr/bin/python
# 2.1
# Pakuje zbior plikow tekstowych do jednego pliku
# Nazwy plikow wejsciowych i archiwum powinny byc podane jako argumenty konsoli
#
# Pack textfiles as one file
# Input and output files are passed as cmd line parameters
import os
import argparse
@dejnon
dejnon / 1.py
Last active December 16, 2015 05:09
Python in scientific calculations. Task List 1.
#!/usr/bin/python
# 1.1
# Najwiekszy wspolny dzielnik podanej listy dodatnich liczb naturalnych
# Greatest common denominator for given list of positive integers
# Intuitive solution:
# def gcd(number_1, number_2):
# lower = min(number_1, number_2)
# for i in reversed(xrange(1, lower+1)):
# if not (number_1 % i and number_2 % i):