Skip to content

Instantly share code, notes, and snippets.

View tjmehta's full-sized avatar
💭
🌉

Tejesh Mehta tjmehta

💭
🌉
View GitHub Profile
ERROR: apport (pid 23850) Tue Sep 1 21:07:32 2015: Unhandled exception:
Traceback (most recent call last):
File "/usr/share/apport/apport", line 54, in drop_privileges
stat = os.stat('/proc/' + pid)
FileNotFoundError: [Errno 2] No such file or directory: '/proc/43'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/share/apport/apport", line 276, in <module>
#!/usr/bin/python3
# Collect information about a crash and create a report in the directory
# specified by apport.fileutils.report_dir.
# See https://wiki.ubuntu.com/Apport for details.
#
# Copyright (c) 2006 - 2011 Canonical Ltd.
# Author: Martin Pitt <martin.pitt@ubuntu.com>
#
# This program is free software; you can redistribute it and/or modify it
@tjmehta
tjmehta / nginx.conf
Created April 18, 2012 19:51
nginx conf
server {
listen 80;
server_name localhost;
root /swelly/static;
location / {
try_files index.html =404;
}
location /api {
proxy_pass http://127.0.0.1:3000/api;
}
class Bunch(dict):
def __init__(self, *args, **kwds):
super(Bunch, self).__init__(*args, **kwds)
self.__dict__ = self
//
// in AppDelegate
//
// Initialize RestKit Shared Client
RKObjectManager *objectManager = [RKObjectManager objectManagerWithBaseURLString:_baseURL];
// Enable automatic network activity indicator management
objectManager.client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES;
// Initialize object store
@tjmehta
tjmehta / domains-emitter-example.js
Last active October 12, 2015 18:04
Unexpected domain error handling
var Domain = require('domain')
var d1 = Domain.create();
var emitter;
d1.on('error', handleCreateErr)
d1.run(function () {
emitter = createEmitter()
})
var d2 = Domain.create();
@tjmehta
tjmehta / LastArg.js
Created November 24, 2012 16:24
Last arg function
var fn = function(one, two, three, callback) {
var args = Array.prototype.slice.apply(arguments);
var lastArg = args.pop()
if (callback !== lastArg && typeof lastArg == 'function') {
callback = lastArg;
arguments[args.length] = undefined; // not -1 bc of pop above
}
// Handle undefined values, by setting default value
// .. Rest of function ..
}
@tjmehta
tjmehta / cookie.js
Created December 11, 2012 00:27
Cookie parser snippet
@tjmehta
tjmehta / publish-static.js
Created February 9, 2016 23:09
Publish all expose ports to 1-to-1 w/ docker host
#!/usr/bin/env node
# Usage: docker run [..opts] `publish-static <image>:<tag>`
'use strict'
const execSync = require('child_process').execSync
const image = process.argv[2]
const inspect = JSON.parse(
execSync('docker inspect ' + image).toString()
{
//...
// plugins
plugins: [
'karma-*',
{
'middleware:custom': ['factory', function (config) {
return function (req, res, next) {
console.log('HELLO!')
res.end('hello-world')