Skip to content

Instantly share code, notes, and snippets.

View mahmoudimus's full-sized avatar
💭
@_@

Mahmoud Rusty Abdelkader mahmoudimus

💭
@_@
View GitHub Profile
@mahmoudimus
mahmoudimus / .tmux.conf
Created December 8, 2011 17:52 — forked from nisc/.tmux.conf
tmux config
###
### Bindings
###
unbind C-b
set -g prefix C-a
bind a send-prefix
# URL viewing
bind-key u capture-pane \; save-buffer /tmp/tmux-buffer \; run-shell "xterm -e 'cat /tmp/tmux-buffer | urlview'"
@mahmoudimus
mahmoudimus / sshpub-to-rsa
Created January 21, 2012 22:19 — forked from thwarted/sshpub-to-rsa
converts an openssh RSA public key into a format usable by openssl rsautl (if you don't have openssh 5.6 or later with ssh-keygen PEM export format)
#!/usr/bin/env python
# with help and inspiration from
# * ASN1_generate_nconf(3) (specifically the SubjectPublicKeyInfo structure)
# * http://www.sysmic.org/dotclear/index.php?post/2010/03/24/Convert-keys-betweens-GnuPG%2C-OpenSsh-and-OpenSSL
# * http://blog.oddbit.com/2011/05/converting-openssh-public-keys.html
# the unix way of doing it:
# Convert ssh-rsa key to pem
# ssh-keygen -f infile.pub -e -m PKCS8 > outfile.pem
def run_pg_fouine():
info = host_info[env.host_string]
db_name = info.tags.get('Name')
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 0/" /etc/postgresql/9.*/main/postgresql.conf')
sudo('/etc/init.d/postgresql reload')
time.sleep(30)
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 500/" /etc/postgresql/9.*/main/postgresql.conf')
sudo('/etc/init.d/postgresql reload')
run('tail -n 100000 /var/log/postgresql/postgresql-9.*-main.log > /tmp/pgfouine.txt')
run('gzip -f /tmp/pgfouine.txt')
@mahmoudimus
mahmoudimus / rvm2rbenv.txt
Created May 13, 2012 22:56 — forked from brentertz/rvm2rbenv.txt
Switch from RVM to RBENV
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
@mahmoudimus
mahmoudimus / .ideamodules.xml
Created May 17, 2012 00:57
InetlliJ Modules in Rubymine
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/custom_engine1/module1.iml" filepath="$PROJECT_DIR$/custom_engine1/custom_engine1.iml" />
<module fileurl="file://$PROJECT_DIR$/custom_engine2/module2.iml" filepath="$PROJECT_DIR$/custom_engine2/custom_engine2.iml" />
</modules>
</component>
</project>
@mahmoudimus
mahmoudimus / create-bank-account.bash
Created June 19, 2012 01:15
create a bank account
curl -X POST https://api.balancedpayments.com/v1/marketplaces/TEST-MP6IEymJ6ynwnSoqJQnUTacN/accounts \
-u 7b7a51ccb10c11e19c0a026ba7e239a9: \
-d email_address="[email protected]" \
-d bank_account[name]="WHC III Checking" \
-d bank_account[account_number]="12341234" \
-d bank_account[bank_code]="321174851" \
-d merchant[type]="person" \
-d merchant[name]="William James" \
-d merchant[street_address]="801 High St" \
-d merchant[postal_code]="94301" \
@mahmoudimus
mahmoudimus / meta.rb
Created July 6, 2012 15:16
Meta querying example for querying by payment sids
require 'balanced'
Balanced.configure "#{API_KEY}"
Balanced::Transaction.paginate(:'meta.pound.payment_sid' => 'PY.....').each do |transaction|
p transaction
end
@mahmoudimus
mahmoudimus / pictures.markdown
Created August 29, 2012 18:26 — forked from sent-hil/pictures.markdown
River (getriver.com): Keep a programming journal.

One of my favorite past times is to look at the notebooks of famous scientists. Da Vinci's notebook is well known, but there plenty others. Worshipping Da Vinci like no other, I bought a Think/Create/Record journal, used it mostly to keep jot down random thoughts and take notes. This was great in the beginning, but the conformity of lines drove me nuts. Only moleskines made blank notebooks, so I had to buy one.

At the same time I started a freelance project. The project itself is irrelevant, but suffice to say it was very complex and spanned several months. It seemed like a perfect opportunity to use the moleskine. Looking back, all my entries fell under few categories:

  • Todo
  • Question
  • Thought
  • Bug
  • Feature
@mahmoudimus
mahmoudimus / example.py
Created August 30, 2012 00:07
__self__ when bound
>>> class O(object):
... def foo(self):
... return 1
...
>>> o = O()
>>> o.foo
<bound method O.foo of <__main__.O object at 0x10049a910>>
>>> o.foo.__self__
<__main__.O object at 0x10049a910>
@mahmoudimus
mahmoudimus / find-it.py
Created September 20, 2012 16:48
find financial instrument
def find_instrument(transaction_number):
instrument = {
'H': balanced.Hold,
'W': balanced.Debit,
'C': balanced.Credit
}[transaction_number[0]]
return instrument.query.filter(instrument.f.transaction_number == transaction_number).one()