Skip to content

Instantly share code, notes, and snippets.

Johan Lindskogen lindskogen

Block or report user

Report or block lindskogen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lindskogen
lindskogen / BluetoothCentral.swift
Last active Jun 17, 2019
Sketch of a BindableObject for finding friends by local PTP
View BluetoothCentral.swift
//
// BluetoothCentral.swift
//
// Created by Johan Lindskogen on 2019-06-16.
// Copyright © 2019 Johan Lindskogen. All rights reserved.
//
import SwiftUI
import CoreBluetooth
import Combine
@lindskogen
lindskogen / ActivityIndicator.swift
Created Jun 12, 2019
SwiftUI Wrapper for UIActivityIndicator
View ActivityIndicator.swift
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()
@lindskogen
lindskogen / fix_steam.sh
Created Aug 9, 2017
Steam case-sensitivity macOS
View fix_steam.sh
#!/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 / find_circles.py
Created Jun 26, 2017
ML circle detection
View find_circles.py
# 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 / checkbox.js
Created Jun 26, 2017
Accessible checkbox in react
View checkbox.js
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 / convertDraftToHTML.js
Created May 23, 2017
Convert DraftJS ContentState to html (only plaintext and mentions)
View convertDraftToHTML.js
// @flow
import { RawDraftContentState } from 'draft-js'
type Mention = {
link: string,
name: string,
fullName: ?string,
id: number,
avatar: string
}
View index.html
<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;
View active_record_log_subscriber.rb
# 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 / nomad-login.sh
Created May 25, 2015
Nomad login via curl or wget
View nomad-login.sh
# 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 / sf.js
Created Mar 22, 2015
sf.se set Gothenburg as city, "no" expire
View sf.js
document.cookie = "ActiveCity__www.sf.se__sv=Z2JfX19nJWMzJWI2dGVib3Jn; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/"
You can’t perform that action at this time.