Skip to content

Instantly share code, notes, and snippets.

@bq1990
bq1990 / gist:3873394
Created October 11, 2012 15:59
Asp.Net MVC return 404
public class HomeController : Controller
{
public ActionResult Index()
{
return new HttpNotFoundResult("This doesn't exist");
}
}
@bq1990
bq1990 / gist:3873614
Created October 11, 2012 16:27
Asp.Net Sql Server Attached database connection string
Data Source=.\SQLEXPRESS;AttachDbFilename=App_Data\Database1.mdf;Integrated Security=True;User Instance=True
@bq1990
bq1990 / gist:d829b4c2d87c7a728289
Created November 20, 2014 16:25
Bootstrap center column in row
.col-centered{
float: none;
margin: 0 auto;
}
@bq1990
bq1990 / gist:345a0303cef95aad5d9a
Created November 23, 2014 18:38
Bootstrap Asp.Net constants into Angular
(function (app) {
app.constant('settings', @Html.Raw(Model.SettingsJson));
})(angular.module('@Model.AngularModuleName'));

Magic words:

psql -U postgres

Most \d commands support additional param of __schema__.name__ and accept wildcards like *.*

  • \q: Quit/Exit
  • \c __database__: Connect to a database
  • \d __table__: Show table definition including triggers
@bq1990
bq1990 / gist:595c615970250e97f3ea
Created December 17, 2014 15:55
Supertest authenticate with bearer token
'use strict';
var should = require('should');
var app = require('../../app');
var request = require('supertest')(app);
describe('GET /api/incidents', function() {
it('should require authorization', function(done) {
request
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge, chrome=1" />
<title>untitled</title>
<link rel="stylesheet" href="" />
</head>
<body>
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@bq1990
bq1990 / gist:aa5f2f8cef180fd9ee56
Created December 30, 2014 21:06
print nameservers
cat domains | xargs dig NS
@bq1990
bq1990 / gist:4f24eca04fe006ccf1e5
Created January 2, 2015 06:36
Knex seed example
'use strict';
var users = require('../sample_users');
exports.seed = function(knex, Promise) {
var userPromises = [];
users.forEach(function(user){
userPromises.push(createUser(knex, user));
});
return Promise.all(userPromises);
};