Git Cheatsheet

Leave a comment

Create new branch and push to remote
$ git branch [branch name] -> create local branch
$ git push origin [branch name] -> push local branch to remote

pulling code from a remote branch and create a new local branch
$ git checkout -b [local branch name] [remote branch name]

delete remote branch
$ git push origin :[branch name]

list branch in remote repo
$ git branch -r

Switch to a master branch
$ git checkout master

merging code from other branch to master (–no-ff is to always create commit object to avoid losing
info about historical existence of another branch and groups together all commits
$ git merge –no-ff [other branch name]

delete local branch
$ git branch -d [branch name]

tag a commit for future reference (can be used for the purpose of versioning)
$ git tag -a [tag name] -m “[some description]“

To see how many commits created since the last tag or given tag
$ git describe –tags

push all tags to remote
$ git push –tags

push one tag to remote
$ git push origin [tag name]

list existing tags
$ git tag -l

checkout a tagged revision and create a branch
$ git checkout -b [branch name] tags/[tag name]

 

Filter, grep and split file in Linux

Leave a comment

Filter only file MM* that contain 20111201

egrep -h “\|20111201\|” MM* > file_1

Split file, each file will contain 500000

split -l 50000 file_1 MM_20111201_000000000

Skip any line that start with FH

egrep -v “^FH\|” MM_20111203_000000000_XX.aa > abc

About Killing Session at Oracle

Leave a comment

Get The session ID by this query:

 

select * from v$session
where program like 'sqlplus@s61cj185%'</pre>
set feedback off
 set serveroutput on size 9999
 column username format a20
 column sql_text format a55 word_wrapped
 begin
 for x in
 (select username||'('||sid||','||serial#||') ospid = '|| process ||
 ' program = ' || program username,
 to_char(LOGON_TIME,' Day HH24:MI') logon_time,
 to_char(sysdate,' Day HH24:MI') current_time,
 sql_address,
 sql_hash_value
 from v$session
 where status = 'ACTIVE'
 and rawtohex(sql_address) <> '00'
 and username is not null ) loop
 for y in (select sql_text
 from v$sqlarea
 where address = x.sql_address ) loop
 if ( y.sql_text not like '%listener.get_cmd%' and
 y.sql_text not like '%RAWTOHEX(SQL_ADDRESS)%' ) then
 dbms_output.put_line( '--------------------' );
 dbms_output.put_line( x.username );
 dbms_output.put_line( x.logon_time || ' ' || x.current_time || ' SQL#=' || x.sql_hash_value);
 dbms_output.put_line( substr( y.sql_text, 1, 250 ) );
 end if;
 end loop;
 end loop;
 end;
 /

And kill using this query:

ALTER SYSTEM DISCONNECT SESSION ’7,36875′ IMMEDIATE;

or
ALTER SYSTEM KILL SESSION ‘sid,serial#’ IMMEDIATE

Unlock user account for Oracle

Leave a comment

Steps to unlock User

sqlplus /nolog;
conn / as sysdba;
alter user <usernme> account unlock;

IPhone bookmark

Leave a comment

1. Objective C

2.Iphone Dev

3. http://cocoadevcentral.com/d/learn_objectivec/

4. http://mobile.tutsplus.com/tutorials/iphone/learn-objective-c-day-1/

Sample Sql Create tablespace in Oracle

Leave a comment

create tablespace MM_USAGE
datafile ‘/u04/oradata/PROD/mm_usage01.dbf’ size 2G autoextend off,
‘/u04/oradata/PROD/mm_usage02.dbf’ size 2G autoextend off,
‘/u04/oradata/PROD/mm_usage03.dbf’ size 2G autoextend off,
‘/u04/oradata/PROD/mm_usage04.dbf’ size 2G autoextend off,
‘/u04/oradata/PROD/mm_usage05.dbf’ size 2G autoextend off,
‘/u04/oradata/PROD/mm_usage06.dbf’ size 2G autoextend off,
‘/u04/oradata/PROD/mm_usage07.dbf’ size 2G autoextend off,
‘/u04/oradata/PROD/mm_usage08.dbf’ size 2G autoextend off
logging
extent management local;

create tablespace MM_USAGE_INDX
datafile ‘/u05/oradata/PROD/mm_usage_indx01.dbf’ size 2G autoextend off,
‘/u05/oradata/PROD/mm_usage_indx02.dbf’ size 2G autoextend off,
‘/u05/oradata/PROD/mm_usage_indx03.dbf’ size 2G autoextend off,
‘/u05/oradata/PROD/mm_usage_indx04.dbf’ size 2G autoextend off,
‘/u05/oradata/PROD/mm_usage_indx05.dbf’ size 2G autoextend off
logging
extent management local;

In Sequence:

select * from dba_tablespaces;
select * from dba_tables where table_name = ‘USAGE_XXXX’ and owner = ‘XXXX’;

select * from dba_data_files where tablespace_name = ‘XX_USAGE’;

alter tablespace MM_USAGE
add datafile ‘/u04/oradata/METERPROD/mm_usage10.dbf’ size 2G autoextend off;

 

 

Query tablespace

select * from dba_tablespaces

Move a table from users table space to other

alter table <tablename> move tablespace MM_MIG_USERS

Rebuild index in new table space

alter index <iname> rebuild tablespace <tablespace name>

From Venu

Leave a comment

CREATE OR REPLACE PROCEDURE “METER”.”COPY_ERROR_CODE_DESCRIPTION” AS

v_id varchar2(32);
v_error_code varchar(32);
v_error_desc varchar2(255);

cursor c_error is
select id from ERROR_CODE_MAPPINGS;

begin
open c_error;
loop
fetch c_error into v_id;
exit when c_error%notfound;

select error_code, error_description into v_error_code, v_error_desc from ERROR_CODE_MAPPINGS_BACKUP where id = v_id;

dbms_output.put_line(v_id ||’ :: ‘ ||v_error_code ||’ :: ‘ ||v_error_desc);
update ERROR_CODE_MAPPINGS set error_description = v_error_desc where id = v_id;

end loop;
close c_error;

end;

Note of DBA task

Leave a comment

Find out user quota in a table space

SELECT * FROM dba_ts_quotas
WHERE USERNAME='nama_user'
AND TABLESPACE_NAME='nama_tablespace';

Find out table space

SELECT b.tablespace_name, tbs_size SizeMb, a.free_space FreeMb
FROM  (SELECT tablespace_name, ROUND(SUM(bytes)/1024/1024 ,2) AS free_space
       FROM dba_free_space
       GROUP BY tablespace_name) a,
      (SELECT tablespace_name, SUM(bytes)/1024/1024 AS tbs_size
       FROM dba_data_files
       GROUP BY tablespace_name) b
WHERE a.tablespace_name(+)=b.tablespace_name;

Identify User  Session

Identify Session User
SELECT s.inst_id,
       s.sid,
       s.serial#,
       p.spid,
       s.username,
       s.program
FROM   gv$session s
       JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id
WHERE  s.type != 'BACKGROUND'
ORDER BY s.username;
 

Count Session and group by machine

select count(*), machine from v$session group by machine order by 1

Moving table space of a table.

–alter table USAGE_HISTORY move tablespace MM_USAGE
–alter index <iname> rebuild tablespace <tablespace name>
–alter index <index name> tablespace MM_USAGE_INDX

–alter index SYS_C0015263 rebuild tablespace MM_USAGE_INDX

HBase Commands

Leave a comment

1. To list tables
> list

2. to create table
>create ‘<Table name>’, {NAME => ‘colfam1′, COMPRESSION => ‘gz’, IN_MEMORY => ‘true’, VERSIONS => ’1′ }

3. drop table
> disable ‘<Table name>’
> drop ‘<Table name>’

3. count no. of rows in table
> count ‘<Table name>’

4. Query based on the key
>get ‘CustomerProfile’, ‘CP00341425667′

5.Delete single

>delete ‘CustomerProfile’, ‘CP00351625215′, ‘colfam1′,1325231955371

Business Rule Bagian 2

1 Comment

Dalam business rule, bagian yang paling penting adalah rule file yang akan diload dan di invoked

Anatomi Rule file bisa digambarkan sebagai berikut:

  • Package
  • Rule name
  • Condition
  • Consequence

Istilah package dalam rule adalah sebagai name space dan sama dengan package didalam java, yakni rule-rule dalam package yang sama harus unique (Di java class name di package yang sama harus unique).

Setelah Package di define, selanjutnya dalam file tersebut kita define rule name.  Setiap rule punya nama yang unique saat dalam package yang sama.

Condition adalah validasi atau pengecekan, dan jika dalam condition itu terpenuhi saratnya maka Consequence akan di eksekusi. Misalnya kondisi suhu tubuh lebih besar 40 Celcius dan badan meriang dan timbul-timbul bercak merah dan bau mulut. Jika semua kondisi terpenuhi maka bawa pasien ke rumah sakit  dan dikasih obat sakit deman berdarah.

Dalam drl file akan seperti ini

package mujoko.rule;
import com.service.tindakanDemamBerdarahService;

rule "demam berdarah"
when
  $pasien : Pasien()
  Pasien ( suhu < 100, meriang==true , bercak==true, baumulut ==true ) // condition
then
   tindakanDemamBerdarahService($pasien); // consequence
end;

berlanjut.

Older Entries

Follow

Get every new post delivered to your Inbox.