Skip to content

Instantly share code, notes, and snippets.

@marckohlbrugge
marckohlbrugge / WIP_Streak.scriptable
Created June 1, 2024 13:38
Scriptable widget showing your streak. Make sure to set your own API key ( https://wip.co/my/api_keys )
{
"always_run_in_app" : false,
"icon" : {
"color" : "yellow",
"glyph" : "fire"
},
"name" : "WIP Streak",
"script" : "\/\/ Replace with your API key\nconst API_KEY = \"wip_sk_REPLACE_ME\";\nconst API_URL = `https:\/\/api.wip.co\/v1\/users\/me.json?api_key=${API_KEY}`;\n\n\/\/ Function to fetch data from the API\nasync function fetchStreakData() {\n let request = new Request(API_URL);\n let response = await request.loadJSON();\n return response;\n}\n\n\/\/ Function to calculate hours left until midnight in a given time zone\nfunction hoursLeftUntilMidnight(timeZone) {\n let now = new Date();\n let nowInUserTimeZone = new Date(now.toLocaleString(\"en-US\", { timeZone: timeZone }));\n let midnight = new Date(nowInUserTimeZone);\n midnight.setHours(24, 0, 0, 0); \/\/ Set to midnight\n\n let hoursLeft = (midnight - nowInUserTimeZone) \/ (1000 * 60 * 60); \/\/ Convert milliseconds to hours\n return hoursLeft.toFixed(0);\n}\n\n\/\/ Function to create a widget displaying the streak info\nasy
@levelsio
levelsio / obfuscate.php
Last active May 5, 2023 12:33
WordPress plugin to progressively obfuscate text like MAKEbook.io
/*
--PIETZ OBFUSCATE CODE--
2019-06-01
from MAKEbook.io
Instructions:
1) put this in your functions.php file
2) add this to the post you want to obfuscate, on top
3) [obfuscate]
4) to start obfuscating, add a HTML code or HTML block with <start></start>
@craigeley
craigeley / toggl_reporter.rb
Last active April 6, 2018 02:39
When used with Hazel, a script that parses data from the Reporter app and starts a new time entry in Toggl.
#!/usr/bin/ruby
# Scipt for Using Reporter to start time entries in Toggl
require 'time'
require 'json'
# Prevent encoding errors on OSX
if RUBY_VERSION =~ /2.*.*/
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
@r-brown
r-brown / howto-install-jekyll_homebrew-rbenv.txt
Last active June 12, 2022 15:23
How to install Jekyll using Homebrew and rbenv
# install Homebrew
$ su ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# show brew commands
$ brew help
# check current user
$ echo $(whoami)
# grant access to the folders
@craigeley
craigeley / markdown_to_day_one.rb
Last active April 6, 2018 02:39
An Automator action to send edited sidecar Markdown files back to Day One.
if RUBY_VERSION =~ /2.*.*/
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end
dayone_path = '/path/to/journal.dayone/entries/'
file_path = ARGV[0]
/UUID:\s(?<uuid>.*)/ =~ IO.readlines(file_path)[1]
# Create working plist file
@craigeley
craigeley / day one_to_markdown.rb
Last active April 6, 2018 02:34
When run with Hazel, this script takes a Day One file and creates a sidecar Markdown file and an alias to that file. When the Day One entry is modified, so is the Markdown file, even if it is moved and/or renamed.
#!/usr/local/bin/ruby
require 'plist'
# Fix encoding errors
if RUBY_VERSION =~ /2.2/
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end