Skip to content

Instantly share code, notes, and snippets.

View foxbunny's full-sized avatar

Hajime Yamasaki Vukelic foxbunny

View GitHub Profile
@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,
from time import time
def fib(x):
if x in (0, 1):
return x
fib1 = 0
fib2 = 1
current = 1
@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
@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/
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 / 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'
@foxbunny
foxbunny / .block
Created March 31, 2018 11:58
Basic bar chart
license: mit
@foxbunny
foxbunny / jsx-dom.js
Last active November 21, 2019 23:04
JSX helper for creating DOM nodes
const h = (tag, attrs, ...children) => {
const elm = document.createElement(tag)
for (let key in attrs) {
if (key.slice(0, 2) == 'on') {
const evtName = key.slice(2)
const cb = attrs[key]
if (cb == null) continue // we can use null or undefnied to suppress
elm.addEventListener(evtName, cb)
} else if (['disabled', 'autocomplete', 'selected', 'checked'].indexOf(key) > -1) {
if (attrs[key]) {
@foxbunny
foxbunny / webpack.config.ts
Last active August 19, 2017 09:00
Bare-bones webpack 2 configuration for typescript projects
/**
* (c) 2017 Hajime Yamasaki Vukelic
* Some rights reserved.
*
* yarn add -D webpack webpack-dev-server ts-node ts-loader html-webpack-plugin @types/webpack @types/html-webpack-plugin
*/
import path = require("path");
import HTMLWebpackPlugin = require("html-webpack-plugin");
@foxbunny
foxbunny / jsx.d.ts
Last active September 14, 2017 13:00
JSX definition for Vue.js
// I'm not the original author of this code. Please let me
// know if you know/find the original author so I can fully
// attribute.
import Vue, { VNode } from "vue";
declare global {
namespace JSX {
interface Element extends VNode {}
interface ElementClass extends Vue {}