Skip to content

Instantly share code, notes, and snippets.

View TENorbert's full-sized avatar

DTEN TENorbert

  • US
View GitHub Profile
@TENorbert
TENorbert / get_previous_current_and_next_item.py
Created December 21, 2018 17:31
Get previous, Current and Next Items from any iterable object in Python 3
from itertools import tee, islice, chain
def get_previous_current_and_next(iterable_object):
prev_item, cur_item, next_item = tee(iterable_object, 3)
prev_item = chain([None], prev_item)
next_item = chain(islice(next_item, 1, None), [None])
return zip(prev_item, cur_item, next_item)
# Test Code:
@TENorbert
TENorbert / Create Forms with datepicker Dynamically using javascript
Last active December 14, 2018 17:56
This simple javascript anables you to dymanically create multiple objects (forms with datepicker). selector is the specific object you want to dynamically create, e.g for table rows <tr> call like so: cloneFormObject('.tr:last', 'gates');
function cloneFormObject(selector, prefix) {
var currentElement = $(selector)
var formCount = parseInt($('#id_' + prefix + '-TOTAL_FORMS').val());
$(currentElement).find('input.date_picker').datepicker({dateFormat:"M-dd-yy", minDate:0, autoclose:true});
var newElement = $(currentElement).clone(true).get(0);
$(newElement).removeAttr('id').insertAfter($(currentElement)).children('.hidden').removeClass('hidden');
$(newElement).find(':input').each(function() {
@TENorbert
TENorbert / bluetooth.py
Created May 9, 2017 17:52 — forked from tito/bluetooth.py
Bluetooth example on Android using Python / Pyjnius
'''
Bluetooth/Pyjnius example
=========================
This was used to send some bytes to an arduino via bluetooth.
The app must have BLUETOOTH and BLUETOOTH_ADMIN permissions (well, i didn't
tested without BLUETOOTH_ADMIN, maybe it works.)
Connect your device to your phone, via the bluetooth menu. After the
pairing is done, you'll be able to use it in the app.
@TENorbert
TENorbert / bluetooth_kivy.py
Created May 9, 2017 17:49 — forked from cuibonobo/bluetooth_kivy.py
Bluetooth example with Kivy. A more fleshed-out example here: https://github.com/tito/android-demo. A more modern way of doing it: https://github.com/kivy/plyer. And this guy used Kivy to connect to an Arduino: https://github.com/brean/arduino-kivy-bluetooth. Native Kivy code (?): https://groups.google.com/d/msg/kivy-users/n_cMbFzf_1A/5edKgQgycx0J
# Same as before, with a kivy-based UI
'''
Bluetooth/Pyjnius example
=========================
This was used to send some bytes to an arduino via bluetooth.
The app must have BLUETOOTH and BLUETOOTH_ADMIN permissions (well, i didn't
tested without BLUETOOTH_ADMIN, maybe it works.)
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
@TENorbert
TENorbert / global_tag
Last active August 29, 2015 14:15 — forked from nsahoo/global_tag
# 2012 mc
START53_V19F::All
# 2011 mc
START42_V14B::All
START53_LV6A1::All (7TeV MC "Legacy" reprocessing in CMSSW_5_3_X)
# 2012 data
FT53_V21A_AN6::All