Warning: simplexml_load_file(): I/O warning : failed to load external entity "../data/asset.xml" in E:\xampp\htdocs\NFPDL\live\php\getAssetMenuListJson.php on line 78
Basics:
========
To add files to be committed
git addTo commit a change in the local tree. To be done after the git add.
git commit -m "comment about the changes" To push the changes or checkin the changes to main branch
git push To discard all changes done in a branch locally git stash save --keep-index git stash drop
To create a new branch
git checkout -b myBranch
To create a patch from the local branch Before this check out a new branch, do all changes in the branch, verify it. And then commit those changes. Do not push the changes to master. git format-patch master --stdout > myPatch.patch git resetupdates the index for that path so that it matches HEAD (the current commit). It doesn't touch the working tree git rm --cached -r to remove a directory which was added. GT Diff:
========== git diff HEAD@{1} The @{1} means "the previous position of the ref I've specified", so that evaluates to what you had checked out previously - just before the pull. git diff HEAD@{1} filename This is a general thing - if you want to know about the state of a file in a given commit, you specify the commit and the file, not an ID/hash specific to the file. git diff --cached --name-only It lists the filenames in the staging area that will be committed to git. Can be used after all the files to be committed are added thru 'git add' to verify only intended files are being commited git difftool --cached the diff of files that are about to be committed against the head will be showed in vimdiff one by one. git difftool the diff of files in the two commits will be shown in vimdiff one by one. git log --pretty=oneline compact display of git log
git diff --name-only for changes relative to indexgit diff --name-only --staged for ... well staged chages :)git diff --name-only HEAD got bothgit status --porcelain|awk '{if($1=="M") {print "scp " $2 " account_name@server_ip:~/my_codebase/$(dirname " $2 ")/;"} }'|sh
if has("autocmd")
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
endif
focus() method are
#include <stdio.h>
#include <string.h>
char *ap1="char *ap1";
static char *ap2="static char *ap2";
int ii;
main()
{
int i;
char a[] ="char a[]";
char a1[] ="char a1[]";
static char a2[32] ="static char a2[10] ";
const char a3[32] ="const char a3[10] ";
char *ap ="char *ap";
static char *aptr ="static *aptr";
printf("strlen a[] %d \n",strlen(a));
printf("sizeof a[] %d \n",sizeof(a));
printf("a[sizeof] %d \n",a[strlen(a)]);
char help[20]="a b c d e ";
printf("local:\n&i %p %d \n",&i,i);
printf("a1 %p %s \n",a1,a1);
printf("a2 %p %s \n",a2,a2);
printf("a3 %p %s \n",a3,a3);
printf("*ap %p %s \n",ap,ap);
printf("*aptr %p %s \n",aptr,aptr);
printf("global:\n*ap1 %p %s \n",ap1,ap1);
printf("*ap2 %p %s \n",ap2,ap2);
printf("&ii %p %s \n",&ii,ii);
}
strlen a[] 8
sizeof a[] 9
a[sizeof] 0
local:
&i 0xbff103f8 -1074723816 < stack
a1 0xbff103e5 char a1[]
a2 0x8049940 static char a2[10]
a3 0xbff103c5 const char a3[10]
*ap 0x80486d8 char *ap
*aptr 0x80486cb static *aptr
global:
*ap1 0x80486b0 char *ap1
*ap2 0x80486ba static char *ap2
&ii 0x8049968 (null)
CC=gcc
S = file1.c file2.c
O = $(S:%.c=%.o)
exe: ${O}
$(CC) ${LIBS} -o $<
# pull in dependency info for *existing* .o files
-include $(OBJS:.o=.d)
%.o: %.c $(CC) ${INCLUDES} $(CFLAGS) -MMD -o $@ -c $<
gcc -MM $(CFLAGS) $*.c > $*.d
.PHONY clean
clean:
\rm -rf *.o exe
Note: Green highlighted stuff optional or use -MMD, are used to create dependencies
Another Example:--------------------
See
:help :compiler
:help :make
(the latter without a preceding exclamation mark) which will
automagically display the first error (if any) as soon as the make job
terminates. (Not sure if you'll get to the first _warning_ or _error_),
and a few other useful commands for use after that:
:cfir[st]
:cla[st]
:cn[ext]
:cp[revious]
:cnf[ile]
:cpf[ile]
for navigating the error list, and
:cope[n]
:ccl[ose]
to see it in its own window (the "quickfix" window), where hitting Enter
on an error moves to that line in the source. Of course, these commands
can be mapped for ease of use; for instance I have the following in my
vimrc:
:map :cnext
:map :cprev
which I use not so much for compiling but for the ":helpgrep" and
":vimgrep" commands (whose results also come in a quickfix window).
See also ":help quickfix.txt"
====================Vimdiff ==================
$cat Connect.java
import java.sql.*;
public class Connect
{
public static void main (String[] args)
{
Connection conn = null;
//String query = "Select * FROM mysql.user";
String query = "Show databases";
String dbtime;
try
{
String userName = "root";
String password = "mysql";
String url = "jdbc:mysql://10.255.6.58/test";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
}
catch (Exception e)
{
System.err.println ("Cannot connect to database server");
System.err.println ("Message :"+e.getMessage());
System.err.println ("Error message: " + e);
e.printStackTrace();
}
finally
{
if (conn != null)
{
try
{
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
dbtime = rs.getString(1);
System.out.println(dbtime);
} //end while
conn.close ();
System.out.println ("Database connection terminated");
}
catch (Exception e) { /* ignore close errors */ }
}
}
}
}
% javac Connect.java
% java -classpath .:/path/mysql-connectorJ-5.jar Connect
Database connection established
mysql
test
userdb
Database connection terminated
#!/bin/expect -f
# Parse argument Variables
set user [lrange $argv 0 0]
set ipaddress [lrange $argv 1 1]
spawn ssh -l user ipaddress
match_max 100000
# Look for passwod prompt
set timeout 2
expect "*(yes/no)?" {
send "yes\r"
}
expect "*?assword:*"
send "password\r"
interact
expect eof
#!/bin/bash
# require that all variables be set, otherwise the bash script will abort
set -o nounset
# pltTrace=2 # uncomment pltTrace to enable trace
export nodeType=""
export BaseProgName=`basename $0`
export ProgName=${BaseProgName}.$$
# if pltTrace is not already defined, define it
# this will allow individual programs to be
# debugged without turning on debugging for
# all scritps that source this file
if ! [ ${pltTrace:+1} ]
then
declare -x pltTrace=0
#change pltTrace to 1 to turn on debug for
# all scripts that haven't defined pltTrace
fi
if [ $pltTrace -ge 2 ]
then
PS4='${ProgName}:$LINENO: pltTrace-> '
set -o xtrace
fi
echo `date '+%Y%m%d.%H%M.%S'` ${BaseProgName} ": ENTER: Echoing here ..."
echo hello
if [ ! : ]; then
echo hello 2
fi
echo hello 3
ttest.16898:37: pltTrace-> date +%Y%m%d.%H%M.%S
test.16898:37: pltTrace-> echo 20101124.0558.51 test ': ENTER: creating ZFS pools and files systems ... starting'
20101124.0558.51 test : ENTER: creating ZFS pools and files systems ... starting
test.16898:40: pltTrace-> echo hello
hello
test.16898:42: pltTrace-> '[' '!' : ']'
test.16898:47: pltTrace-> echo hello 3
hello 3
delimiter //
create procedure circle_area (in r double, out a double)
begin
set a = r * r * pi();
end
//
delimiter ;
call circle_area(22, @a);
select @a;
delimiter //
create function circumference (r double) returns double
deterministic
begin
declare c double;
set c = 2 * r * pi();
return c;
end
//
delimiter ;
select circumference(22);
mysql -p -u user mysql
  or create new user from root login
mysql -u root -p
GRANT ALL ON cpp_data TO 'user1'@'localhost' IDENTIFIED BY 'password';
exit
mysql -p -u user cpp_data
create database cpp_data;
use cpp_data;
create table users(id int, fname varchar(25), sname varchar(25), active bool);
insert into users values (1, 'Fred', 'Smith', True);
insert into users values (2, 'Jane', 'Jones', True);
delimiter //
create function user_count () returns int
deterministic
begin
declare c int;
select count(*) into c from users where active = True;
return c;
end
//
delimiter ;
select user_count ();
#include < iostream >
#include < mysql.h >
using namespace std;
MYSQL *connection, mysql;
MYSQL_RES *result;
MYSQL_ROW row;
int query_state;
int main() {
return 0;
}
mysql_init(&mysql);
//mysql_real_connect(&mysql,"localhost","User","Password","databaseName",0,0,0);
connection = mysql_real_connect(&mysql,"localhost","user1","password","cpp_data",0,0,0);
if (connection == NULL) {
cout << mysql_error(&mysql) << endl;
return 1;
}
query_state = mysql_query(connection, "select user_count()");
if (query_state !=0) {
cout << mysql_error(connection) << endl;
return 1;
}
result = mysql_store_result(connection);
while ( ( row = mysql_fetch_row(result)) != NULL ) {
cout << row[0] << endl;
}
mysql_free_result(result);
mysql_close(connection);
g++ -o db db.cc -L/usr/include/mysql -lmysqlclient -I/usr/include/mysql
mkdir profile
rem --- create ls command ---
echo @echo off > profile/ls.bat
echo dir >> profile/ls.bat
rem --- create pwd command ---
echo @echo off > profile/pwd.bat
echo cd >> profile/pwd.bat
--silent with make or '@' before every command to echo off -rm foo -include Makefile_vars inc.mk @echo " Only once printed ";from,to,text)pattern,replacement,text)string) $< $@ $? $*
%.o : %.c
        $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
stdio.h>string.h>