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 / 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|
@mackuba
mackuba / gist:1031086
Created June 17, 2011 08:48
Kanbanery column width bookmarklet
javascript:(function(){var w=prompt("Enter column width in pixels (press enter for default):"); w = w && parseInt(w, 10) || 300; $('.column-view-body').css('width', w + 'px'); $('.column-view').css('max-width', w + 'px'); $('.ul-columns-section-body').css('width', ($('.column-view-body').length * (w + 15)) + 'px');})()
@mackuba
mackuba / kanbanery_multi_filter.js
Created October 24, 2011 13:04
Kanbanery multi-task-type filter
javascript:(function() { var list = prompt("Enter list of task types to show, separated by commas (leave empty to show all):"); var wait = $("<p>Please wait…</p>").css({ 'font-size': '20px', 'color': 'white', position: 'absolute', top: '10px', left: '500px', width: '150px' }).appendTo($('body')); setTimeout(function() { if (!list) { $('.task-view').each(function(i, t) { $(t).show() }); } else { $('li.placeholder').each(function(i, pl) { $(pl).view().showRealView() }); var types = _.map(list.split(','), function(el) { return $.trim(el.toLowerCase()) }); $('.task-view').each(function(i, t) { var label = $('.disp-task-type-name', t); var type = $.trim($(label).text().toLowerCase()); if (_.indexOf(types, type) == -1) { $(t).hide(); } else { $(t).show(); } }); } wait.remove(); }, 10);})();
@mackuba
mackuba / kill_utm.js
Created October 27, 2011 12:41
Bookmarklet which deletes that utm_* crap from the URL
javascript:(function() { var s = ""; var args = location.search.substring(1).split('&'); for (var a = 0; a < args.length; a++) { var key = args[a].split('=')[0]; if (!key.match(/^utm_/)) { s += '&' + args[a]; }} if (s) { s = '?' + s.substring(1); } location.href = location.origin + location.pathname + s; })()
@mackuba
mackuba / gist:1346371
Last active September 27, 2015 23:08
Benchmark - running an empty spec file on Ruby 1.9.2 vs 1.9.3
### without spork
$ rvm 1.9.2
$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]
$ time bundle exec rspec spec/controllers/notifications_controller_spec.rb
No DRb server is running. Running in local process instead ...
No examples found.
Finished in 0.10633 seconds
@mackuba
mackuba / install.sh
Created April 26, 2012 15:46
Link all dotfiles from Dropbox
#!/bin/bash
for filename in `ls /Users/psionides/Dropbox/dotfiles`; do
name=`basename $filename .txt`
echo "Linking /Users/psionides/Dropbox/dotfiles/$filename to /Users/psionides/.$name..."
rm -f /Users/psionides/.$name
ln -s /Users/psionides/Dropbox/dotfiles/$filename /Users/psionides/.$name
done
echo "Done."
@mackuba
mackuba / symbolicate.rb
Created July 13, 2012 14:09
A script to symbolicate iOS crash logs
#!/usr/bin/env ruby
app = ARGV[0]
executable = app + "/" + app[/[\w\-]+\.app/].split('.').first
lines = STDIN.read
lines.each do |l|
if l =~ /PCRM/
address = l[/0x\w\w+/]
decoded = `atos -arch armv7 -o #{executable} #{address}`.strip
print l.gsub(/\+ .*$/, decoded)
@mackuba
mackuba / lambda_lounge_notatki.md
Last active December 15, 2015 19:49
Notes from Kraków Lambda Lounge meetup [PL]

Notatki z Lambda Lounge meetup

Ogólnie:

  • immutability
  • higher-order functions
  • first-class functions
  • stan przekazywany explicit w argumentach, a nie przechowywany gdzieś tam i zmieniany w miejscu przez nie wiadomo kogo
  • referential transparency - funkcja dostając dane argumenty zawsze zwróci tą samą wartość
  • nie ma rozróżnienia na == vs. equals
@mackuba
mackuba / configure_project.sh
Last active December 16, 2015 02:59
Creates copies of all example config files in the project and shows them to you in the editor for tweaking/confirmation.
#!/bin/bash
for FILE in $(find config -name '*.sample' -or -name '*.example'); do
COPY=$(echo "$FILE" | sed -E -e 's/\.[^.]+$//')
if [ ! -e "$COPY" ]; then
cp "$FILE" "$COPY"
echo "Created $COPY"
if [ "$EDITOR" ]; then
$EDITOR "$COPY"
@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