Skip to content

Instantly share code, notes, and snippets.

Avatar

Roland Ekström peshi

  • Peshi AB
  • Sweden
View GitHub Profile
View purifycss.js
const fs = require('fs')
const _sass = require('node-sass')
const cssnano = require('cssnano')
const purifycss = require('purify-css')
const promisify = (ctx, func = ctx) => (...args) => {
return new Promise((resolve, reject) => {
func.apply(ctx, [...args, (err, result) => err ? reject(err) : resolve(result)])
})
}
@peshi
peshi / composeWithTracker.js
Created Feb 5, 2017
Drop in replacement for react-komposer 2 - Meteor.js
View composeWithTracker.js
import { Tracker } from 'meteor/tracker';
import { compose } from 'react-komposer';
const getTrackerLoader = reactiveMapper => (
(props, onData, env) => {
let trackerCleanup = null;
const handler = Tracker.nonreactive(() =>
Tracker.autorun(() => {
// assign the custom clean-up function.
trackerCleanup = reactiveMapper(props, onData, env);
View keybase.md

Keybase proof

I hereby claim:

  • I am peshi on github.
  • I am peshi (https://keybase.io/peshi) on keybase.
  • I have a public key whose fingerprint is 0B42 5086 A4F8 51A6 C721 76EF E319 4EE4 D10B D810

To claim this, I am signing this object:

@peshi
peshi / blockpeers.sh
Created Mar 7, 2016 — forked from jult/blockpeers.sh
blocking p2p peer snoopers and evil corp (for Tixati IP filter and such)
View blockpeers.sh
#!/bin/sh
# This script runs every other night at 04:56 CET on a webserver I maintain
# Results are always at: https://jult.net/block.txt ( or https://jult.net/block.txt.gz )
# And much smaller, stripped of BS; https://jult.net/bloc.txt
# For use in Tixati IP filter: https://jult.net/bloc.txt.gz
# And finally a txt file with just the bold IP-ranges: https://jult.net/bl.txt (or https://jult.net/bl.txt.gz )
# Download open block-lists, unpack, filter:
curl -s https://www.iblocklist.com/lists.php | grep -A 2 Bluetack | xargs wget -qO - --limit-rate=500k | gunzip -f | egrep -v '^#' > /tmp/xbp
@peshi
peshi / letsencrypt.md
Created Dec 5, 2015 — forked from xrstf/letsencrypt.md
Let's Encrypt on Ubuntu 14.04, nginx with webroot auth
View letsencrypt.md

Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

This document details how I setup LE on my server. Firstly, install the client as described on http://letsencrypt.readthedocs.org/en/latest/using.html and make sure you can execute it. I put it in /root/letsencrypt.

As it is not possible to change the ports used for the standalone authenticator and I already have a nginx running on port 80/443, I opted to use the webroot method for each of my domains (note that LE does not issue wildcard certificates by design, so you probably want to get a cert for www.example.com and example.com).

Configuration

For this, I placed config files into etc/letsencrypt/configs, named after <domain>.conf. The files are simple:

@peshi
peshi / list-group-simple.html.twig
Last active Aug 29, 2015
Simplified list-group.html.twig
View list-group-simple.html.twig
{% extends 'knp_menu.html.twig' %}
{% macro attributes(attributes) %}
{% for name, value in attributes %}
{%- if value is not none and value is not sameas(false) -%}
{{- ' %s="%s"'|format(name, value is sameas(true) ? name|e : value|e)|raw -}}
{%- endif -%}
{%- endfor -%}
{% endmacro %}
@peshi
peshi / flash_helper.rb
Last active Aug 29, 2015
Rails Bootstrap 3 Flash message helper
View flash_helper.rb
module FlashHelper
# Helper for Bootstrap styled flash messages.
def bootstrap_class_for(flash_type)
case flash_type
when 'success'
'alert alert-success alert-dismissable fade in' # Green
when 'error'
'alert alert-danger alert-dismissable fade in' # Red
when 'alert'
View UUID.php
<?php
/**
* UUID class
*
* The following class generates VALID RFC 4211 COMPLIANT
* Universally Unique IDentifiers (UUID) version 3, 4 and 5.
*
* UUIDs generated validates using OSSP UUID Tool, and output
* for named-based UUIDs are exactly the same. This is a pure
* PHP implementation.
@peshi
peshi / objectToArray.php
Last active Aug 29, 2015
Convert multidimensional stdClass object(s) to array.
View objectToArray.php
<?php
/**
* Convert multidimensional stdClass object(s) to array
*
* @param $object
* @return array
*/
private function objectToArray($object) {
if (is_object($object)) {
@peshi
peshi / menu.html.twig
Created Feb 2, 2014
twbs list-group menu
View menu.html.twig
{% extends 'knp_menu.html.twig' %}
{% macro attributes(attributes) %}
{% for name, value in attributes %}
{%- if value is not none and value is not sameas(false) -%}
{{- ' %s="%s"'|format(name, value is sameas(true) ? name|e : value|e)|raw -}}
{%- endif -%}
{%- endfor -%}
{% endmacro %}