Skip to content

Instantly share code, notes, and snippets.

View robbertvancaem's full-sized avatar
👋
Hi!

Robbert van Caem robbertvancaem

👋
Hi!
View GitHub Profile
@robbertvancaem
robbertvancaem / 0_reuse_code.js
Last active August 29, 2015 14:25
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@robbertvancaem
robbertvancaem / gist:926841599e856d6746dd631df4f03deb
Created August 12, 2016 14:34
Convert MyISAM tables to InnoDB
all_dbs=”$(mysql -h $DB_HOST -u $DB_USER -p$DB_PASS -e ‘show databases;’)”
for db in $all_dbs
do
if test $db != “mysql” && [[ $db == *$db_filter* ]]
then sql=$(mysql -h $DB_HOST -u $DB_USER -p$DB_PASS -e “SET @DATABASE_NAME=’$db’; SELECT CONCAT(‘ALTER TABLE ‘, table_name,’ ENGINE=\’InnoDB\’;’) AS ‘’ FROM information_schema.tables AS tb WHERE table_schema = @DATABASE_NAME AND ENGINE=’MyISAM’ ORDER BY table_name DESC;”) &&
mysql -h $DB_HOST $db -u $DB_USER -p$DB_PASS -e “$sql”
fi
done
@robbertvancaem
robbertvancaem / filter_csv.py
Created May 20, 2018 10:15
Filter CSV based on value of column
"""Filter CSV"""
import csv
import time
PASS_FILTER = ['Value A',
'Value B']
FILENAME = 'Filename'
EXTENSION = 'csv'
ORIGINAL_FILENAME = FILENAME + '.' + EXTENSION
@robbertvancaem
robbertvancaem / capitalizeKeys.js
Created March 13, 2019 14:40
Capitalize keys in an object recursively
/**
* Utility function to capitalize the keys of an object recursively
* @param {Object} obj The object to capitalize the keys for
* @return {Object} The provided object with capitalized keys
*/
const capitalizeKeys = obj => {
return Object.keys(obj).reduce((acc, key) => {
const capitalizedKey = `${key.charAt(0).toUpperCase()}${key.slice(1)}`
if (typeof obj[key] !== 'object') {
@robbertvancaem
robbertvancaem / index.js
Created November 24, 2019 12:28
react-spring-demo-1
import React from "react";
import ReactDOM from "react-dom";
import "./styles.css";
function App() {
return (
<div className="App">
<h1>Hello CodeSandbox</h1>
<h2>Start editing to see some magic happen!</h2>
@robbertvancaem
robbertvancaem / index.js
Last active November 24, 2019 12:37
react-spring-demo-2
import React from "react";
import ReactDOM from "react-dom";
import { useSpring, animated } from "react-spring";
import "./styles.css";
function App() {
const [props, set] = useSpring(() => ({ left: 0 }));
return (
<div className="App">
@robbertvancaem
robbertvancaem / index.js
Created November 24, 2019 12:35
react-spring-demo-3
import React, { useState } from "react";
import ReactDOM from "react-dom";
import { useSpring, animated } from "react-spring";
import "./styles.css";
function App() {
const [toggle, setToggle] = useState(false);
const [props, set] = useSpring(() => ({ left: 0 }));
return (
@robbertvancaem
robbertvancaem / now.json
Created December 9, 2019 08:29
dynamic-routing-now-1
{
"name": "dynamic-routing",
"version": 2,
"builds": [{ "src": "next.config.js", "use": "@now/next" }],
"routes": [
{ "src": "/", "dest": "/index" },
{
"src": "/_next/static/(?:[^/]+/pages|chunks|runtime)/.+",
"headers": { "cache-control": "immutable,max-age=31536000" }
}
@robbertvancaem
robbertvancaem / now.json
Created December 9, 2019 08:29
dynamic-routing-now-2
{
"name": "dynamic-routing",
"version": 2,
"builds": [{ "src": "next.config.js", "use": "@now/next" }],
"routes": [
{ "src": "/", "dest": "/index" },
{ "src": "/(?<slug>[^/]+)", "dest": "/post?slug=$slug" },
{
"src": "/_next/static/(?:[^/]+/pages|chunks|runtime)/.+",
"headers": { "cache-control": "immutable,max-age=31536000" }
@robbertvancaem
robbertvancaem / post.js
Created December 9, 2019 08:30
dynamic-routing-now-3
// pages/post.js
import React from 'react';
const Post = ({ slug }) => <div>{slug}</div>;
Post.getInitialProps = async ({ query }) => {
const { slug } = query;
return {