Skip to content

Instantly share code, notes, and snippets.

View BenjaminVerble's full-sized avatar

Benjamin Verble BenjaminVerble

View GitHub Profile
@BenjaminVerble
BenjaminVerble / react-jsonschema-form-conditionals-example.js
Created March 28, 2018 02:55
react-jsonschema-form-conditionals example
import Engine from "json-rules-engine-simplified";
const conf = {
schema: {
type: "object",
properties: {
general: {
type: "object",
properties: {
a: {
@BenjaminVerble
BenjaminVerble / git-deployment.md
Created February 2, 2018 03:42 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your lokal GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like my Deepl.io to act upon a Web-Hook that's triggered that service.

@BenjaminVerble
BenjaminVerble / non-BMP-char-length.js
Last active January 14, 2018 22:55
why string.length is not always reliable
// BMP: Basic Multilingual Plane (U+0000 to U+FFFF)
// UTF-16 (16-bit Unicode Transformation Format) is an extension of UCS-2 that allows representing code points outside the BMP.
// It produces a variable-length result of either one or two 16-bit code units per code point.
// This way, it can encode code points in the range from 0 to 0x10FFFF. (source: https://mathiasbynens.be/notes/javascript-encoding)
// "Unicode code points 2^16 and above are represented in JavaScript by two code units, known as a surrogate pair." Effective JS, Herman (29)
import stringToCodePointArray from 'string-to-code-point-array'
const outsideBMP = '𝌆'
@BenjaminVerble
BenjaminVerble / svg-pattern-bug.html
Created October 23, 2017 20:39
print from chrome to see bad rasterization of svg pattern
<html>
<body>
<svg width="120" height="120" viewBox="0 0 120 120"
xmlns="http://www.w3.org/2000/svg">
<defs>
<pattern id="Triangle" width="10" height="10"
patternUnits="userSpaceOnUse">
<polygon points="5,0 10,10 0,10"/>
</pattern>
@BenjaminVerble
BenjaminVerble / react-datepicker-bug.js
Created August 10, 2017 17:04
react-datepicker-bug.md
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import DatePicker from 'react-datepicker';
import moment from 'moment';
import 'react-datepicker/dist/react-datepicker.css';
class App extends Component {
constructor() {
super();
@BenjaminVerble
BenjaminVerble / rsync-over-ssh.sh
Last active June 6, 2017 18:25
rsync single file over ssh
# https://www.digitalocean.com/community/tutorials/how-to-copy-files-with-rsync-over-ssh
# modified slightly
rsync -avz -e "ssh -o StrictHostKeyChecking=no" --progress ~/Desktop/test.txt username@10.2.3.456:~/Desktop/
CREATE TABLE books
(author_id varchar(55) PRIMARY KEY, title varchar(55))
;
INSERT INTO books
('author_id', 'title')
VALUES
('1asdfasdfasdfasdas', 'How to make your life better'),
('asdfasdf23423456gf', 'How to Cook'),
('2134dfg45675fa4352', 'Hi, what is your name, I am joe')
;
@BenjaminVerble
BenjaminVerble / README.md
Created February 23, 2017 20:15 — forked from track0x1/README.md
Conquering npm shrinkwrap (in layman's terms)

Conquering npm shrinkwrap (in layman's terms)

We've all been there. You start with a simple app idea and get to work. With the vast number of packages available on npmjs.org, your dependency list begins to grow exponentially. You then hear about a neat npm CLI command called shrinkwrap.

What is it?

[Shrinkwrap] locks down the versions of a package's dependencies so that you can control exactly which versions of each dependency will be used when your package is installed. – npmjs

Life without shrinkwrap

import Immutable from 'immutable'
const nested = Immutable.fromJS({a:1, b:2, pieces:[]})
const nested2 = nested.updateIn(['pieces'], list => list.push({player: 'player1'}));
const nested3 = nested2.updateIn(['pieces'], list => list.push({player: 'player2'}));
bin.log(nested3.toJS())
const nested4 = nested3.updateIn(['pieces'], list => list.pop())
bin.log(nested4.toJS())
import { createStore, combineReducers } from 'redux'
// for webpackbin
const log = typeof bin.log === 'function' ? bin.log : console.log;
function reducer (state = 0, action) {
if (action.type === 'INCREMENT') {
return state + 1
}
return state