1. Export environment variable $ export P4CONFIG=.p4config 2. Create workspace directory $ cd /auto/home/delacs/projects/autoselect_feature $ mkdir code 3. Create p4 config file, name of client will be 'delacs-autoselect-feature' $ vi .p4config P4CLIENT=delacs-autoselect-feature P4PORT=server.domain.com:1666 4. Create the client $ p4 client In text editor: Client: delacs-autoselect-feature Root: /auto/home/delacs/projects/autoselect_feature View: //tools/main/perf/scripts/scheduler/... //delacs-autoselect-feature/code/scheduler/... //tools/parser/... //delacs-autoselect-feature/code/parser/... 5. Now, let's pull down code from perforce $ p4 sync
12.13.2014
Perforce Client Setup
I got it from here.
11.24.2014
Get Latest Records SQL
Using this SQL: SELECT sb1.date, sb1.branch, sb1.build FROM stable_builds sb1 INNER JOIN ( SELECT max(date) date, branch FROM stable_builds GROUP BY branch ) AS sb2 ON sb1.branch = sb2.branch AND sb1.date = sb2.date ORDER BY date DESC Data: Date Branch Build 2014-11-24 5.6 460049 2014-11-19 5.6 459641 2014-11-16 5.6 459347 Output: Date Branch Build 2014-11-24 5.6 460049
10.01.2014
Rails - Separate Seeds Using Seedbank
Seedbank gives your Rails seed data a little structure. Create seeds for each environment, share seeds between environments and specify dependencies to load your seeds in order. All nicely integrated with simple rake tasks.
This is how I quickly used it:
1. Put in Gemfile: gem "seedbank" 2. Install $ bundle install 3. Create the specific seed file: $ vi db/seeds/performance_translations.seeds.rb translations = [ ["r-high-0001","1-read high-generation"], ["r-high-0008","8-read high-generation"], ["r-high-0016","16-read high-generation"] ] translations.each do |int, ext| PerformanceTranslation.find_or_create_by_internal(internal: int, external: ext) end 4. Run via rake $ rake db:seed:performance_translations
6.05.2014
Schedule rake using cron on rvm environment
Little tricky to get this going. The key is knowing rvm environment.
$ rvm env --path /auto/home3/delacs/.rvm/environments/ruby-2.0.0-p353@RailsDevFor rvm, basic command line tools like gem, rake and ruby are in the wrappers directory.
$ crontab -l SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin HOME=/auto/home3/delacs RAILS_ENV=development 0 7 * * * /bin/bash -l -c 'source ~/.bash_profile' && cd $HOME/Documents/projects/monweb_management && $HOME/.rvm/wrappers/ruby-2.0.0-p353@RailsDev/rake perfdb:get_baselines >> $HOME/logs/db.import.log 2>&1 5 7 * * * /bin/bash -l -c 'source ~/.bash_profile' && cd $HOME/Documents/projects/monweb_management && $HOME/.rvm/wrappers/ruby-2.0.0-p353@RailsDev/rake perfdb:get_published_runs >> $HOME/logs/db.import.log 2>&1
5.08.2014
Backup Dir and Files in Linux Using Tar and Bash
1. Create a bash script
$ vi backup.sh
#!/bin/bash # This is a script the creates a backup of # monitor instances: .../monitor/inst => .../monitor/backup DATE=`date +"%Y%m%d"` TIMESTAMP=`date +"%Y/%m/%d %T"` FILENAME="inst_backup_$DATE.tar.gz" SRCDIR="inst" DESDIR="backup" tar -cpzf $DESDIR/$FILENAME $SRCDIR if [ $? -eq 0 ]; then echo "$TIMESTAMP: Backup success: $FILENAME" else echo "$TIMESTAMP: Backup error: $?" fi # Any backup older than 30 days are deleted find ./$DESDIR -type f -mtime +30 -delete -printf "$TIMESTAMP: Deleted %16f\n"
for tar:
c - create
p - preserve file and dir permission
z - compress file
f - target filename
$ crontab -e 0 5 * * * cd $HOME/scheduler/monitor && ./backup.sh >> $HOME/scheduler/monitor/backup/logs/monitor.backup.log 2>&1
This would schedule a backup at 5am everyday
2.25.2014
Create Dashboard App Using Dashing Framework
This dashboard framework is fantastic -> Dashing.
Here's how to create a dashboard very easily...
$ gem install dashing $ dashing new sweet_dashboard_project $ cd sweet_dashboard_projec $ bundle install $ dashing startLet's create our own dashboard
$ dashing generate dashboard monweb exist dashboards create dashboards/monweb.erbCreate our monitor widget
$ dashing generate widget monitor exist widgets create widgets/monitor/monitor.coffee create widgets/monitor/monitor.html create widgets/monitor/monitor.scss
2.14.2014
My .vimrc
This is the .vimrc I'm using now. I got from here. Stick this on your home directory.
set nocompatible "This fixes the problem where arrow keys do not function properly on some systems. syntax on "Enables syntax highlighting for programming languages "set mouse=a "Allows you to click around the text editor with your mouse to move the cursor set showmatch "Highlights matching brackets in programming languages set autoindent "If you're indented, new lines will also be indented set cindent "Automatically indents lines after opening a bracket in programming languages set smartindent set backspace=2 "This makes the backspace key function like it does in other programs. set tabstop=8 "How much space Vim gives to a tab set number "Enables line numbering set smarttab "Improves tabbing set expandtab "Expand tabs into spaces" set shiftwidth=4 "Assists code formatting colorscheme delek "Changes the color scheme. Change this to your liking. Lookin /usr/share/vim/vim61/colors/ for options. "setlocal spell "Enables spell checking (CURRENTLY DISABLED because it's kinda annoying). Make sure to uncomment the next line if you use this. "set spellfile=~/.vimwords.add "The location of the spellcheck dictionary. Uncomment this line if you uncomment the previous line. "set foldmethod=manual "Lets you hide sections of code "--- The following commands make the navigation keys work like standard editors imap <silent> <Down> <C-o>gj imap <silent> <Up> <C-o>gk nmap <silent> <Down> gj nmap <silent> <Up> gk "--- Ends navigation commands "--- The following adds a sweet menu, press F4 to use it. source $VIMRUNTIME/menu.vim set wildmenu set cpo-=< set wcm=<C-Z> map <F4> :emenu <C-Z> "--- End sweet menu "show current filename set modeline set ls=2 " Searches in bold yellow hi Search ctermfg=Yellow ctermbg=NONE cterm=bold " make tab in v mode indent code vmap <tab> >gv vmap <s-tab> <gv " make tab in normal mode indent code nmap <tab> I<tab><esc> nmap <s-tab> ^i<bs><esc> " paste mode - this will avoid unexpected effects when you " cut or copy some text from one window and paste it in Vim. set pastetoggle=<F11> " comment/uncomment blocks of code (in vmode) vmap _c :s/^/#/gi<Enter> vmap _C :s/^#//gi<Enter> " Tidy selected lines (or entire file) with _t: nnoremap <silent> _t :%!perltidy -q<Enter> vnoremap <silent> _t :!perltidy -q<Enter> " Deparse obfuscated code nnoremap <silent> _d :.!perl -MO=Deparse 2>/dev/null<cr> vnoremap <silent> _d :!perl -MO=Deparse 2>/dev/null<cr>
1.24.2014
Brocade Switch Cheat Sheet
For further reading:
Zoning Brocade switches - Tutorial
1. Show zoning configuration
1. Show zoning configuration
> zoneshow > zoneshow *zonename*2. Show overall configuration of switch
> switchshow
1.09.2014
How to make Rails Turbolinks play nicely with jQuery
On Rails 4, AJAX in my pages are not being called because of turbolinks. The solution is to wrap the javascript code around the page load event. Got this solution from this post.
What works for me is this…
var ready = function() {
...your javascript goes here...
};
$(document).ready(ready);
$(document).on('page:load', ready);
Subscribe to:
Posts (Atom)