Skip to content

Instantly share code, notes, and snippets.

View mattcassinelli's full-sized avatar

Matthew Cassinelli mattcassinelli

View GitHub Profile
@mattcassinelli
mattcassinelli / Drafts_Javascript_Sort-Lines
Created October 27, 2014 00:28
Sort lines in Drafts 4
function generate(s){
var temp = new Array();
temp = s.split('\n');
temp.sort();
var result = "";
var i;
for(i=0; i<temp.length; i++) {
result += temp[i] + "\n";
}
return result;
@mattcassinelli
mattcassinelli / Drafts_Javascript_Timestamp
Created October 27, 2014 00:30
Insert timestamp into Drafts
function getDateTime() {
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth()+1;
var day = now.getDate();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
if(month.toString().length == 1) {
var month = '0'+month;
@mattcassinelli
mattcassinelli / Drafts_Javacsript_Redo-List-Order
Created October 27, 2014 00:35
Re-number a list in Drafts 4
function renumber(s) {
var rgx=/^\d+\. /m,
list=s.split(rgx),
count;
list.shift();
count = list.length;
for(var i=0; i<count; i++) {
list[i] = (i+1).toString() + '. ' + list[i];
}
return list.join('');
@mattcassinelli
mattcassinelli / Drafts_Template_Web-Capture
Created October 27, 2014 00:36
Change Drafts 4 Web Capture Template to Markdown quote & reference
[[[title]]][1]:
> [[selection]]
[1]: [[url]]
import UIKit
import PlaygroundSupport
let vc = UIViewController()
vc.view.backgroundColor = .white
PlaygroundPage.current.liveView = vc
PlaygroundPage.current.needsIndefiniteExecution = true
let button = UIButton(type: .system)
button.frame = CGRect(x: 0, y: 0, width: 240, height: 120)