Skip to content

Instantly share code, notes, and snippets.

View guarani's full-sized avatar
👋

Paul Von Schrottky guarani

👋
View GitHub Profile
This interactive iOS Safari bookmarklet lets you search for jobs on the HN Who is Hiring thread from an iOS device.
Go to the HN Who is Hiring thread, make a bookmark, change the title to "HN Job Searcher" and replace the address with the following (paste in):
javascript:void(function(){ var a=prompt('Enter keywords:').split(' ');var c=document.getElementsByClassName('athing');var r=[];for(var i=0;i<c.length;i++){ var m=0; for(var j=0;j<a.length;j++) { if (c[i].innerText.toLowerCase().indexOf(a[j].toLowerCase()) > -1) { m++; } } if (m==a.length) { r.push(c[i])} };var z=function(x, y) { x.onclick=function(){y.scrollIntoView();}}; for(var i=0;i<r.length;i++) {r[i].style.backgroundColor='orange';z(r[i], r[i+1])};r[0].scrollIntoView();}())
Then open the bookmark as you normally would while on the thread. In the popup that appears type your job criteria, e.g. "javascript remote", and the results are shown. Tap on a result to go to the next one. Reload the page and open the bookmark again to search again.
@guarani
guarani / playground.swift
Last active December 29, 2021 09:22
Dining Philosophers Problem in Swift with NSOperationQueue
//
// A Swift implementation of the Dining Philosophers Problem:
// https://en.wikipedia.org/wiki/Dining_philosophers_problem
//
//
// P0
// f3 f0
// P3 P1
// f2 f1
// P2
@guarani
guarani / gist:65ade8d7fde7184d6f05
Created April 8, 2015 02:05
A UITableView scrolls to whole UITableViewCells
func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
println("scrollViewWillEndDragging")
println("targetContentOffset: \(targetContentOffset.memory.y)")
var targetContentOffsetCorrected: CGPoint = targetContentOffset.memory
targetContentOffsetCorrected.y += contentInsetY
println("targetContentOffsetCorrected: \(targetContentOffsetCorrected.y)")
let targetCellIndexPath = self.tableView.indexPathForRowAtPoint(targetContentOffsetCorrected)
println("targetCellIndexPath row: \(targetCellIndexPath?.row)")