Skip to content

Instantly share code, notes, and snippets.

@nanusdad
nanusdad / toggleElement
Created May 1, 2014
Javascript function to hide / show element by ID
View toggleElement
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 / mysql_user_create_secure_auth
Last active Aug 29, 2015
MySQL user creation / secure_auth errors
View mysql_user_create_secure_auth
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 / excel_to_csv_to_mysql.md
Last active Nov 28, 2015
Excel to CSV to MySQL
View excel_to_csv_to_mysql.md
  1. Save Excel worksheet as .csv file
  • might need to change new line characters
  • if saving on Mac - open in vi and run %s/^M/\r/g ( ctrl+M )
  1. Use the following example to load in CSV file from mysql prompt -
    load data infile '/tmp/tc_t.csv' 
    into table new_test_categories 
    fields terminated by ','    
@nanusdad
nanusdad / mysql_to_mongo_with_meteor.md
Last active Nov 28, 2015
MySQL to mongo in Meteor
View mysql_to_mongo_with_meteor.md

Export to CSV from MySQL

SELECT * FROM books INTO OUTFILE '/tmp/books.csv'  
FIELDS TERMINATED BY ','  
ENCLOSED BY '"'  
LINES TERMINATED BY '\n'

Note fields in books table

DESC books;

@nanusdad
nanusdad / svn-repo-move-to-another-server.md
Last active Nov 30, 2015
SVN - repository move to another server
View svn-repo-move-to-another-server.md
  • Install svnserve server in newbox
  • Check working directory is fully checked-in at oldbox to subversion, and back it up.
  • Dump the subversion repository. This is done with an svnadmin command: at oldbox svnadmin dump /export/svnrepo/reponame | gzip -9 - > reponame.dump.gz
  • Create the new subversion repository ---- at newbox To create a repository ‘newrepo’ run the svnadmin create command from $SVNHOME/bin. Provide fullpath to the repository at newbox. svnadmin create /export/svnrepo/newrepo .
  • Copy the reponame.dump.gz file up to the newbox server.
  • Load the dumpfile into the new repository: at newbox zcat reponame.dump.gz | svnadmin load /export/svnrepo/newrepo
@nanusdad
nanusdad / using_future_with_meteor.js
Last active Nov 30, 2015
Using Future with Meteor
View using_future_with_meteor.js
function callToEngine(argument) {
var Future = Npm.require('fibers/future');
var fut = new Future();
///do stuff
engine.on('close', function(code)
{
@nanusdad
nanusdad / git_fetch_into_meteor.md
Last active Nov 30, 2015
Git fetch into Meteor
View git_fetch_into_meteor.md

Using Git to manage Meteor app code

meteor create app
cd app
git init
git remote add origin PATH/TO/REPO
git fetch
git checkout -t origin/master
@nanusdad
nanusdad / node-express-https-svc.js
Last active Nov 30, 2015
Starting https service with Node / Express module
View node-express-https-svc.js
var fs = require('fs');
var express = require('express');
var securityOptions = {
key: fs.readFileSync('/certs/domain.com.key'),
cert: fs.readFileSync('/certs/domain.com.chained.crt'),
requestCert: true
};
// .......................................................
@nanusdad
nanusdad / svn-in-place-import
Created Jul 23, 2013
SVN : In-place import commands
View svn-in-place-import
# svn mkdir file:///root/svn-repository/etc \
-m "Make a directory in the repository to correspond to /etc"
# cd /etc
# svn checkout file:///root/svn-repository/etc ./
# svn add apache samba alsa X11
# svn commit -m "Initial version of my config files"
@nanusdad
nanusdad / meteor-authenticate-call
Last active Dec 20, 2015
Meteor : authenticate call back example
View meteor-authenticate-call
// This goes in the client sub directory or use Meteor.isClient check
// http://docs.meteor.com/#meteor_isclient
Meteor.call('authenticate', user, pswd, function(err, res) {
if(err) {
console.log('error trying login');
}
else {
console.log(res);
Session.set('logged_in_user', user);