Skip to content

Instantly share code, notes, and snippets.

@iolate
iolate / AdditionalUIWindow.xm
Last active December 16, 2015 18:40
[THEOS] Additional UIWindows - Rotating UIWindow when orientation was changed.
#define UPDATE_ORIENTATION_NOTI CFSTR("iolate/UpdateOrientation")
static UIWindow* additionalWindow = nil;
static UIView* mainViewInWindow = nil;
static void updateOrientation(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
int orientation_ = 0;
@iolate
iolate / UIActivitiIndicatorOnUITableViewHeader.mm
Created April 29, 2013 05:55
UIActivityIndicator on UITableView header. ( >= iOS6 )
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UITableViewHeaderFooterView *sectionHeaderView = nil;
if (section == 1) {
sectionHeaderView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"headerIndicatorView"];
if (sectionHeaderView == nil) {
sectionHeaderView = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:@"headerIndicatorView"];
}
float indicatorSize = 21.0f;
-(void) addAppAsLoginItem {
if ([self wasAppAddedAsLoginItem]) return;
NSString * appPath = [[NSBundle mainBundle] bundlePath];
// This will retrieve the path for the application
// For example, /Applications/test.app
CFURLRef url = (__bridge CFURLRef)[NSURL fileURLWithPath:appPath];
// Create a reference to the shared file list.
@iolate
iolate / Soribada.js
Created January 6, 2017 18:25
BeardedSpice MediaStrategy for Soribada
//
// Soribada.js
// BeardedSpice
//
// Created by iolate <[email protected]> on 2016. 12. 28..
// Copyright © 2016 GPL v3 http://www.gnu.org/licenses/gpl.html
//
// http://www.soribada.com/
//
#!/bin/bash
# shellinabox ssh wrapper
# -s /:nobody:nogroup:/:/path/to/sshwrapper.sh
echo ""
echo "Example: user@host[:22]"
read -p "Connect to: " connstr;
if ! [[ "$connstr" =~ "@" ]]; then
echo ""
@iolate
iolate / pam_auth.c
Created March 5, 2019 19:15
PAM Authentication for OpenVPN auth-user-pass-verify
// gcc -o pam_auth pam_auth.c -lpam
#include <security/pam_appl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int custom_converation(int num_msg, const struct pam_message** msg, struct pam_response** resp, void* appdata_ptr) {
// Provide password for the PAM conversation response that was passed into appdata_ptr
struct pam_response* reply = (struct pam_response* )malloc(sizeof(struct pam_response));
@iolate
iolate / _readme-to-html.js
Last active December 22, 2019 10:31
[NodeJS] README.md to HTML file
// npm i markdown-it -D
var fs = require('fs');
var md = require('markdown-it')();
var input = fs.readFileSync('README.md', 'utf8');
var output = md.render(input);
var html = `<!DOCTYPE html>
<html><head><meta charset="utf-8" />
@iolate
iolate / AppDelegate.swift
Created April 10, 2022 11:31
Use keyboard shortcuts for status bar app using SwiftUI
// https://github.com/sindresorhus/Preferences/issues/40
// https://lapcatsoftware.com/articles/working-without-a-nib-part-10.html
import Cocoa
@objc protocol EditMenuActions {
func redo(_ sender: AnyObject)
func undo(_ sender: AnyObject)
}
// Method 1: Copy
let certificate = SecCertificateCreateWithData(kCFAllocatorDefault, derData as CFData)
// Method 2: No Copy
cert.withUnsafeBytes { unsafeBytes in
let bytes = unsafeBytes.bindMemory(to: UInt8.self).baseAddress!
let cFData = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, bytes, unsafeBytes.count, kCFAllocatorNull)!
let certificate = SecCertificateCreateWithData(kCFAllocatorDefault, cFData)
}