Skip to content

Instantly share code, notes, and snippets.

View schatekar's full-sized avatar

Suhas Chatekar schatekar

View GitHub Profile
@schatekar
schatekar / todo-1.js
Created March 18, 2012 20:45
Example source for "writing better javascript, part - 1"
$(document).ready(function () {
// Returns formatted HTML for a todo item
function getToDoHtml(todo) {
return '<li><span class="todo">' + todo + '</span><a class="edit">Edit</a><a class="remove">Remove</a></li>';
}
// When Add button is clicked, appends the todo item from the textbox to the list of todo items
$('input[type="submit"].add-todo').click(function () {
var todo = $('input[type="text"].add-todo').val();
@schatekar
schatekar / bad-code-from-part-1.js
Created April 1, 2012 17:44
Wxample source for writing better javascript, part 2
function getToDoHtml(todo) {
return '<li><span class="todo">' + todo + '</span><a class="edit">Edit</a><a class="remove">Remove</a></li>';
}
$('input[type="submit"].add-todo').click(function () {
var todo = $('input[type="text"].add-todo').val();
if (todo) {
$('.todo-list').append(getToDoHtml(todo));
namespace Domain
{
public class Person
{
public string FirstName {get; set;}
public string LastName {get; set;}
public DateTime BirthDate {get; set;}
}
}
namespace Persistence
{
public class PersonDto
{
public string FirstName {get; set;}
public string LastName {get; set;}
public DateTime BirthDate {get; set;}
}
}
var conversion = require("phantom-html-to-pdf")();
var fs = require('fs');
console.time("phantom");
var writeStream = fs.createWriteStream('linkedin_phantom.pdf');
conversion({ url: "https://www.linkedin.com/in/chatekar" }, function(err, pdf) {
console.log(pdf.numberOfPages);
pdf.stream.pipe(writeStream);
@schatekar
schatekar / library-embedded-data.json
Last active December 16, 2015 11:07
Multi-model databases
//collection- borrowers
{
"_id": "some id",
"name": "Suhas Chatekar",
"borrowed_books": [
{
"_id": "book 1",
"name": "Build Single Page Applications with SQL",
"author": {
//collection- borrowers
{
"_id": "some id",
"name": "Suhas Chatekar",
"borrowed_books": [
{
"bookid": "book 1"
},
{
{
"locale": "string",
"displayTexts": {
"concourse": "On {concourse}",
"airside": "string",
"landside": "string",
"beforeSecurity": "string",
"afterSecurity": "string",
"beforeImmigration": "string",
"afterImmigration": "string",
function modify(req, res, next){
if(res.status == 400){
res.body = "";
}
next();
}
{
"href": "https://myapi.com/v1/member/34234",
"id": 34234,
"firstname": "Suhas",
"lastname": "Chatekar",
"email": "abc@gmail.com",
"memberships": [{
"href": "https://myapi.com/v1/meetup/2345",
"meetup_id": 2345,
"name": "London Erlang Group"