Skip to content

Instantly share code, notes, and snippets.

View nektro's full-sized avatar
🌻
if you know, you know

Meghan Denny nektro

🌻
if you know, you know
View GitHub Profile
@nektro
nektro / _uikit.js
Created March 23, 2018 07:15
Bootstrapping HTML
//
'use strict';
import { create_element } from "https://rawgit.com/Nektro/modules.js/439458f/src/create_element.js";
export function createUIWindow(model) {
const view = model.map(x => createComponent(x));
for (const ele of view) {
<!doctype html>
<html>
<head>
<title>edge iframe memory test</title>
<style>
body {
margin: 0;
overflow-x: hidden;
}
iframe {
@nektro
nektro / lucky_numbers.js
Last active February 13, 2018 12:19
Find the [Lucky Numbers](https://en.wikipedia.org/wiki/Lucky_number) up to a certain `n`
function getLuckNumbersTo(n, d=false) {
const start = Date.now();
let lucky = new Array(n).fill(0).map((v,i) => i+1);
if (d) console.log(lucky);
for (let i = 2; i < lucky.length;) {
for (let j = i; j <= lucky.length; j+=i) {
lucky.splice(j-1, 1, 0);
}
lucky = lucky.filter(v => v !== 0);
if (d) console.log(i, lucky);
.square:after {
content: "";
display: block;
padding-bottom: 100%;
}
@nektro
nektro / createImageBitmap.js
Created November 7, 2017 01:14
Edge and Safari Polyfill for createImageBitmap
/* Safari and Edge polyfill for createImageBitmap
* https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap
*/
if (!('createImageBitmap' in window)) {
window.createImageBitmap = async function(blob) {
return new Promise((resolve,reject) => {
let img = document.createElement('img');
img.addEventListener('load', function() {
resolve(this);
});
@nektro
nektro / bs4-accordion.html
Created October 11, 2017 00:34
Bootstrap 4 Accordion Custom Element w/ Corgi Example
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<script defer src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script defer src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<template id="template-bs4-accordion-item">
<div class="card">
<div class="card-header" role="tab" id="headingOne">
<h5 class="mb-0">
<a data-toggle="collapse"
@nektro
nektro / bin2.js
Last active October 16, 2017 02:25
algorithm 3.2
function bin2(n, k)
{
const B = new Array(n+1).fill(0).map((x) => {
return new Array(k+1).fill(0);
});
for (let i = 0; i <= n; i++) {
for (let j = 0; j <= Math.min(i,k); j++) {
if (j === 0 || j === i) {
B[i][j] = 1;
@nektro
nektro / install_composer.sh
Created July 9, 2017 02:29
Installer shell scripts
#!/usr/bin/env bash
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
@nektro
nektro / CoolioVirus.java
Last active January 28, 2017 05:32
Coolio Albainian Virus meme
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class CoolioVirus
{
public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException
{
String title = "Virus Alert !";
String message = "Hi, I am an Albanian virus but because of poor technology in my\n" +
@nektro
nektro / custom_element.html
Created January 14, 2017 07:18
access the dom inside html imports
<script>
const importDoc = document.currentScript.ownerDocument;
</script>