Skip to content

Instantly share code, notes, and snippets.

@abhibeckert
abhibeckert / gist:2bfb6a884c7fdd3194af86bd28ef9c10
Created June 4, 2022 08:13
Rounded Corners SVG QR Code in PHP
<?php
/**
* This code generates an SVG QR code with rounded corners. It uses a round rect for each square and then additional
* paths to fill in the gap where squares are next to each other. Adjacent squares overlap - to almost completely
* eliminate hairline antialias "cracks" that tend to appear when two SVG paths are exactly adjacent to each other.
*
* composer require chillerlan/php-qrcode (tested with version 4.2)
*/
@abhibeckert
abhibeckert / lint.swift
Created June 22, 2018 01:31
Project File Linter
//
// main.swift
// Lint
//
// Created by Abhi Beckert on 18/6/18.
// Copyright © 2018 Abhi Beckert. All rights reserved.
//
import Foundation
@abhibeckert
abhibeckert / gist:b28dc08e58ef17901efd
Last active March 11, 2016 04:31
Sequel Pro Content Filters
{
number = (
{
MenuLabel = "=";
NumberOfArguments = 1;
Clause = "= '${}'";
},
{
MenuLabel = "\U2260";
NumberOfArguments = 1;
/* example usage in Cocoa Script:
// create a window
var window = [[NSWindow alloc] init]
// create an OK button
var okButton = [[NSButton alloc] initWithFrame:NSMakeRect(10, 10, 100, 100)]
[okButton setTitle:"Continue"]
[okButton sizeToFit]
[okButton setKeyEquivalent:"\r"]
#import "COTarget.h"
@implementation COTarget
+ (instancetype)targetWithAction:(MOJavaScriptObject *)action
{
return [[[self class] alloc] initWithAction:action];
}
// as many inserts as possible before 30 second timeout hits
// 226,465 inserts
// auto_increment int(11)
while (1) {
$uuidstr = gen_uuid();
$uuidbin = DB::escape(pack("h*", str_replace('-', '', $uuidstr)));
DB::query("insert into test values ()");
}
Option 1:
let urlRegex = "(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’]))"
Option 2:
let urlRegex = """
(?xi)
\b
#!/usr/bin/swift
import Foundation
print("Content-type: text/html\n\n")
// load all data files
let dataDir = "/Users/abhi/www/data.json-files"
func updateKeys()
{
CATransaction.begin()
CATransaction.setDisableActions(true);
var x: CGFloat = 0
var y: CGFloat = 0
var rowHeight = ceil(self.inputView.frame.size.height / 5)
var colWidth = ceil(self.inputView.frame.size.width / 10)
@abhibeckert
abhibeckert / gist:711645229cba2bd9224f
Last active August 29, 2015 14:08
open/create file in swift
#!/usr/bin/swift
import Cocoa
// remove $0 from args
var args = Process.arguments
args.removeAtIndex(0)
// process input files
for arg in args {