Skip to content

Instantly share code, notes, and snippets.

View pascaliske's full-sized avatar
👋
Hi, what's up?

Pascal Iske pascaliske

👋
Hi, what's up?
View GitHub Profile
@pascaliske
pascaliske / sudo-keepalive-example.sh
Created March 5, 2017 17:27 — forked from cowboy/sudo-keepalive-example.sh
Bash: Sudo keep-alive (good for long-running scripts that need sudo internally but shouldn't be run with sudo)
#!/bin/bash
# Might as well ask for password up-front, right?
sudo -v
# Keep-alive: update existing sudo time stamp if set, otherwise do nothing.
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Example: do stuff over the next 30+ mins that requires sudo here or there.
function wait() {
@pascaliske
pascaliske / recent-finder-window.applescript.scpt
Created March 6, 2017 13:07
Re-open the most recent Finder window via an AppleScript Service.
activate application "Finder"
delay 1
tell application "System Events"
tell process "Finder"
click first menu item of menu 1 of menu item "Recent Folders" of menu 1 of menu bar item "Go" of menu bar 1
end tell
end tell
@pascaliske
pascaliske / dashes-to-camelcase.js
Created March 15, 2017 10:57
Convert dashed strings to camelcased strings
// ES5
var camelize = function(string) {
return string.replace(/-([a-z])/g, function(match) {
return match[1].toUpperCase();
});
};
// ES6 (short one-liner)
const camelize = string => string.replace(/-([a-z])/g, match => match[1].toUpperCase());
@pascaliske
pascaliske / git-diff.md
Last active April 16, 2024 14:32
Collection of useful diff tools for git

Useful git diff tools

Overview

  • Word: docx2txt (brew install docx2txt)
  • Excel: xlsx2txt
  • PDF: pdf2txt (brew install poppler)
  • Images: exiftool (brew install exiftool)

Setup

@pascaliske
pascaliske / link.md
Created May 24, 2017 10:53
Workaround for Safari's gzip bug
@pascaliske
pascaliske / README.md
Last active August 21, 2017 20:41
Local Network BrowserSync Proxy

Local Network BrowserSync Proxy

Update: I've published a npm package for an even easier usage of this trick! See pascaliske/bsproxy.

Quickly proxy a local domain (e.g. http://my-site.dev) for local network access.

Steps

  1. Globally install BrowserSync
// ----
// libsass (v3.5.0.beta.2)
// ----
//
// GLOBAL
//
@mixin cmp-base($component) {
.#{$component} {
@content;
@pascaliske
pascaliske / diff.ts
Last active August 23, 2018 20:23 — forked from mailtruck/colormeter.js
Calculate difference in percentage between 2 hex colors
export function diff(color1: string, color2: string): number {
if (!color1 && !color2) {
return;
}
const _color1 = color1.charAt(0) == '#' ? color1.substring(1, 7) : color1;
const _color2 = color2.charAt(0) == '#' ? color2.substring(1, 7) : color2;
const rColor1 = parseInt(_color1.substring(0, 2), 16);
const gColor1 = parseInt(_color1.substring(2, 4), 16);
@pascaliske
pascaliske / jsonview-solarized.css
Created February 8, 2018 12:05 — forked from iansym/jsonview-solarized.css
JSON View solarized theme for Chrome Extension
body {
background-color: #002b36;
color: #839496;
font-size: 14px;
white-space: pre !important;
font-family: "Source Code Pro", monospace;
}
.property {
font-weight: bold;
@pascaliske
pascaliske / node-with-correct-permissions.md
Last active January 4, 2019 14:00
Install Node, NPM and Yarn with correct permissions and enabled SIP on macOS 10.13+.

Node, NPM, Yarn

Note: Since macOS High Sierra (10.13) the directory /usr/local/bin is not modifiable anymore (because of Apple's SIP feature). But using node and npm with sudo is not advisable.

Generally it is best practice to install node using an dedicated version manager like n or nvm. This will handle permissions correctly and allows easy upgrading / downgrading the versions.

n
  1. Install node version manager n