Skip to content

Instantly share code, notes, and snippets.

View imalberto's full-sized avatar

alberto chan imalberto

  • Yahoo!
  • San Francisco
View GitHub Profile
@imalberto
imalberto / test-kitchen.log
Created November 4, 2016 17:24
"kitchen converge" error when Berksfile components are not installed (missing)
Resolving cookbook dependencies with Berkshelf 5.1.0...
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>> Failed to complete #converge action: [Berkshelf::LockfileNotFound] on default-ylinux6
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
@imalberto
imalberto / conn.go
Created August 8, 2016 21:07
List of func on Conn struct for go-zookeeper
func (c *Conn) Close() {
func (c *Conn) State() State {
func (c *Conn) SessionID() int64 {
func (c *Conn) SetLogger(l Logger) {
func (c *Conn) setTimeouts(sessionTimeoutMs int32) {
func (c *Conn) setState(state State) {
func (c *Conn) connect() error {
func (c *Conn) loop() {
func (c *Conn) flushUnsentRequests(err error) {
func (c *Conn) flushRequests(err error) {

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@imalberto
imalberto / .jslintrc
Created June 25, 2014 20:24
jslint default configuration
{
"globals": {
"exports": true,
"YUI": true,
"YUI_config": true,
"YAHOO": true,
"YAHOO_config": true,
"Y": true,
"global": true,
"process": true,
@imalberto
imalberto / response.json
Created June 12, 2014 17:13
207 response payload format / JSON
{
"response": {
},
"data": {
}
}
@imalberto
imalberto / MainViewController.swift
Last active August 29, 2015 14:02
Swift Template
class MainViewController: UITableViewController, UITableViewControllerDelegate, UITableViewControllerDataSource {
// If using xib
override func awakeFromNib() {
super.awakeFromNib()
}
// If not using xib
func init(name: String) {
}
@imalberto
imalberto / ASObject.m
Created March 1, 2014 06:39
Example of ASObject
// ASObject
// ASQuery
ASQuery *query = [ASQuery queryWithClassName:@"AppInfo"];
[query getObjectInBackgroundWithId:@"XX" block:^(ASObject *appInfo, NSError *error) {
NSLog(@"error");
NSInteger dv = [[appInfo objectForKey:@"dv"] intValue];
NSString *message = [[appInfo objectForKey:@"message"] intValue];
@imalberto
imalberto / app.js
Last active August 29, 2015 13:56
sample app.js
'use strict';
var debug = require('debug')('app'),
express = require('express'),
libmojito = require('../../../'),
app,
mojito;
app = express();
app.set('port', process.env.PORT || 8666);
@imalberto
imalberto / routes.yml
Created January 29, 2014 21:58
routes.yaml example
-
settings:
- master
home:
path: /home
verbs:
- get
call: home.index
@imalberto
imalberto / photo-view.js
Last active September 15, 2016 09:06
YAF and React.js Discussion context is getting YAF to use React.js effectively.
// YAF view
var PhotoView = Y.Base.create('photoView', Y.View, [], {
photoTemplate: Template.get('photonews/photo'),
render: function () {
var container = this.get('container'),
locals = this.get('locals'),
html;
html = this.photoTemplate({