Skip to content

Instantly share code, notes, and snippets.

View zhenghao1's full-sized avatar

Mark Huang zhenghao1

View GitHub Profile
'use strict';
(function() {
var mod = angular.module("App.services", []);
//register other services here...
/* pubsub - based on https://github.com/phiggins42/bloody-jquery-plugins/blob/master/pubsub.js*/
mod.factory('pubsub', function() {
var cache = {};
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@goldsmith
goldsmith / python_mavericks_guide.sh
Last active June 3, 2020 12:18
When I upgraded my Mac to OS X Mavericks, a lot of utilities (like Python, virtualenv, Xcode) broke, and it was pretty stressful trying to get it all set back up. Hopefully this guide can spare you some of that pain.Note: I'm by no means a Linux or Mac expert, so please fork and let me know if anything is redundant, incorrect, or missing!
# A guide to prevent pain and suffering while upgrading to OS X Mavericks
# This will vary greatly depending on system set up, so read the instructions carefully
# Back up Virtulenvs
####################
# Very important!
# For each virtualenv you have, run "pip freeze > requirements.txt" while in the activated virtualenv
# in order to prevent loss of dependencies during the upgrade.
import logging
import zmq
class ZmqClient (object):
def __init__(self, socket, logger):
super(ZmqClient, self).__init__()
self._logger = logger
self._socket = socket
@paulczar
paulczar / logstash-perf.md
Last active May 14, 2018 03:13
logstash performance deets

Logstash Performance Testing

Server Details

HP BL460

  • 48 Gb Memory
  • 2 x X5675 @ 3.07GHz
  • 2 x 10 gbps NIC
  • 2tb NetApp NFS volume for ES data
@samuraisam
samuraisam / zca_example.py
Created November 14, 2012 19:39
ZCA Example
from zope.interface import Interface, Attribute, implements
from zope.component import getGlobalSiteManager, adapts
# here is what our data looks like
class IKey(Interface):
pass
class IEntity(Interface):
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@nobuf
nobuf / gist:3419910
Created August 21, 2012 22:15
Supporting placeholder on IE9 with AngularJS + jQuery
angular.module('test', [])
.directive('placeholder', function($timeout){
if (!$.browser.msie || $.browser.version >= 10) {
return {};
}
return {
link: function(scope, elm, attrs){
if (attrs.type === 'password') {
return;
}

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@chalmerj
chalmerj / gist:1492154
Created December 18, 2011 02:26
Init Script for Graphite/Gunicorn
#! /bin/sh
### BEGIN INIT INFO
# Provides: gunicorn-graphite
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $nginx
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: gunicorn + nginx ubuntu init script
# Description: gunicorn + nginx ubuntu init script