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
| // define person who has siblings and children | |
| struct person { | |
| int age; | |
| struct list_head siblings; | |
| struct list_head children; | |
| } | |
| // declare a father | |
| struct person father = { | |
| .age = 32, |
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
| var os = require("os"); | |
| // winston config | |
| var winston = require('winston'); | |
| winston.clear(); | |
| config.label = os.hostname() + ":" + process.pid; | |
| winston.setLevels(config.levels); // make sure you have a stats level | |
| winston.addColors(config.colors); // you need to add a stats color | |
| winston.add(winston.transports.Console, config); |
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
| var asyncFunction = function(arg, callback) { | |
| anotherAsync(function(err, res) { | |
| if (err) return callback(err); | |
| var returnValue = res + 1; | |
| callback(null, returnValue); | |
| }); | |
| }; | |
| var callbacks = require('asunder').split; |
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
| var config = require('config'); | |
| // require braintree implementation | |
| var payments = require('payments-braintree'); | |
| // or require stripe implementation | |
| var payments = require('payments-braintree'); | |
| // init | |
| payments.config(config.payments); |
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
| s = open "| screen -r" | |
| s.each do |sess| | |
| pid = /\d+/.match(sess) | |
| if pid | |
| puts "killing #{pid}" | |
| open "| screen -X -S #{pid} kill" | |
| end | |
| end |
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
| defmodule Mongo do | |
| defrecord Collection, pid: nil, db: nil, name: nil | |
| def init do | |
| :application.start :bson | |
| :application.start :mongodb | |
| end | |
| def shutdown do | |
| :application.stop :bson |
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
| var config = require('config') | |
| var profilingEnabled = config.profile === undefined ? true : config.profile | |
| var callback = function(name, callback) { | |
| if (!profilingEnabled) return callback | |
| var start = new Date() | |
| var step = 0 | |
| return function end() { | |
| console.log(name,'profile:',((new Date()) - start),'ms',step++) | |
| callback.apply(this, arguments) |
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
| describe "Comnspace.Views.Entries.Index", -> | |
| entries = undefined | |
| view = undefined | |
| $el = undefined | |
| beforeEach -> | |
| entries = new Comnspace.Collections.Entries() | |
| entries.reset [ | |
| title: "Railscasts" | |
| url: "www.railscasts.com" |