Skip to content

Instantly share code, notes, and snippets.

View smrchy's full-sized avatar

Patrick Liess smrchy

View GitHub Profile

Keybase proof

I hereby claim:

  • I am smrchy on github.
  • I am smrchy (https://keybase.io/smrchy) on keybase.
  • I have a public key whose fingerprint is 9A2E 37AF 00EC ED7B 3CD1 02C2 3D70 4FC2 C01C CE2C

To claim this, I am signing this object:

@smrchy
smrchy / docker.sh
Created November 5, 2014 15:14
Docker
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@smrchy
smrchy / old.json
Last active December 27, 2015 11:39
stats
{
"elements": [
{
"nodes": [
{
"node": "1",
"devicetype_id": 7,
"element_id": "27106-35982",
"powersettings": [
{
@smrchy
smrchy / README.md
Last active December 25, 2015 21:09
Transform a correctly sorted SQL query with id and parentid into a tree object. Use `_queryTreeSort()` to sort you SQL query.

_makeTree

Transform a correctly sorted SQL query with id and parentid into a tree object. Use _queryTreeSort() to sort you SQL query.

Parameters:

  • q (Array): A query result (see example below)
  • id (String): The name of the id column (Default: "id")
  • parentid (String): The name of the ParentItemID column (Default: "parentid")
@smrchy
smrchy / README.md
Last active March 24, 2022 22:50
Sort a SQL query with id and parentid so that the rows have the correct order of the tree.

_queryTreeSort

Note: Please check this blog post for more details on these functions.

Sort a SQL query with id and parentid so that the rows have the correct order of the tree.

Parameters:

  • q (Array): A query result (see example below)
@smrchy
smrchy / linuxcheatsheed.txt
Created July 5, 2013 11:32
Linux Cheatsheet
# Truncate a logfile while some process is logging into the file
cat /dev/null > some_log_file.log
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@smrchy
smrchy / rediszsetworker.coffee
Created May 6, 2013 09:39
Redis ZSET Worker To create an easy to use object for statistics
# ## redisZsetWorker
# Requires Underscore.js
# http://documentcloud.github.com/underscore/
#
# Creates an easy to use object from a Redis sorted set.
#
# * Calculate to total, min and max of all scores
# * Calculate a font size (default: 1-10) to create a tag cloud
# * Calculate the percentage for each item
#
# -*- coding: utf-8 -*-
"""
amazon_sender.py
~~~~~~~~
Python helper class that can send emails using Amazon SES and boto.
The biggest feature of this class is that encodings are handled properly.
It can send both text and html emails.
This implementation is using Python's standard library (which opens up for a lot more options).
<!---
# Breadcrumbs
Return all parents of an item, typically to create a breadcrumb navigation
This function will bubble up through a tree and return an array with all parents of a nested item excluding the root.
Adjust the query and its field names to your needs
Parameters: