Skip to content

Instantly share code, notes, and snippets.

@inso-
inso- / rootkit.c
Last active September 17, 2020 01:34
Linux 4.X Kernel Rootkit Open
/*
* open_rootkit.c - Thomas Moussajee
* C Unix Rootkit open
* Make a file forbiden for everyone include root with permission
* HOW TO COMPILE : create a Makefile, make
* exemple of Makeflle :
+ KERNELDIR ?= /lib/modules/$(shell uname -r)/build
+ PWD := $(shell pwd)
+ NAME = rootkit.ko
+ all: $(NAME)
@inso-
inso- / WeakReference.swift
Created March 22, 2020 16:03
propertyWrapper WeakReference
@propertyWrapper
struct WeakReference<T> {
private weak var storage: AnyObject? = nil
private var value: T?{
get { return storage.map { $0 as! T } }
set {
storage = newValue.map {
let asObject = $0 as AnyObject
assert(asObject === $0 as AnyObject)
return asObject
@inso-
inso- / Weak.swift
Created July 7, 2020 14:37
Weak Property Wrapper + Hashable
@propertyWrapper
public struct Weak<Wrapped: AnyObject> {
private weak var value: AnyObject?
public init(_ value: Wrapped? = nil) {
self.value = value
}
public var wrappedValue: Wrapped? {
get { value as? Wrapped }
@inso-
inso- / Weak.swift
Created July 7, 2020 14:53
Weak property Wrapper
@propertyWrapper
public struct Weak<Wrapped: AnyObject> {
private weak var value: AnyObject?
public init(_ value: Wrapped? = nil) {
self.value = value
}
public var wrappedValue: Wrapped? {
get { value as? Wrapped }
@inso-
inso- / Weak+Hashable.swift
Created July 7, 2020 14:58
Hashable extension to Weak property wrapper
extension Weak: Hashable {
public static func == (lhs: Weak<Wrapped>, rhs: Weak<Wrapped>) -> Bool {
lhs.hashValue == rhs.hashValue
}
public func hash(into hasher: inout Hasher) {
hasher.combine(unsafeBitCast(value, to: Int.self))
}
}
@inso-
inso- / PropertyData.swift
Last active July 8, 2020 13:13
static hashmap container
private struct PropertyData {
static private let accessQueue = DispatchQueue(label: "SynchronizedPropertyDataAccess", attributes: .concurrent)
static private var property = [Weak<AnyObject>: [Any]]()
static func memoryClean() {
Self.accessQueue.async(flags: .barrier) {
property = property.filter({$0.key.wrappedValue != nil})
}
}
@inso-
inso- / PropertyData.swift
Created July 7, 2020 15:24
PropertyData Accessor
@propertyWrapper
public class Property<T: Any> {
public var wrappedValue: T? {
get { PropertyData.get(key) ?? nil }
set { PropertyData.set(key, value: newValue as Any) }
}
let key: Weak<AnyObject>
import UIKit
public enum Style {
case dark
case light
case `default`
}
protocol Coolable {
var isCool: Bool { get set }