Skip to content

Instantly share code, notes, and snippets.

View jillesme's full-sized avatar
™️

Jilles Soeters jillesme

™️
View GitHub Profile
import React, { Component } from "react";
import { render } from "react-dom";
const Message = ({ text, date }) => (
<div id="message" className="card">
<div className="cell large-4">{text}</div>
<div className="cell large-2 text-right">
<small>{date}</small>
</div>
</div>
@jillesme
jillesme / test.py
Created May 20, 2020 23:16
Django in-memory image creation for testing
def create_image(self, height=50, width=50, format="jpeg"):
image = BytesIO()
memory_image = Image.new("RGB", (height, width))
memory_image.save(image, format=format)
return SimpleUploadedFile(f"test.{format}", image.getvalue(), f"image/{format}")
@jillesme
jillesme / app.js
Created November 11, 2016 06:36
Little refactor
function handlePossibleError(err) {
if (!err) return;
console.log('------- ERROR --------');
console.error(err);
console.log('----------------------');
}
function insertIntoDatabase(db, data) {
var tweets = db.collection('tweets');
var reg = /(https:\/\/.+)/g;
@jillesme
jillesme / App.jsx
Last active August 30, 2018 09:23
React, Redux and react-redux
import React, { Component } from 'react';
import { createStore } from 'redux'
import { Provider, connect } from 'react-redux'
// create-react-app specific
import logo from './logo.svg';
import './App.css';
const FRAMEWORKS = ['React', 'Angular', 'Vue', 'Ember'];
@jillesme
jillesme / egghead-total-duration.js
Last active February 19, 2016 19:52
Egghead total duration of a course..
(function (s) {
return [~~(s / 3600), ~~((s % 3600) / 60), s % 60].map(v => v < 10 ? '0' + v : v).join(':');
})([].slice.call(document.querySelectorAll('.duration'))
.filter((e, i, a) => ++i <= (a.length / 3))
.map(h => {
var t = h.textContent.match(/[0-9]{1,2}:[0-9]{1,2}/);
var p = t[0].split(':').map(Number);
return (p[0] * 60) + p[1]
}).reduce((p, c) => p + c, 0));
def kebab_to_camel(string):
splitted = string.split('-')
result = [part.title() for part in splitted[1:]]
result.insert(0, splitted[0].lower())
return ''.join(result)
@jillesme
jillesme / .tmux.conf
Created October 16, 2015 09:50
Jilles' tmux configuration
# allow pbcopy | pbpase on OSX
set-option -g default-command "reattach-to-user-namespace -l zsh"
# set colours
set -g default-terminal "screen-256color"
# use ctrl+a rather than ctrl+b (capslock == ctrl)
unbind C-b
set-option -g prefix C-a
bind C-a send-prefix
setTimeout(function () {
document.location.reload();
}, 1000 * 60 * 5);
source ~/.vundle
" -- DEFAULTS --
" UTF-8 encoding
set encoding=utf-8
" Default dir is sites
cd ~/Appsbroker
source ~/.vundle
" -- DEFAULTS --
" UTF-8 encoding
set encoding=utf-8
" Default dir is sites
cd ~/Appsbroker