Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View luwes's full-sized avatar
🙇‍♂️

Wesley Luyten luwes

🙇‍♂️
View GitHub Profile
@luwes
luwes / sub.js
Last active December 23, 2015 10:09
Sub JavaScript library Very limited substitute for jQuery to include in small projects so you have no dependencies Browser support IE8+
/**
* Sub JavaScript library v0.2
* Very limited substitute for jQuery to include
* in small projects so you have no dependencies
* Browser support IE8+
*
* Includes code snippets from
* http://jquery.com/
* http://underscorejs.org/
*
@luwes
luwes / populate.js
Last active December 23, 2015 17:59
Populate - Tiny Javascript Template Function, http://luwes.co/populate-tiny-javascript-template-function/
String.prototype.populate = function(obj, funcs) {
return this.replace(/\{\{\s*([^|\s}]+)\|?([^\s}]*)\s*\}\}/g, function(match, key, mods) {
var str = obj[key];
if (typeof str !== "undefined") {
if (funcs && mods) {
var arr = mods.split('|');
for (var i = 0; i < arr.length; i++) {
var mod = arr[i].split(':')[0];
var par = arr[i].split(':')[1];
var args = par ? par.split(',') : [];
@luwes
luwes / _mixins.scss
Created October 1, 2013 07:43
Sass mixins
@mixin prefixed($property, $value) {
@each $prefix in "-webkit-", "-moz-", "-ms-", "-o-", "" {
#{$prefix}#{$property}: #{$value};
}
}
@mixin transition($props) {
@include prefixed('transition', $props);
}
#!/usr/bin/env bash
# Written by William Ting for the following blog post:
# http://williamting.com/posts/2012/04/18/set-up-python-and-django-on-dreamhost/
rcfile="${HOME}/.bashrc"
version="2.7.8"
setuptools_version="2.7"
tmp_dir="${HOME}/tmp-${RANDOM}"
if [[ ${#} == 0 ]]; then
@luwes
luwes / main.py
Last active September 27, 2016 18:26
Tornado Vimeo Mixin OAuth2
class BaseHandler(RequestHandler):
COOKIE_NAME = 'user'
def get_current_user(self):
user_json = self.get_secure_cookie(self.COOKIE_NAME)
if not user_json:
return None
return json_decode(user_json)
class LoginHandler(BaseHandler, VimeoMixin):
@luwes
luwes / rollup.js
Created September 7, 2017 00:58
Rollup library script - JavaScript API
/* eslint-env node */
const fs = require('fs');
const uglifyJs = require('uglify-js');
const chalk = require('chalk');
const maxmin = require('maxmin');
const rollup = require('rollup');
const babelrc = require('babelrc-rollup').default;
const babel = require('rollup-plugin-babel');
const nodeResolve = require('rollup-plugin-node-resolve');
@luwes
luwes / redux-proxy-selectors.js
Created December 26, 2017 04:59
Experiment to add selectors to state as getters
/**
The selectors would be a map e.g.
const selectors = {
ui: {
getDoubleBurgers: (state) => state.ui.burger + state.ui.burger
}
}
/* eslint-env node */
const fs = require('fs');
const path = require('path');
const camelCase = require('lodash/camelcase');
const pkg = require(path.resolve('package.json'));
const defaultOptions = {
regex: /^rollup-plugin-/,
path: './'
};
@luwes
luwes / tagref.js
Created March 24, 2019 01:00
Static variable tag names for lit-html, lighterhtml, etc...
import { html } from 'lit-html';
const superhtml = tagRef(html)
const result = superhtml`<${MyComponent}>Woohoo</${MyComponent}>`;
export function tagRef(html) {
const cache = new WeakMap();
return (s, ...e) => {
const tagIndex = (t, i) =>
// checks for '*<' or '*</' and a valid tagname

Keybase proof

I hereby claim:

  • I am luwes on github.
  • I am luwes (https://keybase.io/luwes) on keybase.
  • I have a public key ASDE6Oaedhz1Ud4ltpbKU0z19dFw1ubiJRxvsg_xqs4nsQo

To claim this, I am signing this object: