Skip to content

Instantly share code, notes, and snippets.

jmoz

Block or report user

Report or block jmoz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jmoz
jmoz / rsi.py
Created Sep 27, 2019
RSI calculation to match Tradingview
View rsi.py
import pandas as pd
def rsi(ohlc: pd.DataFrame, period: int = 14) -> pd.Series:
"""See source https://github.com/peerchemist/finta
and fix https://www.tradingview.com/wiki/Talk:Relative_Strength_Index_(RSI)
Relative Strength Index (RSI) is a momentum oscillator that measures the speed and change of price movements.
RSI oscillates between zero and 100. Traditionally, and according to Wilder, RSI is considered overbought when above 70 and oversold when below 30.
Signals can also be generated by looking for divergences, failure swings and centerline crossovers.
@jmoz
jmoz / twitter_favouriter.py
Created Aug 1, 2013
Twitter API favouriter
View twitter_favouriter.py
from twitter import Twitter, OAuth, TwitterHTTPError
OAUTH_TOKEN = 'foo'
OAUTH_SECRET = 'bar'
CONSUMER_KEY = 'baz'
CONSUMER_SECRET = 'bat'
t = Twitter(auth=OAuth(OAUTH_TOKEN, OAUTH_SECRET, CONSUMER_KEY, CONSUMER_SECRET))
@jmoz
jmoz / git_config.sh
Created Jul 25, 2013
Git initial config setup
View git_config.sh
git config --global user.name "James Morris"
git config --global user.email "james@jmoz.co.uk"
git config --global core.editor vim
git config --global color.ui true
@jmoz
jmoz / phpunit_chaining.php
Last active Jan 19, 2016
Phpunit mocking and chaining.
View phpunit_chaining.php
<?php
namespace Foo\Unit;
class Foo
{
public function foo($foo = true)
{
return $foo;
}
View README.md

OEmbed Liquid Tag for Jekyll

This is a simple liquid tag that helps to easily embed images, videos or slides from OEmbed enabled providers. It uses Magnus Holm's great oembed gem which connects to the OEmbed endpoint of the link's provider and retrieves the HTML code to embed the content properly (i.e. an in-place YouTube player, Image tag for Flickr, in-place slideshare viewer etc.). By default it supports the following OEmbed providers (but can fallback to Embed.ly or OoEmbed for other providers):

  • Youtube
  • Flickr
  • Viddler
  • Qik
  • Revision3
  • Hulu
  • Vimeo
@jmoz
jmoz / python_import_this
Created Apr 7, 2013
Python import this
View python_import_this
$ python
Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
@jmoz
jmoz / python-linkedin.py
Last active Dec 14, 2015
An example of client code and XML response from LinkedIn's network_updates endpoint. The access tokens used have requested the rw_nus permission.
View python-linkedin.py
from linkedin import linkedin
import config
li = linkedin.LinkedIn(config.Linkedin.API_KEY, config.Linkedin.API_SECRET, 'http://foo.com')
"""the network_updates endpoint needs rw_nus permission, so do something like this during oauth flow:
li.request_token(['rw_nus', 'r_fullprofile'])
"""
@jmoz
jmoz / ratchet_redis.php
Created Jan 22, 2013
Ratchet and Predis-async. (React and Redis).
View ratchet_redis.php
<?php
use RatchetApp\Pusher;
require __DIR__ . '/../vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$pusher = new Pusher();
$loop->addPeriodicTimer(10, array($pusher, 'timedCallback'));
@jmoz
jmoz / jquery_infinite_scroll.js
Last active Dec 11, 2015
jQuery infinite scroll.
View jquery_infinite_scroll.js
<script type="text/javascript">
$(function(){
$('body > .container').infinitescroll({
navSelector : "div.pagination",
nextSelector : "div.pagination a:last",
itemSelector : "div.item",
bufferPx: 1000,
});
@jmoz
jmoz / twitter_pagination.html
Created Jan 18, 2013
Twitter bootstrap HTML with Pagination object.
View twitter_pagination.html
<div class="pagination pagination-right">
<ul>
<li{% if not pagination.prev_page %} class="disabled"{% endif %}><a {% if pagination.prev_page %}href="{{ url_for('index', page=pagination.prev_page) }}"{% endif %}>Prev</a></li>
{% for page in pagination.pages %}
{% set url_paged = url_for('index', page=page) %}
{% set url_not_paged = url_for('index') %}
<li {% if page == pagination.current_page %}class="active"{% endif %}><a {% if page != pagination.current_page %}href="{% if page == 1 %}{{ url_not_paged }}{% else %}{{ url_paged }}{% endif %}"{% endif %}>{{ page }}</a></li>
{% endfor %}
<li {% if not pagination.next_page %}class="disabled"{% endif %}><a {% if pagination.next_page %}href="{{ url_for('index', page=pagination.next_page) }}"{% endif %}>Next</a></li>
</ul>
You can’t perform that action at this time.