Skip to content

Instantly share code, notes, and snippets.

View klepsydra's full-sized avatar

Marcos Koby klepsydra

  • US
View GitHub Profile
@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
@maxgalbu
maxgalbu / Switch_Node.php
Last active December 31, 2019 16:03
Switch tag for Twig, updated from https://github.com/fabpot/Twig/pull/185 to work with Twig >= 1.12
<?php
//To be added under Twig/Node/Switch.php
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
* (c) 2009 Armin Ronacher
*
@Diftraku
Diftraku / gist:5888214
Created June 28, 2013 21:18
A "simple" PHP function to convert arrays into DataTable JSON export format fit to use with Google Charts
<?php
/**
* arrayToDataTable()
* Converts PHP arrays to nested arrays fit for json_encode()
*
* Format Notice:
* - $cols contains all the columns for the DataTable, each column having a type and a label.
* Columns can be defined as plain arrays (containing only type and label, see below) or as a named array,
* with each of the properties defined as key => value pairs. All columns must have at least a 'type'.
*
@danvbe
danvbe / 1-Explanations.md
Last active July 23, 2025 05:55
A way to integrate FosUserBundle and HWIOAuthBundle

I have managed to install this… and make it work. I implemented it for Facebook and Google, but you can extend it. My solution it is mostly as described in #116, with a bit of more code presented. The key aspects that lack in the #116 presentation (IMO) are:

  • the registration as service of your custom FOSUBUserProvider (with the necessary parameters)
  • set the service for oauth_user_provider in the security.yml with your custom created service

Here are the steps:

  1. Routing. In routing.yml I have added all the routes for both bundles.
  2. Configuration. I have set the config.yml mostly as it is presented in the HWIOAuthBundle.
  3. Security. I have set the security.yml mostly as it is presented in the HWIOAuthBundle (though my routes are using /login pattern, not /connect). Also, the oauth_user_provider is set for my custom service.
anonymous
anonymous / gist:4169393
Created November 29, 2012 14:19
Patched ruby psych to handle multiline regexp
module Psych
module Visitors
class ToRuby < Psych::Visitors::Visitor
def deserialize o
if klass = Psych.load_tags[o.tag]
instance = klass.allocate
if instance.respond_to?(:init_with)
coder = Psych::Coder.new(o.tag)
coder.scalar = o.value
@johntyree
johntyree / getBlockLists.sh
Last active June 4, 2025 15:24
Make one large blocklist from the bluetack lists on iblocklist.com
#!/usr/bin/env sh
# Download lists, unpack and filter, write to stdout
curl -s https://www.iblocklist.com/lists.php \
| sed -n "s/.*value='\(http:.*=bt_.*\)'.*/\1/p" \
| xargs wget -O - \
| gunzip \
| egrep -v '^#'
@subelsky
subelsky / casperjs_example.js
Created August 8, 2012 18:51
Webscraping with CasperJS, PhantomJS, jQuery, and XPath
var system = require('system');
if (system.args.length < 5) {
console.info("You need to pass in account name, username, password, and path to casperJS as arguments to this code.");
phantom.exit();
}
var account = system.args[1];
var username = system.args[2];
var password = system.args[3];
@klepsydra
klepsydra / ST.50209607.statsTable.txt
Created April 2, 2012 19:45
ST.50209607.statsTable.txt
+----------------+---------------+---------------+---------------+
| Performance of Scottrade_50209607, 2012-04-02T00:24:33+02:00 |
+----------------+---------------+---------------+---------------+
|group |Unrealized |Realized |Combined |
+----------------+---------------+---------------+---------------+
| openValueSum | 2347.31 | 3056.22 | 1865.23 |
| closeValueSum | 2365.24 | 3132.37 | 1883.16 |
| gainLossRaw | 17.93 | 76.15 | 94.08 |
| profitSum | 17.93 | 76.15 | 94.08 |
| gainLossPerc | 0.76 | 2.49 | 5.04 |