Skip to content

Instantly share code, notes, and snippets.

View trenskow's full-sized avatar

Kristian Trenskow trenskow

View GitHub Profile
@trenskow
trenskow / validate-user.js
Created February 9, 2020 11:45
How to check if two password are equal using invalid.
const user = await isvalid(/* data */,
{
type: Object,
schema: {
'username': { /* username validators */ },
'password': { type: String, required: true, match: /* some regular expression */ },
'password_repeated': { type: String, required: true }
},
post: (obj) {
if (obj.password !== obj.password_repeated) {
@trenskow
trenskow / toCase.js
Last active July 18, 2022 11:02
An convenience method for converting to and from different casing types.
if (!String.prototype.toCase) {
Object.defineProperties(String.prototype, {
'toCase': {
value: function(type = 'camel') {
const seperators = {
'camel': '',
'pascal': '',
'snake': '_',
'domain': '.',
@trenskow
trenskow / example.js
Last active December 14, 2018 00:41
A hack that makes express accept async methods.
const express = require('express');
const app = express();
app.get(
'/',
async (req, res) => {
res.json(await something());
});
//
// NSObject+NSObject_AssociatedObjects.h
// Created by Kristian Trenskow.
//
#import <Foundation/Foundation.h>
/**
Associated objects additions to `NSObject`.
*/
@trenskow
trenskow / gist:b05325cf57d0e63befbd
Created March 6, 2016 18:06
DR.dk - no backdrop.
body, body:before, body:after, .site-wrapper {
background: transparent !important;
background-image: none !important;
}
ofEnableBlendMode(OF_BLENDMODE_ALPHA);
ofEnableAlphaBlending();
_internalImage.allocate(ofGetWidth(), ofGetHeight(), OF_IMAGE_COLOR_ALPHA);
_internalImage.setUseTexture(true);
_internalImage.setColor(ofColor(0, 0, 0, 0));
_internalImage.bind();
@trenskow
trenskow / gist:4050981
Created November 10, 2012 12:50
bodyParser and multipart/form-data
var express = require('express');
var app = express();
app.configure(function() {
app.use(express.bodyParser());
app.get('/', function(req, res, next) {