Skip to content

Instantly share code, notes, and snippets.

View CTimmerman's full-sized avatar

Cees Timmerman CTimmerman

View GitHub Profile
@CTimmerman
CTimmerman / Chrome_lazy_tabs.md
Last active January 30, 2017 17:51
Chrome lazy tab loading extensions test

Chrome + Session Buddy test of extensions that lazy load tabs

  1. Open two windows with two YouTube tabs per window.
  2. Pause all videos.
  3. Open extensions tab and enable none or one lazy tab extension.
  4. Save test session in Session Buddy.
  5. Focus extensions tab and close Chrome.
  6. Open Chrome.
  7. If videos don't all play at the same time, OK, else FAIL.
  8. Close all but Session Buddy tab and restore test session.
@CTimmerman
CTimmerman / webmon.conf
Last active December 30, 2015 09:52
Simple upstart script
# Save as `/etc/init/webmon.conf` and start your daemon with `sudo service webmon restart`. Output is in `/var/log/upstart/webmon.log`
description "Website monitor"
start on (net-device-up IFACE!=lo) # Start when network is up.
respawn
respawn limit 2 120 # Respawn no more than twice in 120 seconds.
# adduser --home /home/webmon webmon
setuid webmon # Don't run as root.
setgid webmon
chdir /home/webmon # Find uploads etc relatively.
exec /home/webmon/webmon.py # Don't forget the #! and `chmod +x`.
@CTimmerman
CTimmerman / mem_perc.py
Created June 4, 2015 14:11
Get and check local and remote (Tomcat) memory usage
"""Checks memory percentage of first process by user name.
2015-06-04 v1.0 by Cees.Timmerman@nospam
Run with `python -m doctest mem_perc.py`.
>>> ps_tomcat = ['ps', 'u', '-U', 'tomcat6']
>>> mem_perc(ps_tomcat) < 20
True
>>> mem_perc(['ssh', 'other.host'] + ps_tomcat) < 20
True
@CTimmerman
CTimmerman / weird_error.log
Last active August 29, 2015 14:22
Meteor Up woes on Windows7/Vagrant/Ubuntu14.04x64/nvm/node
C:\code>meteor create --example todos
C:\code>npm install -g mup
C:\code>cd todos
C:\code\todos>mup init
C:\code\todos>git init
C:\code\todos>git add -A
C:\code\todos>git reset mup.json
C:\code\todos>echo mup.json> .gitignore
C:\code\todos>git commit -m "first commit"
C:\code\todos>npm -v
@CTimmerman
CTimmerman / .htaccess
Last active August 29, 2015 14:24
Redirect permanently all domains to one (HTTPS) - Apache config
RewriteCond %{HTTP_HOST} !^www\.company\.com$ [NC] # nocase
RewriteRule (.*) https://www.company.com/$1 [NE,R=301,L] # noescape, redirect, last
@CTimmerman
CTimmerman / userDefineLang.xml
Created July 27, 2015 11:32
Add highlighting in Notepad++ (Markdown, Stylus) - Save as %AppData%\Notepad++\userDefineLang.xml
<NotepadPlus>
<UserLang name="Markdown" ext="md markdown" udlVersion="2.1">
<Settings>
<Global caseIgnored="yes" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="yes" Keywords2="yes" Keywords3="yes" Keywords4="yes" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">00# 01 02 03&lt;!-- 04--&gt;</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>
@CTimmerman
CTimmerman / build.log
Created August 5, 2015 08:21
Demeteorized Node on Azure adventures
PS C:\meteor\simple-todos\output> npm install
npm WARN package.json simple-todos@0.0.1 No repository field.
npm WARN package.json simple-todos@0.0.1 No license field.
-
> fibers@1.0.5 install C:\meteor\simple-todos\output\node_modules\fibers
> node ./build.js
child_process: customFds option is deprecated, use stdio instead.
@CTimmerman
CTimmerman / backup_remote.sh
Last active January 19, 2016 11:00
Scheduled rsync backup in Windows 10 scheduled task
# Use LF EOLs, not CRLFs, or backup folder might get CR in its name.
rsync --timeout=60 -aP --append-verify --stats user@host:/folder /cygdrive/f/backup
echo Done `date`
@CTimmerman
CTimmerman / wifi_password.bat
Last active September 22, 2015 11:37
Get current WiFi password.
@echo off
rem Run as admin. http://lifehacker.com/find-the-wi-fi-password-for-your-current-network-with-t-1717978747?utm_source=taboola
netsh wlan show profile name=networkname key=clear
pause
@CTimmerman
CTimmerman / SVG_to_PNG.js
Last active April 5, 2024 12:26
Convert SVG to PNG / save SVG as PNG
// SVG2PNG
// By Cees Timmerman, 2024-04-05.
// Paste into console and adjust indices as needed.
let im = document.getElementsByTagName('img')
let fname = location.href
if (im.length < 1) {
let svg = document.getElementsByTagName('svg')[0]
let bb = svg.getBBox()
im = new Image(bb.width, bb.height)
im.src = 'data:image/svg+xml;charset=utf-8;base64,' + btoa(document.getElementsByTagName('svg')[0].outerHTML)