Skip to content

Instantly share code, notes, and snippets.

View fohlin's full-sized avatar

Fredrik Ohlin fohlin

View GitHub Profile

Keybase proof

I hereby claim:

  • I am fohlin on github.
  • I am fohlin (https://keybase.io/fohlin) on keybase.
  • I have a public key ASACLpse4FVfa6ARM1frmqj5V1jpm-_4507R3VfMjE_U1go

To claim this, I am signing this object:

@fohlin
fohlin / loopy.py
Created November 26, 2019 21:30
Loopy
items = ['a', 'b', 'c']
# A
for x in items:
print(x)
# B
my_iterator = iter(items)
for y in my_iterator:
print(y)
const caniuse = require('caniuse-api');
const featureSupport = {};
const features = [
'classlist',
'element-closest',
'es6-module',
'es6-class',
'fetch',
'promises',
var httpProxy = require('http-proxy');
var proxy = httpProxy.createProxyServer({target:'http://localhost:3000'});
proxy.on('proxyReq', function(proxyReq, req, res, options) {
console.info(req);
res.setHeader('X-Special-Proxy-Header', 'foobar');
proxyReq.setHeader('X-Special-Proxy-Header', 'foobar');
});

Köra DrJava på Mac (macOS Sierra och OS X El Capitan)

Ladda hem DrJava som JAR-fil och kör med senaste versionen av Java JDK. Gör så här:

  1. Installera Java JDK.

    1. Scrolla till rubriken Java SE Development Kit 8u111, välj "Accept License Agreement", och ladda hem jdk-8u111-macosx-x64.dmg.
  2. Kör denna fil och följ instruktionerna.

@fohlin
fohlin / archiveTwitter.py
Created August 16, 2012 18:16 — forked from mjbommar/archiveTwitter.py
Archive tweets from a search term going backwards through search.
'''
@author Michael J Bommarito II
@date Feb 26, 2011
@license Simplified BSD, (C) 2011.
This script demonstrates how to use Python to archive historical tweets.
'''
import codecs
import csv
@fohlin
fohlin / forms.py
Created January 8, 2011 18:50
A version of Django's UserCreationForm that uses email instead of username, with some nifty features. (Maybe not super robust yet, in terms of concurrency...)
import re
from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
class UniqueUserEmailField(forms.EmailField):
"""
An EmailField which only is valid if no User has that email.
"""
def validate(self, value):
# Using the OS X "say" command to demo inheritance
# Thanks to Simon Willison for inspiration: http://gist.github.com/267147
import subprocess
def say(s):
subprocess.call(['say', str(s)])
class SpeakingList(list):
"""This custom list speaks (if you're on OS X). Amazing!"""