Skip to content

Instantly share code, notes, and snippets.

View 0xWDG's full-sized avatar
💻
Hacking my way around

Wesley de Groot 0xWDG

💻
Hacking my way around
View GitHub Profile
@0xWDG
0xWDG / console.log support WebView.swift
Created December 26, 2015 12:47
Web view add console.log support
let jsContext = mainWebview.mainFrame.javaScriptContext
jsContext.evaluateScript("var console = {log: function () {var message = '';for (var i = 0; i < arguments.length; i++) {message += arguments[i] + ' '};console.print(message)},warn: function () {var message = '';for (var i = 0; i < arguments.length; i++) {message += arguments[i] + ' '};console.print(message)},error: function () {var message = '';for (var i = 0; i < arguments.length; i++){message += arguments[i] + ' '};console.print(message)}};")
let logFunction: @convention(block) (NSString!) -> Void = { (message:NSString!) in
print("JS: \(message)")
}
jsContext.objectForKeyedSubscript("console").setObject(unsafeBitCast(logFunction, AnyObject.self), forKeyedSubscript:"print")
//
// md5.swift
// PHPFramework
//
// Created by Wesley de Groot on 28-02-16.
// Copyright © 2016 WDGWV. All rights reserved.
//
import Foundation
@0xWDG
0xWDG / SwiftGetHumanType.swift
Last active March 19, 2016 21:35
get the classname back from swift.
//
// SwiftGetHumanType.swift
// PHPFramework
//
// Created by Wesley de Groot on 02-03-16.
// Copyright © 2016 WDGWV. All rights reserved.
//
// https://gist.github.com/wdg/5cf0f2187c7d31a931b7
import Foundation
@0xWDG
0xWDG / SHA1.swift
Last active December 1, 2019 00:51
SHA1 for Swift
//
// SHA1.swift
// Based on:
// https://raw.github.com/kvz/phpjs/master/functions/strings/sha1.js
import Foundation
extension String {
func charCodeAt(Char: Int) -> Int {
@0xWDG
0xWDG / appendBlur.swift
Last active February 18, 2020 11:19
Append Blur to a NSView, NSButton, NSTextField
//
// appendBlur.swift
//
// Created by Wesley de Groot on 09-07-16.
// Copyright © 2016 Wesley de Groot. All rights reserved.
//
import Foundation
enum blur: String {
case light = "light"
@0xWDG
0xWDG / addSizes.js
Created September 15, 2016 18:41 — forked from rainbowstudio/addSizes.js
Affichage du type et de la taille des documents pdf
function hdrDetails(index, elm, length, type) {
// divide the length into its largest unit
var units = [
[1024 * 1024 * 1024, 'Go'],
[1024 * 1024, 'Mo'],
[1024, 'Ko'],
[1, 'bytes']
];
for(var i = 0; i < units.length; i++){
function r(f){/in/.test(document.readyState)?setTimeout('r('+f+')',9):f()}
//Usage:
r(function () {
// Code here
})
@0xWDG
0xWDG / keybase.md
Last active December 19, 2016 21:33

Keybase proof

I hereby claim:

  • I am wdg on github.
  • I am wdg (https://keybase.io/wdg) on keybase.
  • I have a public key whose fingerprint is F580 85CE B0FE 97E5 9668 9149 7B4C E636 025D BA39

To claim this, I am signing this object:

@0xWDG
0xWDG / readUITabbarTitle.swift
Created January 16, 2017 21:04
Read UITabbar title and activate that screen
import Foundation
import UIKit
class testVC: UIViewController {
/*
Using this in your first active UITabBar screen, will allow you to change the screen for e.g. a Quick Action.
*/
var freshLaunch = true
override func viewWillAppear(_ animated: Bool) {
@0xWDG
0xWDG / Excel password breaker.txt
Created December 4, 2017 21:41
Excel password breaker
Sub PasswordBreaker()
'Breaks worksheet password protection.
Dim i As Integer, j As Integer, k As Integer
Dim l As Integer, m As Integer, n As Integer
Dim i1 As Integer, i2 As Integer, i3 As Integer
Dim i4 As Integer, i5 As Integer, i6 As Integer
On Error Resume Next
For i = 65 To 66: For j = 65 To 66: For k = 65 To 66