Skip to content

Instantly share code, notes, and snippets.

View purinda's full-sized avatar
🐺
....

Purinda Gunasekara purinda

🐺
....
View GitHub Profile
@backtrader
backtrader / ibtutorial.py
Last active May 9, 2024 03:06
Interactive Brokers in Python with backtrader
#!/usr/bin/env python
# -*- coding: utf-8; py-indent-offset:4 -*-
###############################################################################
#
# Copyright (C) 2018 Daniel Rodriguez
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@mxschmitt
mxschmitt / start.sh
Last active August 7, 2023 23:41
Librespot -> ffmpeg -> vlc http streaming -> Spotify connect
#!/bin/bash
# Using the Librespot client libary for streaming the Spotfiy connect sound via http
# Instruction:
# 1. Drop this script into the root directory of the librespot repository => https://github.com/plietar/librespot
# 2. Install the dependencies => "sudo apt-get install vlc ffmpeg"
# 3. Set the correct privileges => "chmod +x start.sh"
# 4. Set the librespot directory owner to a non-root user
# 5. Switch to this user
# 6. Change the variables under this instruction for your needs
@marianogappa
marianogappa / ordered_parallel.go
Last active February 12, 2024 09:27
Parallel processing with ordered output in Go
/*
Parallel processing with ordered output in Go
(you can use this pattern by importing https://github.com/MarianoGappa/parseq)
This example implementation is useful when the following 3 conditions are true:
1) the rate of input is higher than the rate of output on the system (i.e. it queues up)
2) the processing of input can be parallelised, and overall throughput increases by doing so
3) the order of output of the system needs to respect order of input
- if 1 is false, KISS!
@developerdino
developerdino / parent-categories.sql
Created April 18, 2016 23:37
Get all parent records for a child category - is good for getting the records for a breadcrumb trail. Thanks to http://stackoverflow.com/questions/2441821/getting-all-parent-rows-in-one-sql-query
select t2.id, t2.name
from (
select
@r as _id,
(select @r := parent_id from categories where id = _id) as parent_id,
@l := @l + 1 as lvl
from
(select @r := :id, @l := 0) vars,
categories h
where @r <> 0) t1
@xjamundx
xjamundx / blog-webpack-2.md
Last active April 21, 2024 16:20
From Require.js to Webpack - Part 2 (the how)

This is the follow up to a post I wrote recently called From Require.js to Webpack - Party 1 (the why) which was published in my personal blog.

In that post I talked about 3 main reasons for moving from require.js to webpack:

  1. Common JS support
  2. NPM support
  3. a healthy loader/plugin ecosystem.

Here I'll instead talk about some of the technical challenges that we faced during the migration. Despite the clear benefits in developer experience (DX) the setup was fairly difficult and I'd like to cover some of the challanges we faced to make the transition a bit easier.

@kennwhite
kennwhite / fix_postgres_initdb_error.md
Last active May 18, 2023 12:06
Postgres CentOS and Amazon Linux initdb error: Data directory is not empty! [FAILED]

If completely wiping & reinstalling a Postgres DB, when running initdb like:

service postgresql-9.2 initdb -E 'UTF8' --pgdata="/foo/bar/"

you can encounter this service error:

Data directory is not empty! [FAILED]

To fix it (and this is the nuclear option -- all db data is wiped!)

@plentz
plentz / nginx.conf
Last active July 27, 2024 16:11
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@MichaelWS
MichaelWS / dataSourcecsv.py
Created June 28, 2013 18:41
example datasource of zipline
"""
leverage work of briancappello and quantopian team
(especcially twiecki, eddie, and fawce)
"""
import pandas as pd
from zipline.gens.utils import hash_args
from zipline.sources.data_source import DataSource
import datetime
import csv
import numpy as np
@esycat
esycat / README.md
Last active October 30, 2023 10:52
How to get GNU's readlink -f behavior on OS X.

readlink.sh is a pure shell implementation that uses dirname, basename, readlink and pwd utils. Note that you cannot rename it to just readlink as then the script will call itself instead of the system utility.

realpath script simply calls Python's os.path.realpath. Python is provided in OS X and major Linux distributions. You can use instead of the system utility by making a symlink: ln -s realpath readlink.

Another way is to install coreutils package via Homebrew or MacPorts and use greadlink.

The code is taken from the following page on StackOverflow: http://goo.gl/Yw9OY

@fernandoaleman
fernandoaleman / how-to-create-an-rpm-repository.sh
Created November 18, 2011 17:57
How to create an RPM repository
# How to create an RPM repository
# This is for Redhat 64 bit versions of Linux. You can create your own RPM repository # to host your custom RPM packages.
#
# See "How to create an RPM from source with spec file" for more information.
# https://gist.github.com/1376973
# Step: 1
# Install createrepo