Skip to content

Instantly share code, notes, and snippets.

@Daij-Djan
Daij-Djan / sinatra-command.rb
Created January 19, 2017 15:24
Run a local Webserver with Sinatra that can do actions on your Mac. I mainly want /quiet for my hacked amazon dash button And/Or home control
#!/usr/bin/env ruby
require 'sinatra'
get '/hello' do
value = `osascript -e 'tell app "System Events" to display dialog "Hello"'`
end
get '/lock' do
value = `"/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession" -suspend`
package info.pich.camunda.bmp.configuration;
import lombok.Data;
import org.camunda.bpm.engine.AuthorizationService;
import org.camunda.bpm.engine.IdentityService;
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.authorization.Groups;
import org.camunda.bpm.engine.authorization.Resource;
import org.camunda.bpm.engine.authorization.Resources;
import org.camunda.bpm.engine.identity.Group;
import CocoaLumberjack
import Security
public class EncryptedLogger: DDAbstractLogger {
let key: SecKey!
let blockSize : Int
let padding : SecPadding
init(key: SecKey!, blockSize : Int = 128, padding: SecPadding = .PKCS1) {
self.key = key
@Daij-Djan
Daij-Djan / ignoreInvalidSSL
Last active May 23, 2016 17:08
show how to properly ignore invalid ssl certificates while leaving other authentication challenges untouuched
//setup a new task
let configuration = NSURLSessionConfiguration.ephemeralSessionConfiguration()
let session = NSURLSession(configuration: configuration, delegate: self, delegateQueue: NSOperationQueue.mainQueue())
let task = session.dataTaskWithURL(url, completionHandler: handleUrlCompleted)
task.resume()
....
//url session needs to accept invalid certificates
func URLSession(session: NSURLSession, didReceiveChallenge challenge: NSURLAuthenticationChallenge, completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Void) {
//MIT
import Foundation
import Contacts
if(NSProcessInfo.processInfo().arguments.count != 2) {
print("Usage: CNPurgeGroup %GROUPNAME%")
}
else {
let groupName = NSProcessInfo.processInfo().arguments[1]
#!/bin/bash
# This has to be run from develop (NOTE: if master is your main dev branch, edit the file.)
git checkout develop
# Update our list of remotes
git fetch
git remote prune origin
# Remove local fully merged branches
@Daij-Djan
Daij-Djan / ReflectionHelpers.swift
Last active November 14, 2015 17:21
a helper that uses reflection to get a nsnumber object from from an (optional) Int/Bool/Double/Float property. needed in unit testing
import Foundation
@objc
class ReflectionHelpers : NSObject {
class func getNSNumberForProperty(cls: AnyObject!, name: String!) -> NSNumber! {
let m = Mirror(reflecting: cls)
let child1 = m.descendant(name)
if(child1 != nil) {
//bool
@Daij-Djan
Daij-Djan / duplicateStringsKeys.sh
Last active August 29, 2015 14:02
find duplicate strings file entries (duplicate keys! the value can differ)
#!/bin/bash
FILENAME="Localizable.strings"
DUPES=`cut -d' ' -f1 "$FILENAME" | sort | uniq -d`
while read -r line; do
echo "error: $line used multiple times -"
done <<< "$DUPES"
@Daij-Djan
Daij-Djan / ArrayUtils.swift
Last active February 2, 2018 20:49
Added an Array extension with contains & indexOf -- bridging to NSArray is ugly and that hides it
import Foundation
extension Array {
func contains<U: Equatable>(object:U) -> Bool {
return (self.indexOf(object) != nil);
}
func indexOf<U: Equatable>(object: U) -> Int? {
for (idx, objectToCompare) in self.enumerate() {
if let to = objectToCompare as? U {
@Daij-Djan
Daij-Djan / plutilIdent
Created April 8, 2014 12:40
plutilIdent: tiny quick&dirty (very) utility that checks if two given plists/strings files contain equal keys
//
// main.m
// plutilIdent
//
// Created by Dominik Pich on 08/04/14.
// Copyright (c) 2014 Dominik Pich. All rights reserved.
//
#import <Foundation/Foundation.h>