Skip to content

Instantly share code, notes, and snippets.

View abjurato's full-sized avatar
💜

Anatoly Rosencrantz abjurato

💜
View GitHub Profile
@abjurato
abjurato / FoodListHandler.swift
Created May 2, 2016 06:49
FoodListHandler class for processing FoodList mustache template. Swift, Perfect, mustache and PostgreSQL on Heroku.
import PerfectLib
import PostgreSQL
class FoodListHandler: PageHandler {
let dbHost = "localhost"
let dbName = "cat_food"
let dbUsername = //PUT YOUR SYSTEM USERNAME HERE!
let dbPassword = ""
func valuesForResponse(context: MustacheEvaluationContext, collector: MustacheEvaluationOutputCollector) throws -> MustacheEvaluationContext.MapType {
@abjurato
abjurato / PerfectHandlers.swift
Created May 2, 2016 06:52
Junk to add to PerfectHandlers.swift to register FoodList mustache template. Swift, Perfect, mustache and PostgreSQL on Heroku.
PageHandlerRegistry.addPageHandler("FullFoodList") {
(r:WebResponse) -> PageHandler in
return FoodListHandler()
}
@abjurato
abjurato / PerfectHandlers.swift
Created May 2, 2016 06:58
Required global function to make Perfect work. Swift, Perfect, mustache and PostgreSQL on Heroku.
import PerfectLib
// This function is required. The Perfect framework expects to find this function
// to do initialization
public func PerfectServerModuleInit() {
PageHandlerRegistry.addPageHandler("CatName") {
// This closure is called in order to create the handler object.
// It is called once for each relevant request.
// The supplied WebResponse object can be used to tailor the return value.
@abjurato
abjurato / CatNameHandler.swift
Created May 2, 2016 07:01
CatNameHandler for processing CatName mustache template. Swift, Perfect, mustache and PostgreSQL on Heroku.
import PerfectLib
class CatNameHandler: PageHandler {
func valuesForResponse(context: MustacheEvaluationContext, collector: MustacheEvaluationOutputCollector) throws -> MustacheEvaluationContext.MapType {
let dict:MustacheEvaluationContext.MapType = ["name": "Sasha"]
return dict
}
}
@abjurato
abjurato / makefile
Created May 2, 2016 19:56
makefile for CatFoodServer deployment to Heroku. Swift, Perfect, mustache and PostgreSQL on Heroku.
# Makefile for CatFoodServer
TARGET = CatFoodServer
OS = $(shell uname)
SWIFT_FILES = $(TARGET)/PerfectHandlers.swift \
$(TARGET)/CatNameHandler.swift \
$(TARGET)/FoodListHandler.swift
MUSTACHE_ROOT = $(TARGET)/Mustache
@abjurato
abjurato / Logger.swift
Created May 4, 2016 18:37
Logger for Heroku. Swift, Perfect, mustache and PostgreSQL on Heroku.
#if os(Linux)
import Glibc
#else
import Darwin
#endif
enum Logger {
static func info(string: String) {
fputs(string, stdout)
fflush(stdout)
@abjurato
abjurato / macho_extractor.c
Created September 27, 2019 12:54 — forked from C0deH4cker/macho_extractor.c
Program that will extract a segment from a mach-o file. Should even work on Linux/BSD/UNIX?
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
/* For supporting Linux and other systems that don't have mach-o headers */
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>application-identifier</key>
<string>io.abjurato.fancyname</string>
</dict>
</plist>
@abjurato
abjurato / EndpointSecurityDemo.m
Created February 13, 2020 14:49 — forked from Omar-Ikram/EndpointSecurityDemo.m
A demo of using Apple's new EndpointSecurity framework - tested on macOS Catalina 10.15 (19A583)
//
// main.m
// EndpointSecurityDemo
//
// Created by Omar Ikram on 17/06/2019 - Catalina 10.15 Beta 1 (19A471t)
// Updated by Omar Ikram on 15/08/2019 - Catalina 10.15 Beta 5 (19A526h)
// Updated by Omar Ikram on 01/12/2019 - Catalina 10.15 (19A583)
//
#import <Foundation/Foundation.h>
extension List {
@ViewBuilder func noSeparators() -> some View {
if #available(iOS 14.0, *) {
self
.accentColor(Color.secondary)
.listStyle(SidebarListStyle())
.onAppear {
UITableView.appearance().backgroundColor = UIColor.systemBackground
}
} else {