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
| snippet req "Require a module where it converts CamelCase to underscore (camel_case)" !b | |
| var ${1:name} = require(${2:'${3:${1/(^[A-Z])|([A-Z])/(?2:_\l$2:\l$1)/g}}'}); | |
| endsnippet |
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
| siege -b -c 100 http://localhost:4444/cache-this |
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: json_path(json, text) | |
| -- DROP FUNCTION json_path(json, text); | |
| CREATE OR REPLACE FUNCTION json_path(data json, path text) | |
| RETURNS text AS | |
| $BODY$ | |
| /* JSONPath 0.8.0 - XPath for JSON | |
| * | |
| * Copyright (c) 2007 Stefan Goessner (goessner.net) |
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 configuration = { | |
| domain: 'localhost', | |
| port: 3000, | |
| keys: require('./keys.js') | |
| } | |
| var express = require('express'); | |
| var app = express(); | |
| app.listen(configuration.port); | |
| var passport = require('passport'); |
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 mysql = some_function_to_create_a_mysql_connection(); | |
| app.get('/foo', function (req, res) { | |
| mysql.query('SELECT * FROM example', function (err, results) { | |
| if(err) { | |
| res.send(400); | |
| } | |
| res.send(results, 200); | |
| } |
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
| description "Node server for #{application} (#{node_env})" | |
| start on (net-device-up | |
| and local-filesystems | |
| and runlevel [2345]) | |
| stop on runlevel [016] | |
| script | |
| exec sudo -u nobody sh -c "NODE_ENV=#{node_env} #{path_to_node} #{script_name}" | |
| end script |
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 MyClass | |
| constructor: (options) -> | |
| # stuff here | |
| myObject = new MyClass(bar: "foo", foo: "bar") |
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
| <?php | |
| $query = "select * from example_table where user_id = ?" | |
| $values = array($_SESSION['user_id']); | |
| $results = select($query,$values); | |
| ?> |
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
| <?php | |
| require_once 'PHPUnit/Framework.php'; | |
| class Describe_Something_Awesome extends PHPUnit_Framework_TestCase | |
| { | |
| public function setUp() | |
| { | |
| $this->something = "Awesome!"; | |
| } | |
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 "Facebook Connect Authentication" do | |
| it "should create a new user in the system when the Facebook Connect cookies are set" do | |
| response = request(url(:home), :cookie=>facebook_cookies) | |
| user = User.first(:facebook_id=>facebook_params[:user]) | |
| user.should_not be_nil | |
| user.should be_valid | |
| end | |
| end |