Skip to content

Instantly share code, notes, and snippets.

View burczyk's full-sized avatar

Kamil Burczyk burczyk

  • Kraków, Poland
View GitHub Profile
@burczyk
burczyk / uploader.sh
Last active October 31, 2020 14:06
Strava gpx importer
#!/bin/bash
for i in {1..100}
do
file=`ls gpx | head -n 1`
echo $file
curl -X POST https://www.strava.com/api/v3/uploads -H "Authorization: Bearer ACCESS_TOKEN" -F data_type="gpx" -F file=@gpx/$file
mv gpx/$file gpx-done
echo
echo
@burczyk
burczyk / exporter.js
Created October 31, 2020 13:10
endomondo-exporter
require('cross-fetch/polyfill');
const fs = require('fs');
const { Api } = require('endomondo-api-handler');
const { DateTime } = require('luxon');
const api = new Api();
(async () => {
await api.login("YOUR_ENDOMONDO_EMAIL", "YOUR_ENDOMONDO_PASSWORD");
@burczyk
burczyk / quicksort.swift
Created January 2, 2015 11:51
Quicksort the Swift way
var list = [8,1,55,34,13,8,5,0,1,3,2,21]
func quicksort1(list:[Int]) -> [Int] {
if list.count == 0 {
return []
}
let pivotValue = list[0]
let smaller = filter(list, { $0 < pivotValue })
smaller
@burczyk
burczyk / .gitconfig
Created January 29, 2014 16:52
.gitconfig backup
[user]
name = Kamil Burczyk
email = kamil.burczyk@sigmapoint.pl
[core]
excludesfile = /Users/kamil/.gitignore_global
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
@burczyk
burczyk / const.c
Created January 28, 2014 13:46
const int VS int const
The trick is to read the declaration backwards (right-to-left):
const int a = 1; // read as "a is an integer which is constant"
int const a = 1; // read as "a is a constant integer"
Both are the same thing. Therefore:
a = 2; // Can't do because a is constant
The reading backwards trick especially comes in handy when you're dealing with more complex declarations such as:
const char *s; // read as "s is a pointer to a char that is constant"
@burczyk
burczyk / UIImage+Color.h
Created August 2, 2013 08:34
UIImage shorthand to create UIImage with specified color and size. It can be used e.g. to stylize UITabBar or UINavigationBar with single-color image in place.
#import <UIKit/UIKit.h>
@interface UIImage (Color)
+ (UIImage *)imageWithColor:(UIColor *)color andSize:(CGSize)size;
@end
@burczyk
burczyk / UIColor+Shorthand.h
Created August 2, 2013 08:32
UIColor shorthand which allows to define colors directly from RGB elements (0-255) instead of floats.
#import <UIKit/UIKit.h>
@interface UIColor (Shorthand)
+ (UIColor*) colorWithR: (unsigned char) r G: (unsigned char) g B: (unsigned char) b A: (float) a;
@end
@burczyk
burczyk / Constants.h
Created July 30, 2013 08:05
Some useful iOS development macros
#ifndef Constants_h
#define Constants_h
#pragma mark some useful macros
#define DEFAULTS [NSUserDefaults standardUserDefaults]
#define DEFAULTS_SET(key, value) [[NSUserDefaults standardUserDefaults] setObject:value forKey:key]; [[NSUserDefaults standardUserDefaults] synchronize];
#define INSTANTIATE(viewController) [[UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil] instantiateViewControllerWithIdentifier:viewController];
#define INSTANTIATE_VIEW(name) [[[NSBundle mainBundle] loadNibNamed:name owner:self options:nil] objectAtIndex:0];
@burczyk
burczyk / LoggersInitialization
Last active December 20, 2015 08:49
iOS initialization for crash stack traces and Cocoa Lumberjack loggers
#import "DDASLLogger.h"
#import "DDTTYLogger.h"
int ddLogLevel = LOG_LEVEL_VERBOSE;
#pragma mark Initialization
- (void) initializeLoggers {
[DDLog addLogger:[DDASLLogger sharedInstance]];
[DDLog addLogger:[DDTTYLogger sharedInstance]];
[[DDTTYLogger sharedInstance] setColorsEnabled:YES];
@burczyk
burczyk / LLDB recursive view description
Created April 10, 2013 08:48
LLDB command for recursive view output during debugging
po [[self view] recursiveDescription]