Skip to content

Instantly share code, notes, and snippets.

View benbahrenburg's full-sized avatar

Ben Bahrenburg benbahrenburg

View GitHub Profile
@benbahrenburg
benbahrenburg / escape-json.js
Created December 25, 2020 03:39 — forked from matthewmueller/escape-json.js
Escape JSON strings before trying to run JSON.parse
/*
Escape JSON
*/
var escapeJSON = exports.escapeJSON = function(json) {
var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
var meta = { // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
@benbahrenburg
benbahrenburg / number_of_rows_removed.md
Created July 26, 2020 03:08 — forked from icerge/number_of_rows_removed.md
Security: ACLs, Query Business Rules

Number of rows removed due to security constraint

User gets this message in a list of records whenever there is a record user doesn't have rights to view. I.e. there is an ACL restricting access to a record or there in NO ACL granting the access. Let's ignore security mode setting here.

It's a default system beharior.

Would you like to get rid of it? System to count with records user has access to?

Solution 1

Replicate row level read access ACLs to query business rules. Naturally, every query will get controlled.

@benbahrenburg
benbahrenburg / PasscodeUtils.swift
Last active July 8, 2020 13:00
Use Swift to determine if device has passcode set
//
// PasscodeUtils.swift
//
// Created by Ben Bahrenburg on 12/31/16.
// Copyright © 2016 bencoding.com. All rights reserved.
//
import Foundation
import LocalAuthentication
@benbahrenburg
benbahrenburg / PDFHelpers.swift
Last active June 2, 2020 17:52
Removing PDF password using Swift
//
// PDF.swift
//
// Created by Ben Bahrenburg on 1/1/17.
// Copyright © 2017 bencoding.. All rights reserved.
//
import UIKit
open class PDFHelpers {
@benbahrenburg
benbahrenburg / appt.tss
Last active May 11, 2020 18:05
Titanium Android Portrait Orientation
//In your app/styles directory you will find an app.tss file
//If this file doesn't exist, simply add it to your project.
//The app.tss is used to apply styles across your project.
//For more on how this works, please visit http://docs.appcelerator.com/platform/latest/#!/guide/Alloy_Styles_and_Themes-section-35621526_AlloyStylesandThemes-GlobalStyles
//In your app.tss add the below Window style. This will set the orientation
//for all windows in your app
"Window" : {
orientationModes :[
Ti.UI.PORTRAIT
@benbahrenburg
benbahrenburg / Obfuscator.swift
Created September 19, 2016 00:38 — forked from MathieuWhite/Obfuscator.swift
Obfuscator for Swift
//
// Obfuscator.swift
// SwiftObfuscatorExample
//
// Created by Mathieu White on 2016-07-03.
// Copyright © 2016 Mathieu White. All rights reserved.
//
import Foundation
@benbahrenburg
benbahrenburg / copyPDFtoData.swift
Last active November 27, 2019 09:16
Copy CGPDFDocument to Data
if let pdf = unlock(data: pdfData, password: "Hello World") {
print("You now have an unlocked CGPDFDocument")
print("Create a copy of the unlocked CGPDFDocument")
let pdfWithoutPassword = copyPDFtoData(pdf: pdf)
print("You how have a pdf without password information")
}
@benbahrenburg
benbahrenburg / Writer.swift
Created October 28, 2019 13:26 — forked from steve228uk/Writer.swift
Write XMP
import UIKit
import CoreServices
import ImageIO
class Writer {
let output = NSTemporaryDirectory().appending("output.heic")
lazy var outputUrl: CFURL = {
return URL(fileURLWithPath: output) as CFURL
}()
@benbahrenburg
benbahrenburg / ViewController.swift
Created May 15, 2016 04:16
Opening a link from WebView
import UIKit
class ViewController: UIViewController, UIWebViewDelegate {
@IBOutlet weak var webView: UIWebView!
let html = "<div> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sit amet porttitor urna. Curabitur ut mattis magna. Fusce cursus diam ac sapien faucibus, at consectetur tellus laoreet. Integer faucibus risus in tempus bibendum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In rutrum mauris vel augue mollis rutrum. Nam lectus libero, blandit eget lorem vitae, consectetur pharetra nibh. Donec ornare vulputate justo, id viverra eros scelerisque eget. Nam eleifend blandit nisi, nec sodales dui sagittis quis.</p><ul><li><a href='http://cnn.com'>CNN</a></li><li><a href='https://apple.com'>Apple</a></li><li><a href='https://google.com'>Google</a></li></ul><p>Donec eget finibus tortor. Nulla et tempor enim. Maecenas at libero gravida, malesuada orci nec, posuere quam. Sed placerat auctor nunc, non consequat erat molestie eu. Sed aliquet u
@benbahrenburg
benbahrenburg / app.js
Last active May 30, 2019 11:21
Titanium Spotlight Tests
var win = Titanium.UI.createWindow({
title:'Demo', backgroundColor:'#fff',layout:'vertical'
});
var btnSpotLightSupported = Ti.UI.createButton({
top:20, title:'Is SpotLight Supported?',
height:60, width:Ti.UI.FILL
});
win.add(btnSpotLightSupported);