Skip to content

Instantly share code, notes, and snippets.

View VeryCrazyDog's full-sized avatar

VCD VeryCrazyDog

View GitHub Profile
@VeryCrazyDog
VeryCrazyDog / sports-tracker-download.js
Last active May 7, 2023 07:59 — forked from bilan/sports-tracker-download.js
Download all workouts from sports-tracker
// VCD: Change folder and file name, add metadata file, script shall be executed in Google Chrome.
// 'Show more' button shall be pressed until all workout are shown on page. You might have
// to manually filter out some control characters in the generated script. Works on 2020-11-21.
//
// Bilan: My fork fixed some api changes, added images downloading and informative gpx file names. Works on 2020/11/02.
//
// You can then upload it to Strava using this oneliner:
// find * -name '*.gpx' -print0 | while read -d $'\0' i; do ID=`echo $i | sed 's/.*id--//' | sed 's/--activity.*//'`; ACTIVITY=`echo $i | sed 's/.*--activity--//' | sed 's/--title.*//'`; NAME=`echo $i | sed 's/--file.gpx//' | sed 's/.*--title--//'`" ($ID/$ACTIVITY)"; echo "\n$NAME\n"; curl -X POST https://www.strava.com/api/v3/uploads -H "Authorization: Bearer ___TOKEN___" -F file=@"$i" -F data_type="gpx" -F description="SportsTracker import" -F name="$NAME" -F external_id="$i"; sleep 10;done
//
// Original description:
@VeryCrazyDog
VeryCrazyDog / template_confirm.sh
Created March 31, 2016 01:26
Shell script template with confirmation
#!/bin/sh
read -r -p "Are you sure you want to continue? [y/N] " response
# Convert to lower case
response=${response,,}
if [[ ! $response =~ ^(yes|y)$ ]]
then
exit 0
fi
@VeryCrazyDog
VeryCrazyDog / helper_func.php
Last active August 29, 2015 14:27
Helper Functions
<?php
// String
function startsWith($haystack, $needle) {
return $needle === '' || strrpos ( $haystack, $needle, - strlen ( $haystack ) ) !== false;
}
function endsWith($haystack, $needle) {
$length = strlen ( $needle );
return (substr ( $haystack, - $length, $length ) === $needle);
}
@VeryCrazyDog
VeryCrazyDog / win8_keyboard_keyout.ps1
Last active July 8, 2018 13:48
Setting Keyboard Layout to US in Chinese Traditional (Hong Kong) Language for Windows 8, 8.1, 10
# More information at
# https://vicidi.wordpress.com/2014/10/19/setting-keyboard-layout-to-us-in-chinese-traditional-hong-kong-language-for-windows-8/
# Please notice that this won't work on Windows 7
# WARNING: This will clear your language list setting
# Determine Windows version
$WindowsVersion = [System.Environment]::OSVersion.Version.Major * 10 + [System.Environment]::OSVersion.Version.Minor
if ($WindowsVersion -ge 62) {
# Windows 8 or higher
@VeryCrazyDog
VeryCrazyDog / build_rpm_from_src.sh
Last active August 29, 2015 14:16
Building Linux RPM Package from Source Code
# Building Linux RPM Package from Source Code
# Referencing from https://gist.github.com/fernandoaleman/1376973
# Step: 1
# Install rpmbuild
yum install rpm-build
# Step: 2
# Create rpmbuild folders in your home directory
@VeryCrazyDog
VeryCrazyDog / ReadUtfFile.cpp
Last active August 28, 2023 13:31
UTF File to UTF-8 in std::string in C++ on Windows
// Reading ASCII, UTF-8, UTF-16LE, UTF-16BE with auto BOM detection using C++11 on Windows platform
// Code tested on Microsoft Visual Studio 2013 on Windows 7
// Part of the code is referencing http://cfc.kizzx2.com/index.php/reading-a-unicode-utf16-file-in-windows-c/
#include <stdio.h>
#include <tchar.h>
#include <string>
#include <fstream>
#include <sstream>
#include <locale>