Skip to content

Instantly share code, notes, and snippets.

View timpulver's full-sized avatar

Tim Pulver timpulver

View GitHub Profile
@timpulver
timpulver / GetNameAndTitleOfActiveWindow.scpt
Created February 11, 2013 10:38
[AppleScript] Get Name of active window | Returns the name / title of the active (frontmost) window
# taken from user Albert's answer on StackOverflow
# http://stackoverflow.com/questions/5292204/macosx-get-foremost-window-title
# tested on Mac OS X 10.7.5
global frontApp, frontAppName, windowTitle
set windowTitle to ""
tell application "System Events"
set frontApp to first application process whose frontmost is true
set frontAppName to name of frontApp
@timpulver
timpulver / read_mac_file_tags.js
Created September 17, 2015 12:49
Read Mac OS X Finder file tags in Node.js
var exec = require('child_process').exec;
// Outputs the Mac OS X Finder tags of a file
// in the same directory as the script.
// Depends on tag (https://github.com/jdberry/tag)
var filename = "some_file_with_tags.md";
readTags(filename);
@timpulver
timpulver / pandoc_watch.js
Created May 28, 2016 18:15
Watches a markdown-folder for changes and re-generates .icml (InCopy / Adobe InDesign CC) files on every change
var exec = require('child_process').exec;
var chokidar = require('chokidar');
/*
* Watches a folder for changes in markdown (*.md) files and compiles them to ICML (Adobe InDesign CC / InCopy format)
*
* Dependencies:
* - Install Pandoc: pandoc.org
* - Run "npm install chokidar"
*

Tailwind.css + Vue.js

Shows how to create a new Vue.js project with vue-cli 3 which uses Tailwind.css.

Tailwind is a utility-first CSS framework for rapidly building custom user interfaces. Tailwind is written in PostCSS and configured in JavaScript, which means you have the full power of a real programming language at your fingertips.

Tested with Vue.js 3.2.1 and Tailwind.css 0.7.3 (Januar 2019)

  • vue create my-project (I used airbnb-eslint, scss and unit-testing )
@timpulver
timpulver / Typografie_Shortcuts_Mac_Deutsch.md
Last active May 7, 2023 18:47
Typografie Shortcuts auf dem Mac mit kurzen Erläuterungen (deutsches Tastaturlayout)
@timpulver
timpulver / IpFromUrl.java
Created September 24, 2012 15:15
[Java] URL to IP address lookup [host, url, ip, server, convert, conversion]
import java.net.*;
import java.io.*;
public static class IpFromUrl {
// Returns the IP address of an URL
// i.e. http://www.facebook.com -> 123.456.789.10
public static String getIp( String hostname ) throws IOException {
try {
InetAddress ipaddress = InetAddress.getByName(hostname);
System.out.println("IP address: " + ipaddress.getHostAddress());
@timpulver
timpulver / rotateImage.pde
Created October 17, 2012 14:46
[Processing] Rotate Image using a direction vector
/**
* Rotates an image around an angle
* For this the direction vector dir will be used.
* E.g. if you want to code something like Asteroids:
* A rocket, which is always pointing towards the direction it is flying to...
* For details about atan2 see here: http://www.processing.org/reference/atan2_.html
*
* keywords: atan, atan2, sin, cos, tan, vector, vektor, math, mathe, winkel,
* angle, rotation, processing.org, 360, TWO_PI, origin, ursprung, image, bild
*/

Electron Drag’n’Drop

Allows files(s) to be dragged inside the electron app as well as files to be dropped out (when dropped on the desktop e.g. the file will be copied to the destination.

Installation

Clone the Quick Start repository:
git clone https://github.com/electron/electron-quick-start

Go into the repository:

@timpulver
timpulver / relsymlink.py
Last active July 16, 2021 03:18
[Python] Creates a relative symlink based on two directories. If only one directory is passed as an argument, the symlink will be created in the current working directory [Mac, Terminal, Symbolic Link, Absolute]
@timpulver
timpulver / load_public_dropbox_file_and_use_it_in_d3.js.md
Created January 27, 2015 21:18
[Javascript, D3.js, Dropbox] Visualize public JSON file from Dropbox in D3.js

Dropbox, D3.js, File, Folder, Public, Load, JSON, JSONP, CORS, Access-Control-Allow-Origin, Error

If you try to load a public JSON-file from Dropbox, you will probably get this error message:

XMLHttpRequest cannot load https://www.dropbox.com/s/123456789/data.json?dl=0. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access.

To load the file successfully, you have to change the end dl=0 to dl=1 and replace www.dropbox.com with dl.dropboxusercontent.com, so the URL should look like this: https://dl.dropboxusercontent.com/s/123456789/data.json?dl=1.

Now you can call: