This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| # Quickly set up a server the way I like it (dotfiles + zsh + oh-my-zsh) | |
| # | |
| # Requires git and zsh to be installed on the machine | |
| # | |
| # Usage: | |
| # curl https://raw.github.com/gist/2945733/82c7487f5a4d99508e7a6150dfa88156b8e88943/dotfiles.sh | sh | |
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Make sure we have the latest package info | |
| apt-get update | |
| # Install ruby 1.9 and some other useful related packages | |
| apt-get install -y ruby1.9.3 build-essential libssl-dev zlib1g-dev | |
| # Let "update-alternatives" know about the new ruby | |
| update-alternatives \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| NGINX_VERSION=1.3.4 | |
| TMP_PATH=/tmp | |
| # Fetch and extract nginx source | |
| cd $TMP_PATH | |
| wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz | |
| tar xvfz nginx-$NGINX_VERSION.tar.gz | |
| cd nginx-$NGINX_VERSION |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getCurrentOpStats() { | |
| intervals = [1,5,10,30] | |
| waitingForLock = 0; | |
| secsRunningStats = {}; | |
| inProg = db.currentOp()["inprog"] | |
| inProg.forEach(function (op) { | |
| if(op["waitingForLock"]) { | |
| waitingForLock += 1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Device memory data | |
| ActivityManager activityManager = (ActivityManager) androidContext.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE); | |
| // Runtime data memory numbers are in bytes (dalvik process?) | |
| int processors = runtime.availableProcessors(); | |
| long totalMemory = runtime.totalMemory(); | |
| long freeMemory = runtime.freeMemory(); | |
| System.out.println(String.format("Runtime: %d processors, %d totalMemory (bytes), %d freeMemory (bytes)", processors, totalMemory, freeMemory)); | |
| // Debug data (system wide) memory numbers are in bytes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Usage: | |
| # | |
| # timer = AverageTimer.new | |
| # my_loop do | |
| # # Track an avent | |
| # timer.event | |
| # | |
| # # Print the events per second (averaged over 5 seconds) | |
| # puts timer.events_per_second(5) | |
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Example usage | |
| AvatarCache = new RedisCache | |
| keyPrefix: "userAvatar:" | |
| expiry: 3600 | |
| generator: (key, callback) -> | |
| request "https://api.github.com/users/#{key}", (error, response, body) -> | |
| if !error and response.statusCode == 200 | |
| user = JSON.parse(body) | |
| generate user.avatar_url |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # Requirements for js framework | |
| # | |
| # - Cache Page "chrome", javascripts, css, templates in app-cache | |
| # - Optionally | |
| # - Load json data from android/ios client (eg. android Parcelable data) | |
| # - Load json data immediately from cache, if present | |
| # - Load json data from http json endpoint, store to cache | |
| # - Update view elements when associated model data changes (knockout.js?) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MongoHelpers | |
| # Sum over fields | |
| def self.sum(collection, fields, group_by, conditions=nil) | |
| map = <<-EOD | |
| function() { | |
| self = this; | |
| key = {}; | |
| if(group_by && group_by.length > 0) { | |
| group_by.forEach(function (g) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| ''' | |
| Copyright 2009, The Android Open Source Project | |
| Licensed under the Apache License, Version 2.0 (the "License"); | |
| you may not use this file except in compliance with the License. | |
| You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 |