Skip to content

Instantly share code, notes, and snippets.

@paretech
paretech / exampleApplyCalOffsets.m
Last active Sep 15, 2022
This MATLAB+Psychtoolbox example script contains naively approach of applying spatial calibration offsets using Psychtoolbox imaging pipeline. It is posted along with support post on the PTB website. Note that this is not production code, it is simply an example to demonstrate a specific concept.
View exampleApplyCalOffsets.m
% Demonstrate attempt at applying x, y offsets via PTB processing hooks.
%
% Instructions
% ------------
% After running, press any key to advance offset position. Position will
% not change until key-up event. The script will run indefinitely until the
% escape key is pressed.
%
% Known Issues
% ------------
@paretech
paretech / shuffle_blocks.py
Created Mar 20, 2022
Shuffle multiple blocks of tabular data by unique value.
View shuffle_blocks.py
# %% [markdown]
# # Data Generation and Sequencing
# %%
import pandas as pd
import numpy as np
import random
# %%
primary = pd.DataFrame({'primary': ['A', 'B', 'C']})
View accounting_month.py
import pandas as pd
def accounting_month(start, end):
month_end = pd.date_range(start=start, end=end, freq=pd.tseries.offsets.LastWeekOfMonth(n=1, weekday=6))
month_start = month_end.shift(periods=-1, freq=pd.tseries.offsets.LastWeekOfMonth(n=1, weekday=6)).shift(periods=1, freq='D')
weeks_in_month = (month_end - month_start).shift(periods=1, freq='D') / pd.Timedelta(7, 'D')
return pd.DataFrame({'start': month_start, 'end': month_end}, index=month_end.to_period('M'))
if __name__ == '__main__':
accounting_calendar = accounting_month('2019-01-01', '2022-01-01')
@paretech
paretech / aio1.py
Created Jul 26, 2019
Python AsyncIO Example #1
View aio1.py
import asyncio
import logging
import random
import sys
LOGGER = logging.getLogger(__name__)
LOGGER.addHandler(logging.NullHandler())
def config_logging():
@paretech
paretech / gist:6bcd39658b42098cbe2c3d19b7245e48
Created Aug 11, 2018
clang2py -c -d -l ftd2xx64.dll ftd2xx.h -vvv -o _ftd2xx64.py
View gist:6bcd39658b42098cbe2c3d19b7245e48
# generated by 'clang2py'
# flags '-c -d -l ftd2xx64.dll ftd2xx.h -vvv -o _ftd2xx64.py'
# -*- coding: utf-8 -*-
#
# TARGET arch is: []
# WORD_SIZE is: 4
# POINTER_SIZE is: 8
# LONGDOUBLE_SIZE is: 8
#
import ctypes
@paretech
paretech / RemoveWindows10Apps
Created Aug 10, 2018
Remove those Windows 10 Apps...
View RemoveWindows10Apps
# Modified based off https://www.oueta.com/microsoft/how-to-uninstall-built-in-apps-from-windows-10/
Get-AppxPackage *twitter* | Remove-AppxPackage
Get-AppxPackage *oneconnect* | Remove-AppxPackage
Get-AppxPackage *people* | Remove-AppxPackage
Get-AppxPackage *messaging* | Remove-AppxPackage
Get-AppxPackage *communicationsapps* | Remove-AppxPackage
Get-AppxPackage *print3d* | Remove-AppxPackage
Get-AppxPackage *autodesksketch* | Remove-AppxPackage
Get-AppxPackage *3dview* | Remove-AppxPackage
Get-AppxPackage *3dbuilder* | Remove-AppxPackage
View LibFT4222 using ctypelib2
# generated by 'clang2py'
# flags '-c -d -k defst -l build/libftd2xx.so.1.4.8 -i ftd2xx.h -o test3.py'
# -*- coding: utf-8 -*-
#
# TARGET arch is: []
# WORD_SIZE is: 8
# POINTER_SIZE is: 8
# LONGDOUBLE_SIZE is: 16
#
import ctypes
@paretech
paretech / multicast_server.py
Created Apr 21, 2017
A simple multicast server that repeatedly says "Test"
View multicast_server.py
"""multicast_server.py - A simple multicast server that says "Test"."""
import socket
import struct
import time
class multicast_speaker():
def __init__(self, address, port, ttl=2, timeout=0.2):
self.group = address, int(port)
@paretech
paretech / haystack.py
Created Apr 21, 2017
Sifting files generated by photorec using md5deep and tiny pieces of python.
View haystack.py
#!/usr/bin/env python3
import csv
import os.path
import os
import shutil
'''Haystack.py - sifting through photorec recovered data
Concept of using photorec, md5deep, NSRL "known" file dataset and personal
View MergePrintIndexed.bat
:: Merge indexed text files and print the result
@ECHO OFF
SETLOCAL EnableDelayedExpansion
:: User Config
SET ina_base=part1_
SET inb_base=part2_
SET out_base=sum12_