Skip to content

Instantly share code, notes, and snippets.

View skovhus's full-sized avatar

Kenneth Skovhus skovhus

View GitHub Profile
@skovhus
skovhus / flow-to-typescript-codemod.sh
Last active May 26, 2022 16:27
Quick and dirty flow-to-typscript migration codemod
#!/bin/sh
#
# This is a super quick and dirty codemod for migration a codebase from Flow to TypeScript.
#
# Step 1:
# npm i -g jscodeshift
# Step 2: rename all .js files to .ts(x)
# find src -name "*.js" -exec sh -c 'mv "$0" "${0%.js}.ts"' {} \;
# find storybook -name "*.js" -exec sh -c 'mv "$0" "${0%.js}.ts"' {} \;
# find src/**/components -name "*.ts" -exec sh -c 'mv "$0" "${0%.ts}.tsx"' {} \;
@skovhus
skovhus / proptypes-to-flow-example.js
Last active April 10, 2017 15:52
PropTypes to Flow blog post
/* 1) Using good old PropTypes */
function Button({ message }) =>
<button>{message}</button>;
Button.propTypes = {
message: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.instanceOf(Message)
]).isRequired,
@skovhus
skovhus / redux-actions-to-flow.py
Created April 6, 2017 10:37
Annotates redux actions files with some Flow types
# Super quick and dirty script to bootstrap our action files with some Flow boilerplate.
import re
import sys
def get_action_constant(l):
m = re.search('= \'(.*)\'', l)
if m:
return m.group(1)
@skovhus
skovhus / tape-to-ava-codemod.js
Last active August 14, 2016 20:36
Codemod for Tape to AVA
/**
* Codemod for transforming Tape tests into AVA.
*
* jscodeshift -t tape-to-ava-codemod.js my-folder
*
* TODO:
* - [ ] Figure out when to keep `t.end` and when to remove it
* - [ ] rename first param in test callback function, if it is not t
* (and replace usage of identifier in block)
* - [ ] write test and submit to https://github.com/avajs/ava-codemods/issues/5
@skovhus
skovhus / gist:5fcefb38500ef4aa8536
Last active August 29, 2015 14:26
My Sublime Text 3 packages
Sublime Text 3 PackageControl https://packagecontrol.io/
Basic:
- Git
- GitGutter
- Markdown Preview
- Pretty JSON
- SideBarEnhancements
- Cucumber
@skovhus
skovhus / Preferences.sublime-settings
Last active August 29, 2015 14:08
Sublime Text 3 preferences
{
"bold_folder_labels": true,
"color_scheme": "Packages/User/Solarized Skovhus (SL).tmTheme",
"font_face": "menlo",
"font_size": 10,
"highlight_line": true,
"ignored_packages":
[
"Vintage"
],
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Generated by: TmTheme-Editor -->
<!-- ============================================ -->
<!-- app: http://tmtheme-editor.herokuapp.com -->
<!-- code: https://github.com/aziz/tmTheme-Editor -->
<plist version="1.0">
<dict>
<key>name</key>
<string>Solarized (Dark)</string>
from functools import wraps
from flask import request, current_app, jsonify
def support_jsonp(f):
"""Wraps output to JSONP"""
@wraps(f)
def decorated_function(*args, **kwargs):
result = jsonify(f(*args, **kwargs))
callback = request.args.get('callback', False)
@skovhus
skovhus / Triggers.plist
Created October 29, 2012 09:00
My QuickSilver Triggers
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>triggers</key>
<array>
<dict>
<key>ID</key>
<string>QSiTunesPlayPauseTrigger</string>
<key>command</key>
@skovhus
skovhus / Blackboard Skovhus Style.tmTheme
Created October 29, 2012 08:53
My TextMate Theme (Blackboard mod)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Domenico Carbotta</string>
<key>name</key>
<string>Blackboard Skovhus Style</string>
<key>settings</key>
<array>