Skip to content

Instantly share code, notes, and snippets.

@ivan-ushakov
ivan-ushakov / MarchingCubes.swift
Last active June 1, 2019 11:16
Marching Cubes triangulation tables
let table11: [simd_int4] = [
[0, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [2, 0, 0, 0], [1, 0, 0, 0], [2, 0, 0, 0], [2, 0, 0, 0], [3, 0, 0, 0],
[1, 0, 0, 0], [2, 0, 0, 0], [2, 0, 0, 0], [3, 0, 0, 0], [2, 0, 0, 0], [3, 0, 0, 0], [3, 0, 0, 0], [2, 0, 0, 0],
[1, 0, 0, 0], [2, 0, 0, 0], [2, 0, 0, 0], [3, 0, 0, 0], [2, 0, 0, 0], [3, 0, 0, 0], [3, 0, 0, 0], [4, 0, 0, 0],
[2, 0, 0, 0], [3, 0, 0, 0], [3, 0, 0, 0], [4, 0, 0, 0], [3, 0, 0, 0], [4, 0, 0, 0], [4, 0, 0, 0], [3, 0, 0, 0],
[1, 0, 0, 0], [2, 0, 0, 0], [2, 0, 0, 0], [3, 0, 0, 0], [2, 0, 0, 0], [3, 0, 0, 0], [3, 0, 0, 0], [4, 0, 0, 0],
[2, 0, 0, 0], [3, 0, 0, 0], [3, 0, 0, 0], [4, 0, 0, 0], [3, 0, 0, 0], [4, 0, 0, 0], [4, 0, 0, 0], [3, 0, 0, 0],
[2, 0, 0, 0], [3, 0, 0, 0], [3, 0, 0, 0], [2, 0, 0, 0], [3, 0, 0, 0], [4, 0, 0, 0], [4, 0, 0, 0], [3, 0, 0, 0],
[3, 0, 0, 0], [4, 0, 0, 0], [4, 0, 0, 0], [3, 0, 0, 0], [4, 0, 0, 0], [5, 0, 0, 0], [5, 0, 0, 0], [2, 0, 0, 0],
[1, 0, 0, 0], [2, 0, 0, 0], [2, 0, 0, 0], [3, 0, 0, 0], [2, 0,
import Foundation
import JSON
let FILE_BUFFER_SIZE = 50000
// source data
struct DebtRec {
var company: String
var phones: Array<String>
var debt: Double
import Foundation
let FILE_BUFFER_SIZE = 50000
// source data
struct DebtRec {
var company: String
var phones: Array<String>
var debt: Double
}
import Foundation
let FILE_BUFFER_SIZE = 50000
// source data
class DebtRec {
var company: String = ""
var phones: Array<String> = []
var debt: Double = 0.0
}
import UIKit
import CoreImage
func createQRFromString(str: String) -> CIImage? {
let stringData = str.data(using: .utf8) as? NSData
guard let f1 = CIFilter(name: "CIQRCodeGenerator") else {
return nil
}
@ivan-ushakov
ivan-ushakov / GLSL-Lights.md
Created December 11, 2018 07:56 — forked from patriciogonzalezvivo/GLSL-Lights.md
GLSL Shaders Lights Funtions
@ivan-ushakov
ivan-ushakov / RecordAudio.swift
Created October 18, 2017 16:54 — forked from hotpaw2/RecordAudio.swift
Swift 3.0 Audio Recording class. Reads buffers of input samples from the microphone using the iOS RemoteIO Audio Unit API
//
// RecordAudio.swift
//
// This is a Swift 3.0 class
// that uses the iOS RemoteIO Audio Unit
// to record audio input samples,
// (should be instantiated as a singleton object.)
//
// Created by Ronald Nicholson on 10/21/16. Updated 2017Feb07
// Copyright © 2017 HotPaw Productions. All rights reserved.
@ivan-ushakov
ivan-ushakov / freqs-pure.cpp
Last active March 23, 2017 17:44
Calculate frequency of words in text. Version without std containers.
// requires C++11, compile with -std=c++11 flag
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <algorithm>
namespace t1
{
template <typename T>
@ivan-ushakov
ivan-ushakov / freqs.cpp
Created March 2, 2017 19:11
Calculate frequency of words in text.
// requires C++11, compile with -std=c++11 flag
#include <string>
#include <unordered_map>
#include <vector>
#include <fstream>
#include <iostream>
#include <sstream>
#include <algorithm>
class Counter