Skip to content

Instantly share code, notes, and snippets.

View davetromp's full-sized avatar

Dave Tromp davetromp

View GitHub Profile
@davetromp
davetromp / login.php
Created September 11, 2012 19:21
Login
<?php
session_start();
if ($_SESSION['login'] == '1'){
echo 'U bent ingelogd';
}
if (!isset($_SESSION['login']) || $_SESSION['login'] == '0') { //als er nog geen sessie is of hij is aan 0 / uitgelogd
if ($_POST['submit']=='Login'){
$query = "SELECT * FROM `users` WHERE `user` = '{$_POST['loginUser']}'";
@davetromp
davetromp / davetromp
Created September 16, 2012 19:59
Virtualhost file
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName davetromp
DocumentRoot /home/davetromp/Lamp
<Directory />
Options FollowSymLinks
AllowOverride All
Allow from all
</Directory>
@davetromp
davetromp / GetDataFromYahooFinance.sh
Created November 18, 2012 16:29
Get data from yahoo finance
#!/bin/bash
# This will be a little script to pull price data from Yahoo finance in order to run a trading stategy on it.
# this function will be called to collect all needed input variabels
function SetVars(){
echo ticker?
read ticker
echo "timeframe (d/w/m)?" # yahoo provide daily, weekly and monthly ohlc prices
read timeframe
@davetromp
davetromp / UpOrDown.sh
Created November 28, 2012 22:29
Bash script that checks if a site is up or down and emails notifications
#!/bin/bash
################################################################################
# This script will check to see if a website is up/down by pinging the url
# If there is no response an email wil be send via an external smtp mail server
# If the site status is down an email will be send when the site is up again
# set your check interval here :-) #############################################
interval=3600 # hour
@davetromp
davetromp / sharpratio.sh
Created December 9, 2012 22:49
This bash script calculates the sharpratio on yahoo finance data
#!/bin/bash
# this script will read in a ohlc file from yahoo finance line by line
# putting every line in a list / array as an element
# and then do some basic calculations on the numbers
# we will calculate the absolute return, the avarage daily differences,
# the standard deviation of the daily differences and finally the sharp ratio
fname=$1
readin(){
@echo off
:: This script checks a files size
:: If it is less then a certain size, it will be switched by a previous
:: version of the file. If the filesize is OK it will be copied to a backup location.
setlocal
:: location of the file
set dir=D:\import
@davetromp
davetromp / csv2loc.py
Created February 24, 2013 22:47
# This python script will loop through a csv file and put the first column in # the id field and the second in the description field of a localization file. # The csv file needs to be UTF-8 encoded. Delimiter is a comma, no quotes please.
import sys
# DT 24-2-2013
# This python script will loop through a csv file and put the first column in
# in the id field and the second in the description field of a localization file.
# The csv file needs to be UTF-8 encoded. Delimiter is a comma, no quotes please.
#write the standaard output to a file
sys.stdout = open('output.xml', 'w')
@davetromp
davetromp / SiteMonitor.py
Created May 25, 2013 21:30
A simple website monitor in python
#!/usr/bin/env python
## Check out: https://github.com/davetromp/SiteMonitor for the complete and current code
import urllib
import smtplib
import time
import datetime
import sys
@davetromp
davetromp / plus500tickers.py
Last active February 28, 2017 22:38
Get links to data referenced by plus500.com
import re
import time
import mechanize
br = mechanize.Browser()
br.set_handle_robots(False) # ignore robots
br.set_handle_refresh(False) # can sometimes hang without this
br.addheaders = [('User-agent', 'Firefox')]
# the code is explained here: https://youtu.be/Eex4zBc9r7Y
import os
def main():
files = os.listdir("./")
for f in files:
if f.lower()[-3:] == "mp4":
print "processing", f
process(f)