Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Marc Köhlbrugge marckohlbrugge

🏠
Working from home
View GitHub Profile
@marckohlbrugge
marckohlbrugge / rss.php
Last active November 5, 2022 08:27
Use WIP's GraphQL API to create an RSS feed of your completed todos
View rss.php
<?php
$username = isset($_GET['username']) ? $_GET['username'] : 'marcano';
function graphql_query($endpoint, $query, $variables = [], $token = null) {
$headers = ['Content-Type: application/json', 'User-Agent: Minimal GraphQL client'];
if (null !== $token) {
$headers[] = "Authorization: bearer $token";
}
@marckohlbrugge
marckohlbrugge / migrate_redis.rb
Created October 9, 2022 10:36
Simple script to migrate all Redis keys from one server (REDIS_ORIGIN_URL) to another (REDIS_DESTINATION_URL)
View migrate_redis.rb
# NOTE: Don't get your two Redis URLs mixed up or you'll lose data!
require "redis"
redis1 = Redis.new(url: ENV.fetch("REDIS_ORIGIN_URL"))
redis2 = Redis.new(url: ENV.fetch("REDIS_DESTINATION_URL"))
# NOTE: Uncomment this if you want to clear out all Sidekiq stats from the ORIGIN(!) server
# redis1.pipelined do |pipeline|
# redis1.keys("stat:processed:*").each do |key|
View get_discord_guilds_for_user.rb
# Make sure you have a .env file with DISCORD_CLIENT_ID set
require "dotenv/load"
require "http"
puts "Go to the following URL in your browser to authorize this application:"
puts "https://discord.com/api/oauth2/authorize?response_type=token&client_id=#{ENV.fetch("DISCORD_CLIENT_ID")}&scope=identify%20email%20connections%20guilds%20guilds.join%20guilds.members.read%20messages.read"
puts ""
puts "Paste the URL you were redirected to after authorization:"
@marckohlbrugge
marckohlbrugge / bookmarklet.js
Last active December 31, 2019 12:43
Shows all tweets with 25+ retweets of Twitter profile you're currently looking at.
View bookmarklet.js
javascript:(function()%7Bwindow.location%20%3D%20%60https%3A%2F%2Ftwitter.com%2Fsearch%3Fq%3Dfrom%253A%24%7Bdocument.location.href.match(%2Ftwitter.com%5C%2F(%5Ba-z0-9_%5D%2B)%2Fi)%5B1%5D%7D%2520min_retweets%253A25%26src%3Dtyped_query%60%7D)() // window.location = `https://twitter.com/search?q=from%3A${document.location.href.match(/twitter.com\/([a-z0-9_]+)/i)[1]}%20min_retweets%3A25&src=typed_query`
@marckohlbrugge
marckohlbrugge / news.ycombinator.com.css
Created October 30, 2019 21:07
Use https://joof.app to fix Hacker News styling
View news.ycombinator.com.css
body { background-color: rgb(246, 246, 239); margin-top: 0 }
.title { font-size: 16px; padding-top: .6em; padding-bottom: .3em; }
.athing > .votelinks { padding-top: .8em }
.subtext { font-size: 12px; }
.comment { font-size: 16px; line-height: 1.5; }
@marckohlbrugge
marckohlbrugge / countdown.rb
Last active October 10, 2018 10:47
Calculates estimated time it takes for a block to return zero. Useful when running operations in parallel (e.g. migrations).
View countdown.rb
# Calculates estimated time it takes for a block to return zero. Useful when
# running operations in parallel (e.g. migrations).
#
# Usage:
# Run in IRB/Rake/whatever: add_slugs_to_each_post # example of long-running operations
# Run in parallel IRB session: countdown { Post.where(slug: nil).count }
#
# sleep_time parameter is optional. The higher the value the more accurate the
# results, but the longer the method takes to run.
@marckohlbrugge
marckohlbrugge / unread_only.js
Created May 3, 2018 11:42
Hides all read chats so you only see unread chats. Save this as a bookmarklet with https://mrcoles.com/bookmarklet/ and run on https://web.telegram.org/#/im
View unread_only.js
$(".im_dialog_wrap .im_dialog_badge.ng-hide").each(function(index, el){$(el).parents("li.im_dialog_wrap").addClass("ng-hide");});
@marckohlbrugge
marckohlbrugge / wip_graphql_demo.rb
Last active October 10, 2022 11:46
Ruby example of creating a todo and then completing it using wip.co graphql.
View wip_graphql_demo.rb
# NOTE: Be sure to set the API key further down in the code!
require "net/http"
require "uri"
require "json"
class WIP
def initialize(api_key:)
@api_key = api_key
end
View text_utils.rb
text = %{This validates there's a lot of attention and real business to be made targeting the nomad and remote work space. Even if nomads have previously had an image of low-income. There's money here.}
def garble(input, intro: 0)
length = input.length
output = []
for position in 0...length
percentage = (position / length.to_f)
output << if percentage < intro ||
percentage < rand ||
@marckohlbrugge
marckohlbrugge / wipchat.coffee
Last active September 26, 2020 01:36
ubersicht widget that pulls in next wipchat todo to work on
View wipchat.coffee
# This is a simple example Widget, written in CoffeeScript, to get you started
# with Übersicht. For the full documentation please visit:
#
# https://github.com/felixhageloh/uebersicht
#
# You can modify this widget as you see fit, or simply delete this file to
# remove it.
# this is the shell command that gets executed every time this widget refreshes
command: "whoami"