Skip to content

Instantly share code, notes, and snippets.

@nanusdad
nanusdad / mysql_user_create_secure_auth
Last active August 29, 2015 14:09
MySQL user creation / secure_auth errors
mysql> create user 'user'@'host_fqdn_or_ip' identified by 'secret_password';
Query OK, 0 rows affected (0.07 sec)
mysql> grant select on database_name.* to 'user'@'host_fqdn_or_ip';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.03 sec)
mysql> set session old_passwords=0; set password for 'user'@'host_fqdn_or_ip' = password('secret_password');
@nanusdad
nanusdad / toggleElement
Created May 1, 2014 19:19
Javascript function to hide / show element by ID
function showStuff(id, text, btn) {
//show
document.getElementById(id).style.display = 'block';
//hide
document.getElementById(text).style.display = 'none';
//hide
btn.style.display = 'none';
}
@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);
});
@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
[email protected]:/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 / 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 / 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 / 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 / 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 / gallery-jquery-in-4-lines
Created September 13, 2013 21:43
Gallery in 4 lines of jQuery code
@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