Skip to content

Instantly share code, notes, and snippets.

@oscarsan
oscarsan / main.py
Created October 17, 2021 08:27
Python 3 scripts export whoop workout data between 2 dates and creates TCX file for importing to trainingPeaks
#!/usr/bin/env python3
import requests # for getting URL
import json # for parsing json
from datetime import datetime # datetime parsing
import pytz # timezone adjusting
import xmlschema
#################################################################
# USER VARIABLES
//Paul Tero, July 2001
//http://www.tero.co.uk/des/
//
//Optimised for performance with large blocks by Michael Hayworth, November 2001
//http://www.netdealing.com
//
//THIS SOFTWARE IS PROVIDED "AS IS" AND
//ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
//IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
//ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
@oscarsan
oscarsan / rakefile.rb
Created June 11, 2016 16:37
rake to dump woocommerce products onto mongodb
require 'Mysql2'
require 'json'
require 'mongo'
namespace :db do
task :backup do
client = Mysql2::Client.new(:host => "localhost", :socket => '/Applications/MAMP/tmp/mysql/mysql.sock', :username => "root", :database => "elrinconecologico_db", :password => "root")
mongo_client = Mongo::Client.new('mongodb://127.0.0.1:27017/database')
products = client.query("SELECT * FROM wp_posts where post_type='product' and post_name <> ''")
products.each do |product|
@oscarsan
oscarsan / boxlistener
Created May 20, 2015 07:43
Simple HTTP listener
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
@oscarsan
oscarsan / gist:d0819f17b10641d16a0e
Created May 15, 2015 13:53
Ruby tcpsocket server
require 'socket' # Get sockets from stdlib
server = TCPServer.open(5000) # Socket to listen on port 2000
counter = 0;
loop do
client = server.accept # Wait for a client to connect
while line = client.gets # Read lines from socket
puts line # and print them
end
client.puts "Hello this is a test by oscar #{counter}"
@oscarsan
oscarsan / gist:2af5c797516d9ee28325
Created January 21, 2015 12:06
YAMLDOTNET sample
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YamlDotNet.Serialization;
namespace YamlDotNet.Samples
{
public class SerializeObjectGraph
{