Skip to content

Instantly share code, notes, and snippets.

View rhalff's full-sized avatar

Robbert Halff rhalff

  • Robbert Halff
  • Netherlands
View GitHub Profile
@rhalff
rhalff / star.dart
Last active August 18, 2019 21:30
Custom Star Painter
import 'dart:math' as math;
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
const double _kRadiansPerDegree = math.pi / 180;
class Star extends StatelessWidget {
final Color color;
@rhalff
rhalff / example.dart
Created February 15, 2019 02:05 — forked from sma/example.dart
A flutter example demonstrating a custom painter drawing selectable rects
class RectsExample extends StatefulWidget {
@override
_RectsExampleState createState() => _RectsExampleState();
}
class _RectsExampleState extends State<RectsExample> {
int _index = -1;
@override
Widget build(BuildContext context) {
@rhalff
rhalff / .Xresources
Created December 5, 2018 19:16 — forked from rawsh/.Xresources
.Xresources theme for rofi and terminal
! *----------------------------*
! | Dotfiles - .Xresources |
! *----------------------------*
! This files contains configuration for:
! * terminal colours
! * urxvt
! * rofi
@rhalff
rhalff / configuration.nix
Created December 1, 2018 13:23
configuration.nix
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
@rhalff
rhalff / .gvimrc
Created November 19, 2018 18:46 — forked from ryanflorence/.gvimrc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Font
:set guifont=Source\ Code\ Pro:h14
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Hide pointless junk at the bottom, doesn't work in .vimrc for some reason?
:set laststatus=0
:set noshowmode "don't show --INSERT--
:set noruler "don't show line numbers/column/% junk
@rhalff
rhalff / i3-config
Created October 7, 2018 14:53 — forked from bijanebrahimi/i3-config
Run terminator as a drop-down tiling terminal in i3-wm using scratchpad
# Add this to your i3 config (~/.config/i3/config) and restart i3 (Super+Shift+R)
exec --no-startup-id "terminator -m"
for_window [class="Terminator" title="^((?!Terminator Preferences).)*$"] move scratchpad, move position 0 0, resize set 1366 768;
bindsym F1 [class="Terminator"] scratchpad show;
@rhalff
rhalff / forkStream.js
Created September 22, 2018 13:19 — forked from jtbonhomme/forkStream.js
This gist shows how to fork a nodejs stream into 2 streams
var spawn = require('child_process').spawn;
var pass = require('stream').PassThrough;
var a = spawn('echo', ['hi user']);
var b = new pass;
var c = new pass;
a.stdout.pipe(b);
a.stdout.pipe(c);
@rhalff
rhalff / asymmetric.go
Created July 8, 2018 02:32 — forked from cryptix/LICENSE
example of using JWT for http authentication in go
package main
// using asymmetric crypto/RSA keys
import (
"crypto/rsa"
"fmt"
"io/ioutil"
"log"
"net/http"
@rhalff
rhalff / autobind.ts
Created May 5, 2018 21:30 — forked from rasmuskl/autobind.ts
TypeScript autobind decorator
function autobind<TFunction extends Function>(constructor: TFunction):TFunction {
const newConstructor = function(...args) {
constructor.apply(this, args);
for (const property in this) {
if (typeof this[property] !== typeof Function) {
continue;
}
this[property] = this[property].bind(this);
}
@rhalff
rhalff / typescript-mixins.ts
Created May 2, 2018 21:58
Typescript Mixins, using each others methods.
export type Constructor<T = {}> = new(...args: any[]) => T;
export interface FirstMixin { firstMethod: () => void; }
export interface SecondMixin { secondMethod: () => void; }
export interface UsingFirstMixin { useFirstMethod: () => void; }
export interface UsingFirstAndSecondMixin { useFirstAndSecondMethod: () => void; }
export function FirstMixin <T extends Constructor<{}>>(Base: T) {
return class First extends Base implements FirstMixin {
firstMethod() {