Skip to content

Instantly share code, notes, and snippets.

View samatjain's full-sized avatar

uıɐɾ ʞ ʇɐɯɐs samatjain

View GitHub Profile
@miohtama
miohtama / python-redis-json-dataclass-example.py
Created May 18, 2021 09:48
Python simple persistent database with dataclass, JSON and Redis.
"""A simple trade execution report database by using Python dataclass, Redis and JSON.
- A very simple database for arbitrage trade execution reports.
- Dataclasses are serialised and deserialised to JSON that is stored in the Redis.
- There is type validation for members and class-types.
- Class-types like Decimal are converted back to their original format upon deserialisation.
- Optional members are supported and the member presence is validated.
- Past trades can be iterated in either order by creation.
- A simple CSV exported is provided.
@secretGeek
secretGeek / get-meetings.ps1
Last active September 13, 2022 22:19
Get today's schedule from Outlook, using COM, and format as text for my TODO.txt file
# Get a list of meetings occurring today.
function get-meetings() {
$olFolderCalendar = 9
$ol = New-Object -ComObject Outlook.Application
$ns = $ol.GetNamespace('MAPI')
$Start = (Get-Date).ToShortDateString()
$End = (Get-Date).ToShortDateString()
$Filter = "[MessageClass]='IPM.Appointment' AND [Start] > '$Start' AND [End] < '$End'"
$appointments = $ns.GetDefaultFolder($olFolderCalendar).Items
$appointments.IncludeRecurrences = $true
@smhanov
smhanov / description.md
Last active November 7, 2023 11:52
Pipeline multiprocessing for python with generators

Pipeline multiprocessing in Python with generators

Similar to mpipe, this short module lets you string together tasks so that they are executed in parallel.

The difference is that it lets you use generators, functions which yield results instead of returning them. Each yielded item gets passed to the next stage.

You can specify that one or more copies of the workers operate on the input queue.

Things that can be in a stage

@imjasonh
imjasonh / markdown.css
Last active February 12, 2024 17:18
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@agateau
agateau / cmdline.sh
Last active January 28, 2022 04:49
#!/bin/bash
set -e
PROGNAME=$(basename $0)
die() {
echo "$PROGNAME: $*" >&2
exit 1
}
@pnorman
pnorman / load.sh
Created May 9, 2014 17:50
Shell commands to set up and load OpenStreetMap data into a PostGIS database with osm2pgsql on Ubuntu 14.04 from scratch
sudo apt-get --no-install-recommends -y install software-properties-common
sudo add-apt-repository -y ppa:kakrueger/openstreetmap
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get --no-install-recommends -y install git unzip curl build-essential postgresql-9.3-postgis-2.1 postgresql-contrib-9.3 proj-bin libgeos-dev apache2 munin munin-node munin-plugins-extra libdbd-pg-perl sysstat iotop ptop osm2pgsql osmctools
sudo -u postgres createuser -s $USER
createdb gis
psql -d gis -c 'CREATE EXTENSION hstore; CREATE EXTENSION postgis;'
sudo munin-node-configure --sh | sudo sh
sudo service munin-node restart
sudo sed -i "s|Allow from.*|Allow from all|" /etc/munin/apache.conf
@mcpherrinm
mcpherrinm / instructions.md
Last active October 25, 2015 02:35
Crosscompiling Rust to Arm

I want to write Rust code on my computer (x86_64, Ubuntu 14.04) and produce arm executables. I found hints on the internet, but not a concise set of instructions on what to do. So I wrote them down exactly:

apt-get install g++-arm-linux-gnueabihf
git clone https://github.com/mozilla/rust.git
mkdir rust/build-cross
cd rust/build-cross
../configure --target=arm-unknown-linux-gnueabihf --prefix=$HOME/local/rust-cross
make -j8 && make install
@akumria
akumria / find-forks.py
Last active March 9, 2024 01:39
A quick way to find all the forks of a particular github project. see: https://github.com/akumria/findforks for a version which works now
#!/usr/bin/env python
import os
import urllib2
import json
import subprocess
user=None
repo=None