Skip to content

Instantly share code, notes, and snippets.

View leomelzer's full-sized avatar

Leonhard Melzer leomelzer

View GitHub Profile
@leomelzer
leomelzer / .zshrc
Created March 11, 2023 21:07
My .zshrc
# https://github.com/Schniz/fnm#shell-setup
eval "$(fnm env --use-on-cd)"
# https://github.com/junegunn/fzf#using-homebrew
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh
if type brew &>/dev/null
then
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
@leomelzer
leomelzer / package.json
Created August 2, 2022 13:05
Send in Blue Wrapper Example
{
"name": "send-in-blue-wrapper",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
@leomelzer
leomelzer / Dockerfile
Last active March 9, 2022 19:18
Install private NPM dependencies using git+ssh on Now. Based on https://zeit.co/blog/build-env to work around missing support for git+ssh dependencies in now@2 (https://github.com/zeit/now-builders/issues/49)
# This is a multi-stage build to not spill the contents of the deploy_key
FROM mhart/alpine-node:10 as base
# We need git and openssh to resolve `git+ssh` links in package.json
RUN apk update \
&& apk add git openssh
WORKDIR /usr/src
COPY package*.json ./
@leomelzer
leomelzer / howto.md
Created October 24, 2012 22:29
Installing ImageMagick & Ghostscript on Ubuntu
  1. You have Ghostscript installed, right? Otherwise sudo apt-get install ghostscript
  2. This is important and installs the headers (iapi.h etc) which are required but don't come with the default Ghostscript package: sudo apt-get install libgs-dev
  3. I also needed sudo apt-get install gs-esp
  4. For me the pre compiled version of ImageMagick never accepted Ghostscript, so let's remove it: sudo apt-get --purge remove imagemagick
  5. Get the source of ImageMagick, untar it, cd ImageMagick-xx
  6. ./configure --with-gslib=yes [and what else you need]
  7. Confirm in the output near the bottom gslib yes yes and not gslib yes no
  8. make
  9. make install
  10. Run convert -list configure | grep DELEGATES => DELEGATES bzlib djvu freetype gs jpeg jng jp2 lcms png tiff x11 xml zlib
"""Count words."""
def count_words(s, n):
"""Return the n most frequently occuring words in s."""
# TODO: Count the number of occurences of each word in s
words = s.split(" ")
# set comprehension so we only have unique values
word_frequencies = {word: words.count(word) for word in words}
word_frequency_tuples = [(word, count) for word, count in word_frequencies.items()]
@leomelzer
leomelzer / howto.md
Created October 22, 2012 14:38
vpnc with hybrid authentication on OS X Mountain Lion

How To

  1. Install homebrew if you don't have it already: http://mxcl.github.com/homebrew/
  2. Run brew install vpnc --hybrid
  3. Check if you already have virtual tunnel interfaces, run ls /dev/tun*. If there are none, install "Tun Tap OSX" (see below)
  4. Go to https://www.rz.uni-konstanz.de/angebote/e-mail/usermanager/ and login, then download both the certificate (you need the .pem file) and vpn profile
  5. Run openssl x509 -in <certificateFile>.pem -noout -hash
  6. Rename <certificateFile>.pem to the output of (5) with .pem as extension
  7. Move the .pem certificate to a permanent location, e.g. /etc/ssl/certs/
  8. Open /usr/local/etc/vpnc/default.conf in your favorite text editor, delete the contents
  9. Run pcf2vpnc /.pcf and paste the output to your open text editor
@leomelzer
leomelzer / index.ts
Created February 2, 2021 17:59
Set SVG dimensions in GraphCMS
import fetch from "node-fetch";
import imageSize from "image-size";
import { GraphQLClient, gql } from "graphql-request";
const ENDPOINT =
"https://api-eu-central-1.graphcms.com/v2/myProject/master";
const TOKEN =
"myTokenWithMutationPrivileges";
type Asset = Record<"id" | "handle" | "url", string> &
@leomelzer
leomelzer / input.story.js
Last active November 7, 2019 08:55
$ jscodeshift -t removeStoryConfig.js **/*.story.js
export const usePlaceholder = () => (
<TextField placeholder="I am a placeholder" />
);
usePlaceholder.story = {
name: 'use placeholder'
};
@leomelzer
leomelzer / input.story.js
Created November 7, 2019 08:54
$ jscodeshift -t renameDefaultStory.js **/*.story.js
export const defaultStory = () => <StatusDot />;
Option Description
version We'll use the (current) version 2 of the Now platform. Version 1 will be deprecated in the future but is still fully supported. Since the platform versions are based on different concepts, the specific options are different, too.
name The name of the application, usually the same as in package.json. This will be used as a label in the Now UI to identify the application.
alias This is the default argument for the now alias command. The alias will point to the randomly generated subdomain where Now created your immutable deployment. You must add the domain to Now in order to use this feature. You may add multiple aliases and also use subdomains here (e.g. foo.example.org if you already added the domain example.org to Now).
builds A Now application may be deployed using any of the available builders such as for Node.js, Go, Python and so on. We'll use the `static-buil