Skip to content

Instantly share code, notes, and snippets.

@j0shua
Created April 8, 2011 15:10
Show Gist options
  • Save j0shua/910067 to your computer and use it in GitHub Desktop.
Save j0shua/910067 to your computer and use it in GitHub Desktop.
notes
create a module to reverse a html form into drupal form definition
to see a certain file as it was in a certain commit
git show commit:path/to/file >something
MAC clipboard is called pbcopy :
echo "blah" | pbcopy
to create an empty (bare) repo:
go to the "remote"/central machine
1. make a dir there
2. init the repo
mkdir /var/git/recipecleanup
cd /var/git/recipecleanup
git --bare init
get rid of the last LOCAL commit:
git reset --hard HEAD~1
will remove the topmost.POOF. just as if it would have never existed
yank a range in vim:
09:32] -ChanServ- [#vim] vim discussion .. www.vim.org, vim.sf.net, :help
[09:33] <j0shua> is there a way to yank a range into a named buffer. basically
i want to combine : :32,50y and "k20y
[09:34] <j0shua> like 30,5"0ky
[09:34] <j0shua> * 30,50"ky
[09:35] == sharat87 [~chatzilla@122.166.11.129] has quit [Quit: ChatZilla
0.9.86-rdmsoft [XULRunner 1.9.2.3/20100414003610]]
[09:35] <mgedmin> :h :y
[09:35] <mgedmin> and you'll notice that you can specify the register name
[09:35] <graywh> :[range]y [register]
[09:35] <mgedmin> so :32,50y k
[09:35] <bairui> j0shua: I'm a bit confused by your request, but you can
append to a register by using the capital case form
[09:36] <graywh> i'm a bit confused by bairui's suggestion, but you can repeat
the last cmdline command with @:
[09:37] <bairui> graywh: :-)
[09:37] <graywh> fyi, 20"ky will yank 20 lines into register k (if you want to
do it that way)
[09:37] <j0shua> bairui: ok so how would that go? if i want to append lines
20,50 into register "k" I do : "K20,50y ?
[09:38] <graywh> you haven't been paying attention
[09:38] <graywh> :20,50y K or 20G"Ky50G
[09:39] <j0shua> ok thanks sorry I hadn't seen the comment above
[09:39] <bairui> j0shua: as graywh just said. Sorry. got busy with a RL
request :)
[09:39] == letto [~letto@188.26.200.58] has joined #vim
[09:39] <j0shua> no prob thank you both !
[09:39] <bairui> np
!! important !!
git reset RESETS the pointer to a given commit
git checkout checks-out the files from a given commit
truncate a bunch of tables:
mysql -uroot -e "use information_schema; select TABLE_NAME from TABLES where TABLE_SCHEMA='databasename' AND TABLE_NAME like 'cache_%';" > temp.txt
for i in `count=`wc --lines temp.txt | cut -d' ' -f1`; count=`expr $count - 1`; tail -$count temp.txt` ; do mysql -uroot blah -e $i; done
to set git push to only push the current branch:
git config --global push.default tracking
to restict output of git log to one dir:
git log -- PATH
to add in files changed:
git log --name-only
OR
git log --stat
can be combined ala: git log --name-only -- PATH
to see a file as it was at a given commit:
git show HASH:/PATH/TO/FILE/IN/REPO
example:
git show 804b32c29173e0be4ae170b3dca6adbbff55a336:/import/filename.php
find count recipes in pubserv files
var=0; for i in `grep -R --count '<recipe:title>' * | cut -d':' -f2` ; do var=`expr $var + $i`; done; echo "var = $var";
to reset fileformat from [dos]
set fileformat=unix
to find duplicate entries in the DB table:
select count(*), xref_id, asset_id from asset_xref group by xref_id, asset_id having count(*) > 1
to delete duplicates:
delete t1 from asset_xref t1, asset_xref t2 where t1.xref_id = t2.xref_id and t1.asset_id=t2.asset_id and t1.rank > t2.rank;
git log format:
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
git bash auto complete
curl -O https://github.com/git/git/raw/master/contrib/completion/git-completion.bash
put in ~/.git-completion.sh
then source ~/.git-completion.sh in bash_profile
sshfs:
add to /etc/fuse.conf
user_allow_other
to mount the dir via sshfs:
sshfs -o allow_other,uid=48,gid=48 josh@10.10.10.20:/medres_images/joshres/ srcImgs
to un-mount:
fusermount -u srcImgs/
generate a csv:
"select blah, blah2 etc FIELDS TERMINATED BY `,` LINES TERMINATED BY `\n`
FROM recipe r inner join asset_xref
ax on r.id=ax.xref_id
INNER JOIN asset a
ON a.id=ax.asset_id
INNER JOIN
web_usage wu
ON wu.recipe_id=r.id
WHERE a.type = 'video'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment