Skip to content

Instantly share code, notes, and snippets.

View lindskogen's full-sized avatar
🏃‍♂️

Johan Lindskogen lindskogen

🏃‍♂️
View GitHub Profile

Keybase proof

I hereby claim:

  • I am lindskogen on github.
  • I am jlindsk (https://keybase.io/jlindsk) on keybase.
  • I have a public key whose fingerprint is F9FB 80B7 28C7 C523 F818 5DB4 4322 9229 4C53 7B06

To claim this, I am signing this object:

@lindskogen
lindskogen / sf.js
Created March 22, 2015 13:30
sf.se set Gothenburg as city, "no" expire
document.cookie = "ActiveCity__www.sf.se__sv=Z2JfX19nJWMzJWI2dGVib3Jn; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/"
@lindskogen
lindskogen / nomad-login.sh
Created May 25, 2015 12:30
Nomad login via curl or wget
# Using curl:
curl 'https://login.nomad.chalmers.se' --data 'action=Login&login=$USERNAME/net&password=$PASSWORD&org=Radius'
# Using wget: (on Ubuntu for example)
wget 'https://login.nomad.chalmers.se' --post-data 'action=Login&login=$USERNAME/net&password=$PASSWORD&org=Radius'
@lindskogen
lindskogen / active_record_log_subscriber.rb
Created November 21, 2016 13:31
ActiveRecordLogSubscriber
# Drop this into config/initializers to print line number of each query called by ActiveRecord
module LogQuerySource
def debug(*args, &block)
return unless super
backtrace = Rails.backtrace_cleaner.clean caller
relevant_caller_line = backtrace.detect do |caller_line|
!caller_line.include?('/initializers/')
@lindskogen
lindskogen / index.html
Created April 5, 2017 11:30
Swish Redirect
<html>
<head>
<title>Swish redirect</title>
<script>
var search = window.location.search;
var params = search.substr(1).split('&').map(function(arg){
return arg.split('=', 2);
}).reduce(function(acc, items) {
acc[items[0]] = decodeURIComponent(items[1]);
return acc;
@lindskogen
lindskogen / convertDraftToHTML.js
Created May 23, 2017 09:00
Convert DraftJS ContentState to html (only plaintext and mentions)
// @flow
import { RawDraftContentState } from 'draft-js'
type Mention = {
link: string,
name: string,
fullName: ?string,
id: number,
avatar: string
}
@lindskogen
lindskogen / checkbox.js
Created June 26, 2017 14:59
Accessible checkbox in react
import React, { PureComponent } from 'react';
import cx from 'classnames';
import './checkbox.styl';
const SPACE_KEY = 32;
const filterSpacePressed = (event, callback) => {
if (event.which === SPACE_KEY) {
event.preventDefault();
@lindskogen
lindskogen / find_circles.py
Created June 26, 2017 16:32
ML circle detection
# Standard imports
import cv2
import numpy as np
# Read image
img = cv2.imread("IMG_20170624_152655.jpg", 0)
img = cv2.medianBlur(img, 5)
cimg = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
# Set up the detector with default parameters.
@lindskogen
lindskogen / fix_steam.sh
Created August 9, 2017 16:29
Steam case-sensitivity macOS
#!/bin/bash
## Try to use following solution.
## ------------------------------------
USER=$(whoami)
cd /Users/$USER/Library/Application\ Support/Steam/Steam.AppBundle/Steam/Contents/MacOS/public; ls *.res | while read line ; do file=$(echo $line | tr '[:upper:]' '[:lower:]'); mv $line $file; done
cd /Users/$USER/Library/Application\ Support/Steam/Steam.AppBundle/Steam/Contents/MacOS/steam/cached/; ls *.res | while read line ; do file=$(echo $line | tr '[:upper:]' '[:lower:]'); mv $line $file; done
cd /Users/$USER/Library/Application\ Support/Steam/Steam.AppBundle/Steam/Contents/MacOS/friends; ls *.res | while read line ; do file=$(echo $line | tr '[:upper:]' '[:lower:]'); mv $line $file; done
cd /Users/$USER/Library/Application\ Support/Steam/Steam.AppBundle/Steam/Contents/MacOS/graphics; ls *.res | while read line ; do file=$(echo $line | tr '[:upper:]' '[:lower:]'); mv $line $file; done
cd /Users/$USER/Library/Application\ Support/Steam/Steam.AppBundle/Steam/Contents/MacOS/servers; ls *.res | while read l
@lindskogen
lindskogen / ActivityIndicator.swift
Created June 12, 2019 21:01
SwiftUI Wrapper for UIActivityIndicator
import SwiftUI
import UIKit
struct ActivityIndicator : UIViewRepresentable {
var animating: Bool
var hidesWhenStopped = true
var style: UIActivityIndicatorView.Style = UIActivityIndicatorView.Style.medium
func makeUIView(context: Context) -> UIActivityIndicatorView {
let control = UIActivityIndicatorView()