Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am moonhouse on github.
  • I am moonhouse (https://keybase.io/moonhouse) on keybase.
  • I have a public key whose fingerprint is 382B EC05 847B ADC8 D860 DDFE 65F9 8045 285A 7A5F

To claim this, I am signing this object:

@moonhouse
moonhouse / search_id.js
Created July 16, 2014 14:51
List objects with a certain id in MongoDB regardless of collection
var searchId = function (objId) {
coll = db.getCollectionNames();
coll.forEach(function(collName) {
obj = db[collName].findOne({'_id': ObjectId(objId)});
if (obj !== null) {
print(collName + " " + objId);
}
});
};
@moonhouse
moonhouse / bjorn-stenberg-osm.html
Last active August 29, 2015 13:58
Video och bilder från Björn Stenbergs presentation av Open Street Map
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>OpenStreetMap - Björn Stenberg</title>
<script src="http://popcornjs.org/code/dist/popcorn-complete.min.js" type="text/javascript">
</script>
<script src="popcorn.slideshare.js" type="text/javascript">
</script>
@moonhouse
moonhouse / extract_item.rb
Created March 4, 2014 16:51
Extract one item from RSS file
file_name = ARGV[0]
item_no = ARGV[1].to_i
no_of_items = 0
correct_line = false
in_item = false
File.open(file_name, "r").each_line do |line|
if line.include? '<item>'
in_item = true
no_of_items += 1
@moonhouse
moonhouse / find_large_rss_items.rb
Created March 4, 2014 16:23
Find RSS items (such as in Wordpress WXR) larger than 1 MB
files = Dir.glob('exports/*.xml')
files.each do |file|
puts file
no_of_items = 0
item_size = 0
File.open(file, "r").each_line do |line|
if line.include? '<item>'
no_of_items += 1
item_size = line.size
elsif line.include? '</item>'
@moonhouse
moonhouse / tv12.svg
Created February 20, 2014 17:43
TV12 logo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@moonhouse
moonhouse / gist:8039500
Created December 19, 2013 14:00
Set directory mtime based on mtime on file in directory.
find . -type d -print0 | while IFS= read -r -d '' dir
do
OUTPUT=$(stat -c %y $dir/readme.txt)
OUTPUT="${OUTPUT:0:16}"
echo $OUTPUT
touch -d "$OUTPUT" $dir
done
@moonhouse
moonhouse / zephyros.rb
Created August 21, 2013 12:58
Automatically move Skype and Outlook windows when connecting my MacBook to an external screen with 1200x1600 pixel resolution.
require '/Applications/Zephyros.app/Contents/Resources/libs/zephyros.rb'
def dell_screen
API.all_screens.each do |screen|
frame = screen.frame_without_dock_or_menu
if frame.w == 1200 and frame.h == 1600
return screen
end
end
return false
1.9.3p448 :015 > device_info.vendor_id
(irb):15: [BUG] Segmentation fault
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin12.4.0]
-- Control frame information -----------------------------------------------
c:0024 p:---- s:0085 b:0085 l:000084 d:000084 CFUNC :vendor_id
c:0023 p:0011 s:0082 b:0082 l:001158 d:000081 EVAL (irb):15
c:0022 p:---- s:0080 b:0080 l:000079 d:000079 FINISH
c:0021 p:---- s:0078 b:0078 l:000077 d:000077 CFUNC :eval
c:0020 p:0028 s:0071 b:0071 l:000070 d:000070 METHOD /Users/davidhall/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/irb/workspace.rb:80
@moonhouse
moonhouse / database.ddl
Created June 13, 2013 09:44
Import RSS entries to TV4 Intranet
CREATE TABLE importedentries (uri varchar, saved datetime);