Skip to content

Instantly share code, notes, and snippets.

View klepsydra's full-sized avatar

Marcos Koby klepsydra

  • US
View GitHub Profile
@ChecksumFailed
ChecksumFailed / ReadMe.md
Created October 17, 2023 20:53
SerivceNow Widget Exploit Testing

Powershell script to to test simple lis

@yoshyoshi
yoshyoshi / tradingbot.py
Created July 24, 2018 04:56
trading bot code snippet
from datetime import datetime
import numpy as np
import talib
import alpaca_trade_api as tradeapi
api = tradeapi.REST(key_id=<your key id>,secret_key=<your secret key>)
barTimeframe = "1H" # 1Min, 5Min, 15Min, 1H, 1D
assetsToTrade = ["SPY","MSFT","AAPL","NFLX"]
positionSizing = 0.25
@yoshyoshi
yoshyoshi / gist:5a35a23ac263747eabc70906fd037ff3
Last active September 1, 2021 14:42
download and store OHLCV data into a CSV
import alpaca_trade_api as tradeapi
api = tradeapi.REST(key_id=<your key id>,secret_key=<your secret key>)
storageLocation = "<your folder location>"
barTimeframe = "1H" # 1Min, 5Min, 15Min, 1H, 1D
assetsToDownload = ["SPY","MSFT","AAPL","NFLX"]
iteratorPos = 0 # Tracks position in list of symbols to download
assetListLen = len(assetsToDownload)
@franzalex
franzalex / TextArea_Backup_with_Expiry_Fix.user.js
Last active April 3, 2018 08:24
Creates a backup of input and textArea fields for restoration after data loss. It offers similar functionality as the Lazarus Firefox extension which is no longer supported.
// ==UserScript==
// @author Crend King
// @contributor Franz Alex Gaisie-Essilfie
// @version 2.4.20170620
// @name Textarea Backup with expiry Fix
// @namespace http://users.soe.ucsc.edu/~kjin
// @description Fix @grant https://greasyfork.org/zh-CN/forum/discussion/8161
// @description Retains text entered into textareas and contentEditables, and expires after certain time span.
// @include http://*
// @include https://*
@emaraschio
emaraschio / SOLID.markdown
Last active May 24, 2023 07:18
SOLID Principles with ruby examples

#SOLID Principles with ruby examples

##SRP - Single responsibility principle A class should have only a single responsibility.

Every class should have a single responsibility, and that responsibility should be entirely encapsulated. All its services should be narrowly aligned with that responsibility, this embrace the high cohesion.

##OCP - Open/closed principle Software entities should be open for extension, but closed for modification.

@solyarisoftware
solyarisoftware / idle.rb
Last active July 11, 2023 20:58
Ruby script to test how to fetch IMAP mails (IDLE "push" mode) without pulling (in "real-time")
# Encoding: utf-8
#
# idle.rb
#
# goal:
# Ruby script to test how to fetch IMAP mails with IDLE mode.
# IMAP IDLE allow a sort of "push" / "real-time" delivery.
#
# I used the script to test LATENCY (end-to-end delivery times)
@klepsydra
klepsydra / sync-fail2ban.sh
Last active January 11, 2024 15:11
Block globally reported hack attempts using your local iptables firewall rules
#!/bin/bash
## Update fail2ban iptables with globally known attackers.
## Actually, runs 100% independently now, without needing fail2ban installed.
##
## /etc/cron.daily/sync-fail2ban
##
## Author: Marcos Kobylecki <[email protected]>
## http://www.reddit.com/r/linux/comments/2nvzur/shared_blacklists_from_fail2ban/
@thertrader
thertrader / ShinyForTradingStrategy.txt
Last active June 17, 2023 15:59
A Simple Shiny App for Monitoring Trading Strategies
This Shiny application is designed to help analysing trading strategies. It is an ongoing project that I improve when time allows. Feel free to get in touch should you have any suggestion.
*How to use the App as it is?
The App uses as input several csv files (one for each strategy). Each file has two columns: date and daily return. There is an example of such a file in the Github repository. The code is essentially made of 3 files.
-ui.R: controls the layout and appearance of the app
-server.R: contains the instructions needed to build the app. You can load as much strategies as you want as long as the corresponding csv file has the right format (see below).
-shinyStrategyGeneral.R: loads the required packages and launches the app
put ui.R and server.R file in a separate directory
In the server.R file change the inputPath, inputFile and keepColumns parameters to match your setting. The first two are self explanatory the third one is a list of column names within the csv file. Keep only date and daily return
@Osse
Osse / gist:9553403
Created March 14, 2014 18:07
Cannot shutdown
$ sudo systemctl poweroff
Failed to start poweroff.target: Connection timed out
$ sudo shutdown -h now
Failed to start poweroff.target: Activation of org.freedesktop.systemd1 timed out
Failed to open /dev/initctl: No such device or address
Failed to talk to init daemon.
@Integralist
Integralist / Hash Keys to Symbols.rb
Last active September 2, 2020 08:50
Convert Ruby Hash keys into symbols
hash = { 'foo' => 'bar' }
# Version 1
hash = Hash[hash.map { |k, v| [k.to_sym, v] }]
# Version 2
hash = hash.reduce({}) do |memo, (k, v)|
memo.tap { |m| m[k.to_sym] = v }
end