Skip to content

Instantly share code, notes, and snippets.

View MatthiasWinkelmann's full-sized avatar

Matthias Winkelmann MatthiasWinkelmann

View GitHub Profile
@MatthiasWinkelmann
MatthiasWinkelmann / prime.c
Last active May 9, 2016 16:18 — forked from airspeedswift/prime.c
Swift vs C Prime Number Benchmark
// code originally adapted from https://github.com/DuncanMC/SwiftPerformanceBenchmark
#include <stdlib.h>
#include <stdio.h>
#include <CoreFoundation/CFDate.h>
void updateTotal(int newTotal, CFAbsoluteTime startTime) {
CFAbsoluteTime now = CFAbsoluteTimeGetCurrent();
CFAbsoluteTime totalTime = now - startTime;
@MatthiasWinkelmann
MatthiasWinkelmann / redis.rb
Created May 11, 2016 18:24 — forked from pubis/redis.rb
Redis config and initialization for rails
#config/initializers/redis.rb
require 'redis'
require 'redis/objects'
REDIS_CONFIG = YAML.load( File.open( Rails.root.join("config/redis.yml") ) ).symbolize_keys
dflt = REDIS_CONFIG[:default].symbolize_keys
cnfg = dflt.merge(REDIS_CONFIG[Rails.env.to_sym].symbolize_keys) if REDIS_CONFIG[Rails.env.to_sym]
$redis = Redis.new(cnfg)
Redis::Objects.redis = $redis
@MatthiasWinkelmann
MatthiasWinkelmann / beautiful-failure.py
Created May 22, 2016 17:58
An Ansible plugin to format console output
# Save as <folder with your playbook>/callback_plugins/<some name>.py
# Optionally use no_log: True on your playbook/roles/tasks to suppress other output
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import time
import json
import sys

Keybase proof

I hereby claim:

  • I am matthiaswinkelmann on github.
  • I am matthi (https://keybase.io/matthi) on keybase.
  • I have a public key ASC58jvqyXfBdzAYxJyHPiJvb1YR31znPlI9rOD7zXzSOgo

To claim this, I am signing this object:

@MatthiasWinkelmann
MatthiasWinkelmann / ... Syncing stylelint and editorconfig.md
Last active July 23, 2023 13:14
Syncing stylelint and editorconfig

Synchronizing .editorconfig and stylelint

Note: See MatanelGordon's comment for an updated approach to do this.

Just a quick how-to to import rules specified in .editorconfig into your stylelint configuration to avoid duplication.

Install the following packages. stylelint-config-standard is just used as an example. Use a different one or your current configuration object.

#> (npm install -g | yarn global add) editorconfig stylelint stylelint-config-standard 
@MatthiasWinkelmann
MatthiasWinkelmann / preview.rb
Created March 16, 2017 21:55
A ruby script to quickly generate one colourful terminal output
require 'colorize'
puts "\n"
3.times do
String.colors.each do |color|
print ' '.colorize(color: :default, background: color)
print ' '
end
puts ''
end
@MatthiasWinkelmann
MatthiasWinkelmann / tasks.json
Created May 18, 2017 15:21
VSCode (Visual Studio Code) tasks.json configuration for rails guard test runner task
{
"command": "watch",
"suppressTaskName": true,
"tasks": [{
"taskName": "watch",
"command": "rbenv",
"args": ["exec", "bundle", "exec", "guard", "--no-interactions"],
"isBackground": true,
"problemMatcher": {
"applyTo": "allDocuments",
@MatthiasWinkelmann
MatthiasWinkelmann / .pryrc
Created May 19, 2017 04:45
Filter ruby's <Class>.methods to exclude the common ones
module ObjectExtensions
def methods
return super - Object.methods unless self == Object
super
end
end
class Object
prepend ObjectExtensions
end
@MatthiasWinkelmann
MatthiasWinkelmann / extract.py
Last active March 5, 2024 06:19
Extract PNG images from the cifar-100/cifar-10 pickled dataset
# This extracts png images from the
# packed/pickle'd cifar-100 dataset
# available at http://www.cs.toronto.edu/~kriz/cifar.html
#
# No Rights Reserved/ CC0
# Say thanks @whereismatthi on Twitter if it's useful
#
# probably requires python3
# definitely requires PyPNG: pip3 install pypng
@MatthiasWinkelmann
MatthiasWinkelmann / index.html
Last active July 11, 2017 11:59
Minimal example using the StackExchange API
<html>
<head>
<script type='text/javascript' src='https://api.stackexchange.com/js/2.0/all.js'></script>
<script>
// I was a bit stumped because there wasn\'t a single example of how to actually'
// use the StackExchange JS API. As it turns out, you actually don\'t really use it.
// This SE.init() call may or may not get you higher quotas, and it allows your
// users to authenticate. If you don't need those, you can use the REST API without any
// libraries as shown below in getQuestions();",
SE.init({