Skip to content

Instantly share code, notes, and snippets.

View ronbeltran's full-sized avatar

Ronnie Beltran ronbeltran

View GitHub Profile
@ronbeltran
ronbeltran / Beer.java
Created March 27, 2012 08:46
99 Bottles of Beer in Java
class Beer {
/* Prints the lyrics of "99 Bottles of Beer" */
public static void lyrics(int bottles){
if(bottles == 0){
System.out.println();
System.out.println("No bottles of beer on the wall, no bottles of beer, ya' can't take one");
System.out.println("down, ya' can't pass it around, 'cause there are no more bottles of beer on the wall!");
} else {
System.out.println(bottles + " bottles of beer on the wall," + bottles + " bottles of beer, ya' take one");
@ronbeltran
ronbeltran / Equi.java
Created April 19, 2012 07:16
Equilibrium index
/* http://rosettacode.org/wiki/Equilibrium_index
* Assume the sum of zero element is equal to zero. Write a function
* that given a sequence, returns its equilibrium index (any) or -1
* if no equilibrium indexes exist. Assume that the sequence may be very long.
*/
public class Equi {
private int array[];
private int index;
public Equi(int array[]){
@ronbeltran
ronbeltran / Inv.java
Created April 19, 2012 07:17
Inversion
public class Inv
{
public static int array_inversion_count(int array[])
{
int inversion_counter = 0;
for(int p=0;p<array.length;p++)
{
for(int q=0;q<array.length;q++)
{
package edu.upittc.training;
import javax.swing.JOptionPane;
public class ArrayTest {
public static int max(int[] x){
//get max integer in array
int max = x[0];
for(int i=0;i<x.length;i++){
@ronbeltran
ronbeltran / wsgi.py
Created August 12, 2012 11:05
Serve static file at Heroku with Python
from wsgiref.simple_server import make_server
import static
app = static.Cling('_site')
def main():
make_server('localhost', 8000, static.Cling('_site')).serve_forever()
if __name__=='__main__':
main()
@ronbeltran
ronbeltran / Procfile
Created August 12, 2012 11:06
Heroku Procfile: gunicorn + gevent
web: gunicorn wsgi:app -b 0.0.0.0:$PORT -w 3 -k gevent --max-requests 250
@ronbeltran
ronbeltran / custom_alias.sh
Created August 25, 2012 10:53
Bashrc Custom Alias
# custom alias
alias free="free -m"
alias cls="clear"
alias l="ls -lrt"
alias update="sudo apt-get update"
alias install="sudo apt-get install"
alias upgrade="sudo apt-get dist-upgrade"
alias remove="sudo apt-get remove"
alias reboot="sudo reboot"
alias shutdown="sudo shutdown -h now"
# pip is a tool for installing Python packages.
sudo easy_install pip
# Essential tools for any self-respecting Python programmer.
sudo pip install virtualenv virtualenvwrapper ipython
# This is where we keep Python environments.
mkdir ~/.virtualenvs
# Set up our shell for virtualenvwrapper.
{% load url from future %}
<link href="{{ STATIC_URL }}css/facebook.css" type="text/css" rel="stylesheet" media="all" />
{% include 'django_facebook/_facebook_js.html' %}
Register!
<form action="{% url 'facebook_connect' %}?facebook_login=1" method="post">
<a href="javascript:void(0);" style="font-size: 20px;" onclick="F.connect(this.parentNode);">Login or register with facebook</a>
<input type="hidden" value="{% url 'my_post_registration_url' %}" name="register_next" />

prefix == Ctrl+f

screenshot

Panes

Navigation

(vim movement keys)
prefix h

prefix j