Skip to content

Instantly share code, notes, and snippets.

View CTimmerman's full-sized avatar

Cees Timmerman CTimmerman

View GitHub Profile
@CTimmerman
CTimmerman / type_clipboard.ahk
Created November 10, 2015 11:15
Type clipboard text using http://www.autohotkey.com/
; win + v
#v::
SendRaw %clipboard%
@CTimmerman
CTimmerman / find_task.sh
Last active December 22, 2015 09:58
Find task in Linux, excluding apt
grep -Hirn $@ /etc/cron* |grep -v apt
@CTimmerman
CTimmerman / changed
Created January 4, 2016 10:31
Find recent file changes with Bash. Optional arguments: [path] [max age in minutes]
#!/bin/bash
sudo find ${1} -cmin -${2-1} 2>&1 |grep -v /proc/
@CTimmerman
CTimmerman / macro_function.vba
Last active February 8, 2016 13:24
Excel 2010 sucks almost as bad as Libre/Open Office Calc 5, so here are some notes:
Function example(ByVal r As Range, r2) As String
' Functioning practical Excel example by Cees.Timmerman@company.
' 2016-01-19 v1.0
' Sample usage: Press Alt+F11, Tools, Macros..., "example", Create, and replace template code.
' Make A1 "1;2;3" and B2 "=example(A1;A2)" or "=example(A1,A2)" if second parameter doesn't turn green.
' B2 should now have value "03". Press Ctrl+Alt+F9 to update all function cells after editing the function.
On Error GoTo ErrorHandler
Debug.Print "When debugging, this appears in the Immediate Window. It is now " & Now()
Debug.Print "r is " & r.NumberFormat _
& " " & TypeName(r) _
@CTimmerman
CTimmerman / auto_away_steam.py
Last active February 8, 2016 11:54
Steam auto-away while idle
""" Steam auto-away while idle. 2016-02-07 v1.0 by Cees Timmerman """
import ctypes, subprocess, time
class LASTINPUTINFO(ctypes.Structure): # https://msdn.microsoft.com/en-us/library/windows/desktop/ms646272%28v=vs.85%29.aspx
_fields_ = [('cbSize', ctypes.c_uint),
('dwTime', ctypes.c_ulong)] # DWORD
lii = LASTINPUTINFO()
lii.cbSize = ctypes.sizeof(lii)
@CTimmerman
CTimmerman / NppUDL_CoffeeScript.xml
Last active March 8, 2016 16:22
Notepad++ highlighting for CoffeeScript. Line comments still override block comments, though, even after changing the Keywords name=Comments value.
<NotepadPlus>
<UserLang name="CoffeeScript" ext="coffee" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="yes" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">03### 04### 00# 01 02</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>
@CTimmerman
CTimmerman / nice_loop.coffee
Last active February 25, 2016 14:58
Loop large arrays in JS without hogging the CPU
# synchronous
a = 'abc'; for i in [0...a.length] then console.log i, a[i]
# asynchronous
a = 'abc'; i = 0; x = setInterval ->
if i < a.length then console.log i, a[i]; ++i else clearInterval x
, 1000
@CTimmerman
CTimmerman / gist:e0ddc9780349863da78d
Created February 25, 2016 16:38
Clone remote MongoDB to localhost
"C:\Program Files\MongoDB\Server\3.0\bin\mongodump.exe" /h cluster.mongolab.com:port /d dbname /u user /p pass
2016-02-25T17:15:09.639+0100 writing dbname.system.indexes to dump\dbname\system.indexes.bson
2016-02-25T17:15:09.642+0100 writing dbname.objectlabs-system to dump\dbname\objectlabs-system.bson
2016-02-25T17:15:09.645+0100 writing dbname.houston_admins to dump\dbname\houston_admins.bson
2016-02-25T17:15:09.646+0100 writing dbname.assets to dump\dbname\assets.bson
2016-02-25T17:15:09.756+0100 writing dbname.users to dump\dbname\users.bson
2016-02-25T17:15:09.761+0100 writing dbname.objectlabs-system metadata to dump\dbname\objectlabs-system.metadata.json
2016-02-25T17:15:09.918+0100 writing dbname.users metadata to dump\dbname\users.metadata.json
2016-02-25T17:15:09.920+0100 writing dbname.houston_admins metadata to dump\dbname\houston_admins.metadata.json
2016-02-25T17:15:09.959+0100 done dumping dbname.objectlabs-system (1 document)
@CTimmerman
CTimmerman / change_columns_with_constraints.sql
Last active March 7, 2016 09:34
Change columns with constraints in MySQL.
show create table orders_products;
ALTER TABLE orders_products DROP FOREIGN KEY orders_products_ibfk_1;
alter table orders_products modify column orderId bigint;
alter table orders modify column id bigint AUTO_INCREMENT;
ALTER TABLE orders_products ADD CONSTRAINT `orders_products_ibfk_1` FOREIGN KEY (`orderId`) REFERENCES `orders` (`id`);
@CTimmerman
CTimmerman / use_fixed_ip.bat
Created March 8, 2016 15:53
The alternate ethernet configuration in Windows 10 didn't seem to work for me, so i had to manually use DHCP. To quickly restore fixed IP settings (with Google DNS), use this batch file.
netsh interface ipv4 set address "Local Area Connection" static 10.0.0.2 255.0.0.0 10.0.0.1
netsh interface ipv4 add dnsserver "Local Area Connection" address=8.8.8.8 index=1
netsh interface ipv4 add dnsserver "Local Area Connection" address=8.8.4.4 index=2
pause