Skip to content

Instantly share code, notes, and snippets.

View menangen's full-sized avatar
🏠
Working from home

Andru Menangen menangen

🏠
Working from home
View GitHub Profile
@menangen
menangen / a-record.swift
Last active February 14, 2020 14:03
DNS TXT resolving in Swift5
let memory = rawData!.bindMemory(to: UInt8.self, capacity: 4)
print(memory[0], memory[1], memory[2], memory[3])
print(ttl, Int(rdlen))
/* ..... */
let error = DNSServiceQueryRecord(
&service,
kDNSServiceFlagsTimeout,
@menangen
menangen / AppDelegate.swift
Last active October 10, 2019 18:16
Legacy iPhone/Universal iOS application
import UIKit
import CoreData
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
@menangen
menangen / GCE-Finland.txt
Last active October 3, 2019 18:00
Python Async Ping subprocess
Austria: 40ms
Smolensk: 20ms
Sofia Bulgaria: 50ms
Tambov: 24ms
Moscow MTS: 14ms
Yandex Cloud: 17ms
Novosibirsk: 65ms
Yaroslavl: 19ms
Krasnodar: 37ms
Minsk: 54ms
@menangen
menangen / main.go
Last active September 22, 2019 19:23
Salsa20 Golang
package main
import (
//"crypto/rand"
"fmt"
"golang.org/x/crypto/salsa20"
)
func main() {
nonce := []byte {
@menangen
menangen / meson.build
Created August 20, 2019 09:07
QuickJS Meson build
project('quickjs', 'c', version : '2019-08-10')
add_project_arguments('-DCONFIG_VERSION="2019-08-10"', language : 'c')
lib = static_library('quickjs', 'quickjs.c', 'cutils.c', 'quickjs-libc.c', 'libregexp.c', 'libunicode.c')
compiler = executable('qjsc', 'qjsc.c', link_with : lib) #, link_args : '-Wl,-S'
repl_c = custom_target(
'repl.c',
@menangen
menangen / main.c
Last active March 2, 2023 20:04
QuickJS C API
//
// main.c
// testQJS
//
// Created by menangen on 15/08/2019.
// Copyright © 2019 menangen. All rights reserved.
//
#include "quickjs.h"
#include "quickjs-libc.h"
@menangen
menangen / swiftTests.swift
Created June 24, 2019 14:24
Default XCodeTest / Swift 4
import XCTest
import class Foundation.Bundle
final class commandlinetoolTests: XCTestCase {
func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct
// results.
// Some of the APIs that we use below are available in macOS 10.13 and above.
@menangen
menangen / Contents.swift
Created May 25, 2019 19:09
GKRidgedNoiseSource bug in Apple SpriteKit
import PlaygroundSupport
import Cocoa
import SpriteKit
import GameplayKit
class GameScene: SKScene {
let spriteSize: CGFloat = 128
let mapSize = double2(2, 2)
func getMapTexture(_ source: GKCoherentNoiseSource) -> SKTexture
@menangen
menangen / app.js
Created December 27, 2018 17:32
Human ready Base32 node.js
const assert = require('assert');
class Encoder {
static get alpha () {
return "0123456789ABCDEFGHJKLMNPQRSTVXYZ"
}
static getCode(number) {
const r = number & 31;
const diff = (number - r) >> 5;
@menangen
menangen / GameScene.swift
Last active November 15, 2018 11:09
SpriteKit
import SpriteKit
import GameplayKit
class GameScene: SKScene {
override func didMove(to view: SKView) {
let frequency: Double = 1.0
let sampleCount: Int32 = 16
let mapSize: Double = 5