Skip to content

Instantly share code, notes, and snippets.

View peshi's full-sized avatar

Roland Ekström peshi

  • Peshi AB
  • Sweden
View GitHub Profile
@peshi
peshi / objectToArray.php
Last active October 26, 2022 08:10
Convert multidimensional stdClass object(s) to array.
<?php
/**
* Convert multidimensional stdClass object(s) to array
*
* @param $object
* @return array
*/
private function objectToArray($object) {
if (is_object($object)) {
#!/bin/sh
# Download and build OS X Mavericks XNU Source
if [ ! -d "dtrace-118" ]; then
curl -O http://opensource.apple.com/tarballs/dtrace/dtrace-118.tar.gz
tar zxf dtrace-118.tar.gz
rm dtrace-118.tar.gz
fi
if [ ! -d "AvailabilityVersions-6" ]; then
curl -O http://opensource.apple.com/tarballs/AvailabilityVersions/AvailabilityVersions-6.tar.gz
tar zxf AvailabilityVersions-6.tar.gz
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 February 5, 2017 12:06
Drop in replacement for react-komposer 2 - Meteor.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);

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 March 7, 2016 02:02 — forked from jult/blockpeers.sh
blocking p2p peer snoopers and evil corp (for Tixati IP filter and such)
#!/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 December 5, 2015 04:20 — forked from xrstf/letsencrypt.md
Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

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 August 29, 2015 14:18
Simplified list-group.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 August 29, 2015 14:03
Rails Bootstrap 3 Flash message helper
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'
@peshi
peshi / UUID.php
Created February 11, 2014 00:23 — forked from dahnielson/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.