Skip to content

Instantly share code, notes, and snippets.

View estahn's full-sized avatar
👨‍💻
ʕʘ̅͜ʘ̅ʔ – ʕ•̫͡•ʕ*̫͡*ʕ•͓͡•ʔ-̫͡-ʕ•̫͡•ʔ

Enrico Stahn estahn

👨‍💻
ʕʘ̅͜ʘ̅ʔ – ʕ•̫͡•ʕ*̫͡*ʕ•͓͡•ʔ-̫͡-ʕ•̫͡•ʔ
View GitHub Profile
@estahn
estahn / designer.html
Created July 26, 2014 02:07
designer
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
@estahn
estahn / open_files_per_process.sh
Last active August 29, 2015 14:21
Number of open files per process
#!/bin/sh
processes=$(lsof | cut -f1 -d" " | sort | uniq | xargs -n1 -I% sh -c 'echo % `pidof % | sed -e "s/ /,/g"`' | cut -d" " -f1 -s)
for process in $processes; do
echo $process $(pidof $process | sed -e "s/ /,/g" | xargs -I% -n1 sh -c 'lsof -a -p % | wc -l')
done
@estahn
estahn / gist:703556
Last active September 24, 2015 06:08
Doctrine - Versionable behavior configuration for use in symfony
Authority:
columns:
...
actAs:
Versionable:
className: '%CLASS%Versionable'
tableName: '%TABLE%_log'
deleteVersions: false
auditLog: true
generateFiles: true
bash-3.2# ps x | grep vmnet
919 ?? S 0:00.10 /Library/Application Support/VMware Fusion/vmnet-bridge
923 ?? Ss 0:00.02 /Library/Application Support/VMware Fusion/vmnet-dhcpd -s 13 -cf /Library/Application Support/VMware Fusion/vmnet1/dhcpd.conf -lf /var/db/vmware/vmnet-dhcpd-vmnet1.leases -pf /var/run/vmnet-dhcpd-vmnet1.pid vmnet1
925 ?? Ss 0:00.00 /Library/Application Support/VMware Fusion/vmnet-netifup -s 13 -d /var/run/vmnet-netif-vmnet1.pid vmnet1 vmnet1
927 ?? Ss 0:00.02 /Library/Application Support/VMware Fusion/vmnet-dhcpd -s 13 -cf /Library/Application Support/VMware Fusion/vmnet8/dhcpd.conf -lf /var/db/vmware/vmnet-dhcpd-vmnet8.leases -pf /var/run/vmnet-dhcpd-vmnet8.pid vmnet8
930 ?? S 0:00.06 /Library/Application Support/VMware Fusion/vmnet-natd -s 13 -m /Library/Application Support/VMware Fusion/vmnet8/nat.mac -c /Library/Application Support/VMware Fusion/vmnet8/nat.conf
932 ?? Ss 0:00.00 /Library/Application Support/VMware Fusion/vmnet-netifu
@estahn
estahn / gist:743291
Created December 16, 2010 11:10
Apple Script to start VMware Fusion lazy
set isRunning to do shell script "ps -ef | grep vmnet | grep -v grep | wc -l |sed 's/ //g'"
if isRunning is "0" then
do shell script "/Library/Application\\ Support/VMware\\ Fusion/boot.sh --start" with administrator privileges
end if
tell application "VMware Fusion" to activate
@estahn
estahn / rack_hotfix.rb
Created July 8, 2011 09:46
"warning: regexp match /.../n against to UTF-8 string" when running Cucumber
# TODO: Can be removed after updating to rack 1.3.0
module Rack
module Utils
def escape(s)
CGI.escape(s.to_s)
end
def unescape(s)
CGI.unescape(s)
end
end
@estahn
estahn / gist:5002290
Created February 21, 2013 05:13
Our current framework is heavily using a "Factory" to instantiate classes on the fly. It used ReflectionClass::newInstanceArgs() for classes with arguments. Since Reflection is quite slow it decreased our performance. The gist shows a solution that is less beautiful but more performant.
<?php
class Factory
{
// ...
/**
* Helper to instantiate objects with dynamic constructors.
*
@estahn
estahn / remove_old_chrome_versions.sh
Created October 3, 2013 11:59
Free up disk space by deleting older Google Chrome versions
#!/bin/bash
current=`find /Applications/Google\ Chrome.app/Contents/Versions -maxdepth 1 -type d -name "*.*.*.*" | sort | tail -1 | xargs -I% basename %`
echo Deleting old Chrome versions and keep $current
find /Applications/Google\ Chrome.app/Contents/Versions -maxdepth 1 -type d -name "*.*.*.*" -not -iname "$current" -exec rm -rf {} +
aws ec2 describe-instances \
--filters Name=dns-name,Values=ec2-12-345-678-90.myregion.compute.amazonaws.com \
| jq '.Reservations [] .Instances [] .InstanceId'
aws ec2 describe-instances \
--filters Name=dns-name,Values=ec2-12-345-678-90.myregion.compute.amazonaws.com \
| jq '.Reservations [] .Instances [] .InstanceId' \
| xargs -n1 aws ec2 get-console-output --instance-id \
| jq '.Output'