Skip to content

Instantly share code, notes, and snippets.

View foxbunny's full-sized avatar

Hajime Yamasaki Vukelic foxbunny

View GitHub Profile
@foxbunny
foxbunny / ImbaAdapter.js
Last active November 21, 2018 14:05
Imba-Vue adapter for using Imba apps inside Vue
import Vue from 'vue'
import { Component, Prop } from 'vue-property-decorator'
import Imba from 'imba'
/**
import { App } from './App.imba'
import ImbaAdapter from './ImbaAdapter'
function reduce(transform, append, arr, init) {
const l = arr.length
let i = 0
let accum = init
if (typeof accum === 'undefined') {
accum = arr[0]
i = 1
}
for (; i < l; i++) {
accum = append(accum, transform(arr[i]))
@foxbunny
foxbunny / email.regex.js
Created March 8, 2019 17:07
Reasonably good regexp library
const emailRe = /^([\w\d\-+](\.?[\w\d_\-+])*)@(((2([0-4]\d|5[0-5])|1?\d{1,2})\.){3}(2([0-4]\d|5[0-5])|1?\d{1,2})|[a-z\d]([a-z\d-]{1,61}[a-z\d])?(?:\.[a-z]{2,})+)$/
// Able to pass the test samples here: https://blogs.msdn.microsoft.com/testing123/2009/02/06/email-address-test-cases/
@foxbunny
foxbunny / .vimrc
Created May 23, 2019 08:51
Local Vim configuration for C projects
# Taken from http://www.alexeyshmalko.com/2014/using-vim-as-c-cpp-ide/
set tabstop=4
set softtabstop=4
set shiftwidth=4
set noexpandtab
augroup project
autocmd!
autocmd BufRead,BufNewFile *.h,*.c set filetype=c.doxygen
from time import time
def fib(x):
if x in (0, 1):
return x
fib1 = 0
fib2 = 1
current = 1
@foxbunny
foxbunny / svg-spritesheet-snippet.js
Created November 28, 2023 22:39
SVG spritesheet creation script for use in Google Chrome Snippets
let svgMimeType = 'image/svg+xml'
let svgNS = 'http://www.w3.org/2000/svg'
let preamble = '<?xml version="1.0" encoding="utf-8"?>'
Object.assign(document.createElement('input'), {
type: 'file',
accept: svgMimeType,
multiple: true,
onchange: processFiles,
function findEnumerableProperties(obj) {
let enumerableProperties = []
let descriptors = Object.getOwnPropertyDescriptors(obj)
for (let k in descriptors)
if (descriptors[k].enumerable)
enumerableProperties.push(k)
return enumerableProperties
}
let builtins = [Object, Array, String, Number, Boolean, RegExp, Set, Map, Date, WeakMap, WeakSet, WeakRef, Function, Event, Element]