Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am originell on github.
  • I am luisnell (https://keybase.io/luisnell) on keybase.
  • I have a public key ASBSXlh0oSykmXPzBbtfCfhn7L78G_MEjr3WiytHvw1U-go

To claim this, I am signing this object:

@originell
originell / PATH.md
Last active January 11, 2019 11:12
Small Fish Intro

Notes about $PATH

You are probably used to lines like these in your shell config:

export PATH="/usr/local/opt/gettext/bin:$PATH"

Now, $PATH can also be modified like this in fish. However, it would not be very idiomatic.

@originell
originell / keybase.md
Created September 26, 2017 11:26
keybase.md

Keybase proof

I hereby claim:

  • I am originell on github.
  • I am luisnell (https://keybase.io/luisnell) on keybase.
  • I have a public key ASB2zMHH4q3XTjUnERLfXYbpsesbZbpZpfo-FhUDUDffMgo

To claim this, I am signing this object:

@originell
originell / navStyleChanger.js
Last active August 29, 2015 14:20
Example: detect scroll position and change navi style
// Navigationbar to be changed (cached here for performance, always grabbing
// it new in the scroll-callback is bad for performance)
var $navi = $('.myNav')
function changeNavStyle() {
var top = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
if (top > 200) {
$navi.addClass('.myNewStyle-Yo')
} else {
@originell
originell / TopMostViewController.swift
Created January 7, 2015 23:31
Reliably get the top most UIViewController. Tested with iOS7 and 8
// Note: There are no fancy error checks in here. This is just meant to quickly demonstrate this.
// I was extremely frustrated because most posts on stackoverflow are missing the important point
// of checking for the "presentedViewController".
// If you are working in a view that is *already living* in the view hierarchy.
var topMostController = view.window!.rootViewController!
// or
// If you don't have a view in the hierarchy yet (as it might happen in viewDidLoad etc.)
// (there is also the possibility to use UIApplication.sharedApplication().keyWindow, though it seems
// that the internet's general opinion is that it's safer to use the delegate's window)
@originell
originell / RubberBand.md
Last active August 26, 2024 05:20
This is a straight copy of – to avoid this ever going dark http://squareb.wordpress.com/2013/01/06/31/

Analysis of Apple’s rubber band scrolling

January 6, 2013

I recently saw a post on Twitter from @chpwn that described the alogorithm that Apple uses for its “rubber band” or “bungee” scrolling.

b = (1.0 – (1.0 / ((x * c / d) + 1.0))) * d
@originell
originell / extract_exceptions.py
Created February 27, 2012 10:29
Python Traceback Extractor from text/log files.
"""
Extract unique Python-Exceptions with their Traceback from a log/text file.
Usage::
python extract_exceptions.py -f logfile.txt
Furthermore it supports excluding exceptions you don't want to have::
python extract_exceptions.py -f logfile.txt -e ValueError,AttributeError
@originell
originell / form_to_array.py
Created May 11, 2011 19:39
XHTML 1.1 form to PHP Array.
# coding: utf-8
"""
Convert a XHTML 1.1 compliant form to a php array with Python (YIKES! :D)
"""
import re
# Put your form in here!
s = """
<form action="foobar.php" method="post" accept-charset="utf8">
@originell
originell / test.py
Created May 4, 2011 16:24
Fastes way to search for something in a list
import pytz
import re
"""
Trying to find a fast way to search through a list.
As example we use pytz's all_timezones list and set, which
are both pretty nicely filled with strings.
OSX 10.6.7, 2.53ghz Core2Duo:
@originell
originell / uri_regex_test.py
Created April 22, 2011 14:17
Trying to build a regex validating the given URIs
#!/usr/bin/env python
# encoding: utf-8
"""
Build URL Validation Regex.
See the according *\_urls list for a definition of what we
want to match and what not.
Note that according to RFC 2612 (HTTP 1.1, Section 3.1.2) there is
no such thing as a maximum URI length. Since servers should