Skip to content

Instantly share code, notes, and snippets.

@gotofritz
gotofritz / gitlab-markdown-toc.js
Last active May 7, 2019 12:50
creates a gitlab markdown table of contents for a README.md page
// quick and dirty snippet to creates a gitlab markdown table of contents for a README.md page
// preview gitlab page and paste in browser console
var str = "";
$('.file-content')
.find('h1, h2, h3, h4, h5, h6, h7')
.each((i, node) => {
// node.tagName is H1 H2...
let indent = Number(node.tagName[1]) - 1;
// markdown mested lists are
// - xxx
@a-r-g-v
a-r-g-v / nsqd.service
Created February 21, 2016 23:59
nsqd, nsqdlookupd systemd service files
[Unit]
Description=NSQD
After=network.target
[Service]
WorkingDirectory=/usr/local/nsq
ExecStart=/usr/local/nsq/bin/nsqd -http-address 127.0.0.1:4151 -tcp-address 127.0.0.1:4150 -lookupd-tcp-address 127.0.0.1:4160
ExecReload=/bin/kill -HUP $MAINPID
Type=simple
KillMode=process
@derhuerst
derhuerst / _.md
Last active April 9, 2024 11:06
List of HAFAS API Endpoints
local function string(o)
return '"' .. tostring(o) .. '"'
end
local function recurse(o, indent)
if indent == nil then indent = '' end
local indent2 = indent .. ' '
if type(o) == 'table' then
local s = indent .. '{' .. '\n'
local first = true
@tomasbasham
tomasbasham / UIImage+Scale.m
Last active February 1, 2024 19:04
Scale a UIImage to any given rect keeping the aspect ratio
@implementation UIImage (scale)
/**
* Scales an image to fit within a bounds with a size governed by
* the passed size. Also keeps the aspect ratio.
*
* Switch MIN to MAX for aspect fill instead of fit.
*
* @param newSize the size of the bounds the image must fit within.
* @return a new scaled image.
@zpmorgan
zpmorgan / pubsub.pl
Created September 22, 2012 00:47
pub/sub with mojolicious, redis, & websockets.
#!/usr/bin/env perl
use Mojolicious::Lite;
use common::sense;
use Mojo::JSON;
my $json = Mojo::JSON->new();
use Mojo::Redis;
use Protocol::Redis::XS;
@tibr
tibr / NSFileManager+DoNotBackup.h
Created March 8, 2012 09:42
Setting the do not backup attribute in different iOS versions
@interface NSFileManager (DoNotBackup)
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL;
@end
/*
The MIT License (MIT)
Copyright (c) 2014 Ismael Celis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is