Skip to content

Instantly share code, notes, and snippets.

Peter Marklund peter

Block or report user

Report or block peter

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
@peter
peter / script-open-terminal-tabs.md
Created Apr 11, 2019
Script to open terminal tabs and run commands on Mac
View script-open-terminal-tabs.md

Open Terminal Tabs on Mac and Run Commands

Dependencies

Requires Node.js and ttab

npm install ttab -g
View vs-code-keybindings.json
[
{
"key": "cmd+t",
"command": "workbench.action.quickOpen"
},
{
"key": "cmd+p",
"command": "-workbench.action.quickOpen"
}
]
@peter
peter / gmail-shortcut-keys.md
Last active Apr 9, 2019
Gmail Shortcut Keys
View gmail-shortcut-keys.md

Gmail Shortcut Keys

  • 'o' - open
  • 'u' - return to thread list
  • 'j' - next
  • 'k' - previous
  • '[' - archive and next
  • ']' - archive and previous
  • 'shift ?' - show shortcut keys help
@peter
peter / vs-code-prettier-formatOnSave.json
Created Feb 28, 2019
VS Code Prettier Extension Format on Save settings.json
View vs-code-prettier-formatOnSave.json
{
"editor.formatOnSave": false,
"[javascript]": {
"editor.formatOnSave": true
},
"[javascriptreact]": {
"editor.formatOnSave": true
}
}
@peter
peter / java-boilerplate-hashcode-equals-tostring.java
Last active Jan 18, 2019
Java Boilerplate Nostalgia - DTO classes with hashCode, equals, toString, getter/setter methods
View java-boilerplate-hashcode-equals-tostring.java
public class SettingDTO {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof SettingDTO)) return false;
SettingDTO filterDTO = (SettingDTO) o;
if (key != null ? !key.equals(filterDTO.key) : filterDTO.key != null) return false;
if (value != null ? !value.equals(filterDTO.value) : filterDTO.value != null) return false;
@peter
peter / compose-and-pipe.js
Last active Nov 29, 2018
JavaScript Compose and Pipe
View compose-and-pipe.js
//////////////////////////////////////////////
// Compose and Pipe
//////////////////////////////////////////////
const a = v => v + 'a'
const b = v => v + 'b'
const c = v => v + 'c'
function compose (...fns) {
if (fns.length === 0) return arg => arg
View await-with-sync-function.js
function syncBar () {
console.log('in syncBar')
return 'syncBar'
}
function asyncBar () {
console.log('in asyncBar')
return Promise.resolve('asyncBar')
}
@peter
peter / util.js
Created Jan 6, 2018
JavaScript Utility Functions
View util.js
function nil(value) {
return value === undefined || value === null
}
function notNil(value) {
return !nil(value)
}
function empty(value) {
if (nil(value)) {
@peter
peter / java-vs-python.md
Last active Jan 1, 2018
Java vs Python
View java-vs-python.md

Java vs Python

Split String

Java:

String numberString = "1,2,3,4,5";
int[] numbers = Arrays.stream(numberString.split(",")).mapToInt(Integer::parseInt).toArray();
@peter
peter / python-runtime-type-checks.md
Last active Dec 21, 2017
Python runtime type checks with decorator
View python-runtime-type-checks.md

Python runtime type checks with decorator

# This modules provides pre/post conditions for python functions via the @typeSpec decorator

from functools import reduce

def compact(d):
    return {k: v for k, v in d.items() if v != None}
You can’t perform that action at this time.