Skip to content

Instantly share code, notes, and snippets.

Avatar

Hajime Yamasaki Vukelic foxbunny

  • Devius LLP
  • Belgrade, Serbia
View GitHub Profile
View fib_proc.py
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
Local Vim configuration for C projects
View .vimrc
# 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 Mar 8, 2019
Reasonably good regexp library
View email.regex.js
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/
View functools.js
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 Nov 21, 2018
Imba-Vue adapter for using Imba apps inside Vue
View ImbaAdapter.js
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 Mar 31, 2018
Basic bar chart
View .block
license: mit
@foxbunny
foxbunny / jsx-dom.js
Last active Nov 21, 2019
JSX helper for creating DOM nodes
View jsx-dom.js
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 Aug 19, 2017
Bare-bones webpack 2 configuration for typescript projects
View webpack.config.ts
/**
* (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 Sep 14, 2017
JSX definition for Vue.js
View jsx.d.ts
// 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 {}
View fib.erl
-module(fib).
-export([fib/1, tests/0]).
fibOf(0) ->
0;
fibOf(1) ->
1;
fibOf(N) ->
fibOf(N-1) + fibOf(N-2).