Skip to content

Instantly share code, notes, and snippets.

View mackuba's full-sized avatar
🌤️
Playing with Bluesky API

Kuba Suder mackuba

🌤️
Playing with Bluesky API
View GitHub Profile
@mackuba
mackuba / ip-monitor.sh
Created April 22, 2013 21:40
Monitors external IP address using curlmyip.com and sends an email when it changes (should be run from cron)
#!/bin/bash
FILE="$HOME/ip-monitor.txt"
OLD_IP=`cat $FILE`
CURRENT_IP=`curl -s http://curlmyip.com`
EMAILS="my.address@gmail.com"
SUBJECT="IP address changed"
FROM="IP Address Bot <root@localhost>"
if [ "$CURRENT_IP" ]; then
@mackuba
mackuba / oauth_generator.rb
Last active December 17, 2015 02:38
Generates OAuth access key & secret for Twitter apps
#!/usr/bin/env ruby
consumer_key = ENV['KEY']
consumer_secret = ENV['SECRET']
unless consumer_key && consumer_secret
puts "Please set consumer key and secret from your Twitter app's settings: KEY=... SECRET=... ruby oauth_generator.rb"
exit 1
end
@mackuba
mackuba / rupy_2012_notes.md
Last active December 17, 2015 22:09
Notes from RuPy 2012 (http://12.rupy.eu)

Javascript as language for native apps (Stepan Bechynsky)

  • Windows RT - new system library for Windows apps, unified for Intel and ARM computers and tablets
    • can be used from C++, C# (with XAML) or HTML/Javascript apps
    • HTML/Javascript apps can access the whole RT API and standard browser API
    • WinJS - Javascript bindings for WinRT and application framework
  • Visual Studio 2012 is needed to build the app, but most of the work can be done on any OS, as it’s mostly just JS
  • controls: <div data-win-control="WinJS.UI.ToggleSwitch" data-win-options="{title: '...'}">
  • access from JS to any system APIs, like camera capture, updating live tiles
  • package.appmanifest - application config, e.g. permissions that the app requests from the user
@mackuba
mackuba / hive_joel.md
Last active December 17, 2015 23:38
Notes from the Hive53 meetup with Joel Spolsky (14.05.2013)

(This is mostly based on this post from 2000.)

There are two types of startups you can create. You have to know from the start which one it’s going to be. If you can't decide, or start using the rules from the wrong kind of startup, you’ll probably lose.

Type 1: Get Big Fast startup

  • Stack Overflow, Facebook, Yelp, Amazon, Trello
  • has to grow quickly
  • concentrates on getting as many users as possible in order to earn money in the future in some way
  • relies on VC money
@mackuba
mackuba / skype_history_export.sh
Created October 22, 2013 15:35
Exports the history of conversations with a specific person from Skype (OSX) to an HTML file
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <your_username> <contact_username>"
exit 1
fi
echo "<!DOCTYPE html><html><head>"
echo "<style>"
echo "table { border-collapse: collapse; width: 800px; }"
@mackuba
mackuba / decapsify.rb
Last active January 3, 2016 14:08
Clean up stupid docs that CAPITALIZE words like MUST or SHOULD and make it very HARD to READ such TEXT.
#!/usr/bin/env ruby
STDIN.each_line do |line|
print line.gsub(/\b[A-Z]{2,}\b/) { |word| word.downcase }
end
@mackuba
mackuba / swift_programming_language_b3.md
Last active June 11, 2016 17:11
I made a diff of the versions of Swift ebooks between the early June and early July versions. I'm not sure if I can post it publicly, but here's a summary of what's updated:
  • across all sections:

    • changed all occurrences of the a..b operator to a..<b
    • changed all occurrences of a Something[] array type to [Something]
    • changed some occurrences of an Array(values) array initialization to [Something](values)
    • changed some occurrences of a Dictionary<Key, Value> dictionary type to [Key: Value]
  • Swift Tour:

    • added a line:
@mackuba
mackuba / MKAnnotationView-v1.swift
Last active August 17, 2016 12:55
Swift MKAnnotationView WTF
/*
MKAnnotationView has one init listed in its documentation, initWithAnnotation:reuseIdentifier:, so let's override that.
But this causes a runtime exception:
fatal error: use of unimplemented initializer 'init(frame:)' for class 'PulsatingDotMarker'
*/
class PulsatingDotMarker: MKAnnotationView {
let innerCircle: UIView
@mackuba
mackuba / macbook-pro-2016.md
Created January 18, 2017 03:06
MacBook Pro 2016 - an iOS developer's review

MacBook Pro 2016 - an iOS developer's review

Here are some thoughts about my new MacBook Pro that I've been using for the last few weeks (the Santa Claus from DHL brought it to me just before Christmas), hopefully this will help someone who's considering getting one.

Note: this is written from the perspective of a person who switched to the MBP from a 2015 13" MacBook Air (i7) and also has a 2012 21" iMac. Your experiences will obviously be different if you have e.g. a fairly recent 15" Retina MacBook Pro.

Specs

  • MacBook Pro 15", late 2016
  • Core i7 2.9 GHz (4 cores)
@mackuba
mackuba / find_long_names.rb
Last active December 11, 2019 18:00
Finding the longest names in Cocoa
#!/usr/bin/ruby
# find /Applications/Xcode.app/Contents/Developer/Platforms -name '*.h' | ruby find_long_names.rb > names.txt
names = []
STDIN.each_line do |line|
path = line.strip
begin
File.open(path, "r") do |file|