View serialization.kt
import kotlinx.serialization.* | |
import kotlinx.serialization.internal.ArrayListSerializer | |
import kotlinx.serialization.internal.StringDescriptor | |
import kotlinx.serialization.json.Json | |
import kotlinx.serialization.modules.SerializersModule | |
@Serializable | |
sealed class Foo { | |
@Serializable |
View cnpj.kt
data class CNPJ(val value: String) | |
fun CNPJ.isValid(): Boolean { | |
val cnpj = value | |
return validateCNPJLength(cnpj) && validateCNPJRepeatedNumbers(cnpj) | |
&& validateCNPJVerificationDigit(true, cnpj) | |
&& validateCNPJVerificationDigit(false, cnpj) | |
} |
View compo_completed.js
// Auxiliary code!!!!! | |
// Ignore and go to "START FROM HERE" below!!!! | |
function randomInt(min, max) { | |
min = Math.ceil(min) | |
max = Math.floor(max) | |
return Math.floor(Math.random() * (max - min)) + min | |
} | |
// Data |
View FontCache.kt
object FontCache { | |
private val FONTS_DIR = "fonts/" | |
private val CACHE = Hashtable<String, Typeface>() | |
fun notoSansCJK(context: Context, textView: TextView) { | |
applyTypefaceAsync(context, textView, "NotoSansCJKjp-Regular.otf") | |
} |
View FirebaseIDGenerator.kt
/** | |
* * New version: 30/May/2017 | |
* * Made it more kotlin-like with same functionality ^^ | |
* | |
* based on: https://gist.github.com/RomansBermans/6f3836188427fbd3b1efcf7e6418f06d | |
* Fancy ID generator that creates 20-character string identifiers with the following properties: | |
* | |
* 1. They're based on timestamp so that they sort *after* any existing ids. | |
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs. | |
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly). |
View designer.html
<link rel="import" href="../paper-slider/paper-slider.html"> | |
<polymer-element name="my-element"> | |
<template> | |
<style> | |
:host { | |
position: absolute; | |
width: 100%; | |
height: 100%; |
View designer.html
<link rel="import" href="../polymer/polymer.html"> | |
<polymer-element name="my-element"> | |
<template> | |
<style> | |
:host { | |
position: absolute; | |
width: 100%; | |
height: 100%; |
View designer.html
<link rel="import" href="../core-scaffold/core-scaffold.html"> | |
<link rel="import" href="../core-header-panel/core-header-panel.html"> | |
<link rel="import" href="../core-menu/core-menu.html"> | |
<link rel="import" href="../core-item/core-item.html"> | |
<link rel="import" href="../core-icon-button/core-icon-button.html"> | |
<link rel="import" href="../core-toolbar/core-toolbar.html"> | |
<link rel="import" href="../core-menu/core-submenu.html"> | |
<link rel="import" href="../paper-button/paper-button.html"> | |
<link rel="import" href="../core-icons/core-icons.html"> | |
<link rel="import" href="../core-icon/core-icon.html"> |
View gist:310b526568b7157faad4
from mpl_toolkits.mplot3d import axes3d | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import scipy as sp | |
import scipy.optimize | |
def cylinderLineFirstInterval(cylinderLength, lineP0, lineP1): | |
l = cylinderLength | |
p0 = lineP0 | |
p1 = lineP1 |
View gist:db1752da2f982ea0dfb2
using GridT = openvdb::FloatGrid; | |
auto grid1 = openvdb::tools::createLevelSetSphere<GridT>( | |
512.0, openvdb::Vec3f(0, 0, 0), 1, 2); | |
Sphere s0{glm::vec4(-512,-512,512,1), 16}; | |
LinearSphereSweptVolume volume0(s0, /*translation=*/glm::vec3(1024, 1024, 0)); | |
auto grid2 = create_levelset_volume<GridT>(volume0, 1, 2); | |
openvdb::tools::csgDifference(*grid1, *grid2); | |
s0 = Sphere{glm::vec4(-512,512,1024,1), 16}; |
NewerOlder