Skip to content

Instantly share code, notes, and snippets.

View rxw1's full-sized avatar
☠️

rxw1

☠️
  • Germany
View GitHub Profile
@rxw1
rxw1 / ref.js
Created February 25, 2015 05:43
ref
// jshint esnext:true
function linkResources(data) {
_.each(data, function(resources, _key) {
let key = _key;
_.each(resources, function(resource, resourceIdx, resources) {
var refs = _.pick(resource, function(refId, refKey) {
return /_id/.test(refKey) && refId;
});
@rxw1
rxw1 / koa-pg-test.js
Last active August 29, 2015 14:15
[koa] try catch pg connect
(function() {
//jshint esnext:true
'use strict';
var koa = require('koa');
var cors = require('koa-cors');
var pg = require('koa-pg');
var app = koa();
var DATABASE = process.env.DATABASE || 'postgres://asdsf@localhost/database';
@rxw1
rxw1 / gist:072a1bc1f5960619f3a1
Created February 20, 2015 12:42
Extract name and version from package.json
egrep '\b(version|name)\b' package.json | cut -d\ -f4- | awk 1 ORS=' ' | sed 's/[",]//g; s/[ ]/-/; s/[ ]//'
@rxw1
rxw1 / .psqlrc
Created February 18, 2015 22:00
PostgreSQL configs! ^^
\set QUIET 1
\pset format wrapped
\pset null ''
\pset pager on
\set COMP_KEYWORD_CASE upper
\set extensions 'select * from pg_available_extensions;'
\set HISTSIZE 9999
\set PROMPT1 '%[%033[1;31m%]psql%[%033[0m%]:%[%033[1;33m%]%/ %[%033[1;35m%]>%[%033[0m%] '
\set PROMPT2 '%[%033[1;31m%]> %[%033[0m%] '
\set show_slow_queries 'SELECT (total_time / 1000 / 60) as total_minutes, (total_time/calls) as average_time, query FROM pg_stat_statements ORDER BY 1 DESC LIMIT 100;'
@rxw1
rxw1 / gist:8777f753c3df4a65d3cf
Created February 16, 2015 23:21
angular + ngCordova + template/stuff
(function() {
'use strict';
/* global angular */
var app = angular.module('bidos', [
'ngCordova'
]);
app.controller('appCtrl', [function() {
@rxw1
rxw1 / manifest.sh
Created February 16, 2015 22:29
Create a manifest.appcache file
#!/usr/bin/env zsh
# generate build/manifest.appcache
client=($(find client -type f))
build=($(find build -type f))
bower=($(grep -Ehor 'lib/.[a-zA-Z0-9/\._-]+' client | grep '\.'))
remote=($(grep -Ehor 'http[s]/[a-zA-Z0-9/\._-]+' client))
cached_files=($client $build $bower $remote)
@rxw1
rxw1 / mvPwdToDate.zsh
Last active August 29, 2015 14:15
Zsh function: move pwd to date
# Move current working directory to current date %H%M%S like ../005347
mvPwdToDate () {
dir=../$(zstat -F '%H%M%S' +ctime $PWD)
mkdir -p $dir && mv -iv $PWD $dir && cd .
}
@rxw1
rxw1 / mountall.sh
Created December 26, 2014 18:34
Try to mount all found partitions. Usage: mount-all DIR
#!/bin/zsh
#vi: colorscheme delek
#
# beware
# 2012,2015 (c) [email protected]
#
if [ ! $#@ -eq 1 ]
then
@rxw1
rxw1 / designer.html
Created September 17, 2014 20:57
designer
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;