select rows via waterline/ sails.js

odel.find({field: 'value'}, {fields: ['id', 'name']})
    .paginate({page: 1}, {limit: 10)
    .exec(function(err, results) {
        if(err) {

#code, #orm, #sails-js, #waterline

Connect to a local database in C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Windows;

namespace WpfApplication1
 class DBClass
 private SqlConnection sqlcon;
 private SqlCommand sqlcom;
 public DBClass()
 string executable = System.Reflection.Assembly.GetExecutingAssembly().Location;
 string path = (System.IO.Path.GetDirectoryName(executable));
 AppDomain.CurrentDomain.SetData("DataDirectory", path);
 string sqlCon = @"Data Source=.\SQLEXPRESS;" +
 Integrated Security=True;
 Connect Timeout=30;
 User Instance=True";
 sqlcon = new SqlConnection(sqlCon);
 sqlcom = new SqlCommand();

 public SqlDataReader executeQuery(String query){
 SqlDataReader reader;
 this.sqlcom.CommandText = query;
 this.sqlcom.CommandType = CommandType.Text;
 this.sqlcom.Connection = this.sqlcon;


 reader = this.sqlcom.ExecuteReader();

 return reader;


 public void closeConnection() {

#code, #csharp, #database, #local-database, #sql-server

checking a checkbox in jquery

for JQuery 1.6+

$('.myCheckbox').prop('checked', true);
$('.myCheckbox').prop('checked', false);

for below 1.6

$('.myCheckbox').attr('checked', true);
$('.myCheckbox').attr('checked', false);

#checkbox, #code, #jquery

How to fix “Headers already sent” error in PHP

The following worked for me


  // code 



#code, #php, #stackoverflow

Solution of the problem Life,the Universe and Everything in two new programming language

Ok, I just solved the problem stated in by using two new programming language, Go and Lua.
Here goes the code,

package main

import "fmt"

func main() {
for value := 0; ; {
if value == 42 {


And now for Lua:

local ans
ans =
ans = tonumber(ans)
while ans ~= 42 do
ans =
ans = tonumber(ans)

Well I admit, lua is a true beauty, where Go looks like a rough one.   Be with me via twitter to know my micro thoughts.

#code, #codechef, #golang, #lua, #programming-contest

PHP Array Multisort Object: Sort multidimensional array by different columns – PHP Classes

PHP Array Multisort Object: Sort multidimensional array by different columns – PHP Classes.

#code, #php

[CODE] function to get google place recommandations

function fetch_google_venue_recommandation($place_name,$long,$lat){
 global $logger;
 $url = "" . $place_name . "&sensor=true&location=".$long.",".$lat. "&key=" . GOOGLE_APP_KEY;
 $places = null;
 $ch = curl_init($url);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_HEADER, 0);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 $data = curl_exec($ch); // Yelp response
 $response = json_decode($data);
 return $response;

#code, #curl, #google, #google-api, #php

internet explorer – Detect IE version in Javascript – Stack Overflow

I did the following:

function isIE (){var myNav = navigator.userAgent.toLowerCase();return(myNav.indexOf('msie')!=-1)? parseInt(myNav.split('msie')[1]):false;}
if(isIE()){// is IE}else{// Other browser}

internet explorer – Detect IE version in Javascript – Stack Overflow.

#cascading-style-sheets, #code, #ie, #javascript, #stack-overflow, #stackoverflow

Get unix date time of 15 days ago in php

$date = date('Y-m-d H:i:s', strtotime("-15 days"));

#code, #php

Return the last day of the month, the bad and ugly way (but great way!)

Taken from

function daysInMonth(month,year) {
var m = [31,28,31,30,31,30,31,31,30,31,30,31];
if (month != 2) return m[month - 1];
if (year%4 != 0) return m[1];
if (year%100 == 0 && year%400 != 0) return m[1];
return m[1] + 1;

#code, #date, #javascript