Skip to content

Instantly share code, notes, and snippets.

@nanusdad
nanusdad / js-forEach-simple
Created August 19, 2013 23:02
Javascript forEach simple example
function logArrayElements(element, index, array) {
console.log("a[" + index + "] = " + element);
}
[2, 5, 9].forEach(logArrayElements);
@nanusdad
nanusdad / npm-proxy-settings
Created August 21, 2013 22:28
Using NPM behind firewall with username and password set
registry = "http://registry.npmjs.org/"
https-proxy = "http://username:secret@proxymain.dns.com:8128/"
proxy = "http://username:secret@proxymain.dns.com:8128/"
registry = "http://registry.npmjs.org/"
strict-ssl = false
// Use "npm config set" commands
@nanusdad
nanusdad / ps-remote-cmdline.md
Last active December 22, 2015 00:59
Using Powershell to run command line on remote machine

First, start powershell

      C:\Users\tester>powershell
      Windows PowerShell
      Copyright (C) 2009 Microsoft Corporation. All rights reserved.

Next, create remote sesssion

@nanusdad
nanusdad / gallery-jquery-in-4-lines
Created September 13, 2013 21:43
Gallery in 4 lines of jQuery code
@nanusdad
nanusdad / forever-node-start
Created September 16, 2013 15:03
Using "forever" to start node instance from Meteor bundle
export MONGO_URL=mongodb://localhost:27017/<dbname>
export PORT=<server_port>
export ROOT_URL=http://sub.example.com/
forever start bundle/main.js
@nanusdad
nanusdad / npm-mssql-mongo-example
Last active December 23, 2015 13:49
Using npm package mssql to query MS SQL db and generate JS code for mongo update load
var sql = require('mssql');
//npm install tedious
//npm install mssql
config = {
driver: 'tedious',
server: 'db_server',
user: 'user',
password: 'password',
port: '1433',
@nanusdad
nanusdad / chage-linux
Created September 24, 2013 22:23
Set non-expiring password in Linux ( chage command )
chage -I -1 -m 0 -M 99999 -E -1 username
@nanusdad
nanusdad / create-simple-perl-module
Last active December 24, 2015 08:59
Creating a simple Perl module
Use a module. Check out perldoc perlmod and Exporter.
In file Foo.pm
package Foo;
use strict;
use warnings;
use Exporter;
our @ISA= qw( Exporter );
@nanusdad
nanusdad / git-init-repo-from-dir
Created October 28, 2013 23:12
GitHub - initialize from existing directory
Create the remote repository, and get the URL such as
git@github.com:/youruser/somename.git or https://github.com/youruser/somename.git
If your local GIT repo is already set up, skips steps 2 and 3
Locally, at the root directory of your source, git init
Locally, add and commit what you want in your initial repo
@nanusdad
nanusdad / nodejs-tail-file
Created November 22, 2013 20:56
Tail equivalent using NodeJS
Tail = require('tail').Tail;
tail = new Tail("fileToTail");
tail.on("line", function(data) {
console.log(data);
});