Skip to content

Instantly share code, notes, and snippets.

View dnsang's full-sized avatar
💭
I may be slow to respond.

SangDang dnsang

💭
I may be slow to respond.
  • DataInsider
  • Moksha
View GitHub Profile
@dnsang
dnsang / git_build.sh
Created June 8, 2016 10:59
To pull & build sbt or mvn from list of projects on order
#!/bin/bash
# written by sangdn 6/6/2016
# to reduce stupid-time when up-to-date dependency projects
# config:
# set sbt_exclude/mvn_exclude to exclude build mode
# set mvn = PATH[param], PaTH[param]
# set mvn_options = option to build with maven command
# eg:
# sbt_exclude=clean
# sbt=PATH[clean,compile,publishLocal]
#search text in file in directory
grep -Ril "text-to-find-here" /
find . -name "*.txt" | xargs grep -i "text_pattern"
find . -name '*.py' -exec grep -n "text_pattern" {} \; -print
#understand xargs: find . -name "*.py" | xargs -n 1 echo
#sed
sed -i 's/test/test/g' file1.a
#awk:
http://code.linuxnix.com/2013/04/awk-scripting-learn-awk-built-in-variables-with-examples.html
awk -F’,’ ‘{print $4}’ db.txt
@dnsang
dnsang / VIM
Created November 26, 2015 03:52
#save in ReadOnly mode
:w !sudo sh -c "cat > %"
create getswap.sh
#!/bin/bash
# Get current swap usage for all running processes
# Erik Ljungstrom 27/05/2011
SUM=0
OVERALL=0
for DIR in `find /proc/ -maxdepth 1 -type d | egrep "^/proc/[0-9]"` ; do
PID=`echo $DIR | cut -d / -f 3`
PROGNAME=`ps -p $PID -o comm --no-headers`
cat /sys/block/sdb/queue/rotational
0: SSD, 1: HDD
@dnsang
dnsang / google-search-operator
Last active February 27, 2023 22:06
Google Useful Command
# some common and useful google search tips
# for ref: http://www.google.com/advanced_search
###### tips #####
define hello >> to looking for definition of hello
###### Content Search & Operator ########
"hello world" >> to search for exact match of hello world
hello + world >> to search for hello and word eg: hello to my world
hello -world >> to search for hello, exclude word eg: hello to my house
hello * world >> to search fuzzy for hello *** world
~hello >> to search similar for hello eg: hi, hey
@dnsang
dnsang / gist:5f2e0196ce1a8ef0aa83
Created June 22, 2015 04:03
Sort file by date
find . -printf "%T@ %Tc %p\n" | sort -n
printf arguments from man find:
%Tk: File's last modification time in the format specified by k.
@: seconds since Jan. 1, 1970, 00:00 GMT, with fractional part.
c: locale's date and time (Sat Nov 04 12:02:33 EST 1989).
%p: File's name.
@dnsang
dnsang / gist:40ef86cf4abeec41cd32
Created June 9, 2015 03:02
ElasticSearch - Useful Rest Command
#node info
http://10.30.58.160:9210/_nodes/process?pretty
#disable for bulk indexing
curl -XPUT 'localhost:9210/_settings' -d '
{
"index" : {
"refresh_interval" : "60s"
}
@dnsang
dnsang / so_30691082
Last active August 29, 2015 14:22
Exactly Match with Not_Analyzed & Term filter
#this gist is used to answer for question from http://stackoverflow.com/questions/30691082/elasticsearch-either-or-match-query
#any question could request to zkidkid@gmail.com
# delete exist index
curl -XDELETE 'http://localhost:9200/furnit/'
#create new index
curl -XPUT 'http://localhost:9200/furnit/'
# create a new type which specify mappings
#!/bin/bash
#########################################################################################
# Bash script for Subversion integration with Slack #
# #
# 1. Save this file in /usr/bin as incomming_webhook_slack #
# 2. Make it executable: #
# chmod +x /usr/bin/incomming_webhook_slack #
# 3. Put this line at the end of file of your_svn_repo/hooks/post-commit: #
# incomming_webhook_slack $REPOS $REV svn_path #
# 4. Edit this file, config all variable to point to your webhook #