Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

suhail suhailvs

🏠
Working from home
View GitHub Profile
@suhailvs
suhailvs / Openshift27.md
Last active Aug 29, 2015
Openshift python -2.7, django-1.6 example
View Openshift27.md

Steps to create in OPENSHIFT

  1. Create a Python27 app in Openshift

create a python2.7 application in openshift

if you still don't uploaded the ssh publickey to openshift, then doit:

View HackMeSomeUnicoins.md

Much nicer solution can be used for any stackexchange sites::: First, go to stackoverflow.com(or any other stackexchange sites) then define this in your Javascript console(Press F12):

function minec(){ 
  $.getJSON('/unicoin/rock',function(data) {
    setTimeout(function(){
      $.post('/unicoin/mine?rock='+data.rock,{fkey:StackExchange.options.user.fkey})
      .done(function( data ) {
        console.log(data);
      });
@suhailvs
suhailvs / vim.md
Created Nov 22, 2014
VIM COMMANDS
View vim.md

Move

  • h - <-- ,j - down, k - up, l - -->.
  • w - next word, e - end, b - beginning,
  • 5w - 5 words, ,5h - 5 left,
  • 0 - move to beginning of the line, , $(end to the line)
  • gg - move to beggining of file, ,G - end, , 8G - move to 8th line,

Find

@suhailvs
suhailvs / nginx.md
Created Dec 15, 2014
Deploy Django on gevent with nginx
View nginx.md

create a file /etc/nginx/conf.d/virtual.conf

#
# A virtual host using mix of IP-, name-, and port-based configuration
#

server {
    listen       8080;
    server_name  chat.djangoer.com;
View imagefield_with_thumbnail.md

Create thumbnails for an ImageField in django

# -*- encoding: utf-8 -*-
"""
django-thumbs by Antonio Melé
http://django.es
"""
from django.db.models import ImageField
from django.db.models.fields.files import ImageFieldFile
from PIL import Image
@suhailvs
suhailvs / terminal_commands.md
Last active Aug 29, 2015
Terminal Commands
View terminal_commands.md

to kill all process:

killall -9 <name>

to copy file to server:

scp <filename> root@djangoer.com:

to get disk usage:

@suhailvs
suhailvs / internet_usage.md
Created Dec 31, 2014
How to monitor internet usage?
View internet_usage.md

Install

$ apt-get install vnstat

Usage

To create the cron job simply run this command

$ vnstat -u -i eth0
@suhailvs
suhailvs / virtualenvwrapper.md
Last active Aug 29, 2015
How to install v wrapper
View virtualenvwrapper.md
$ sudo pip install virtualenvwrapper

# append it to file `.bashrc`
$ vi ~/.bashrc
source /usr/local/bin/virtualenvwrapper.sh

now restart terminal

@suhailvs
suhailvs / nginx_local_setup.md
Created Jun 5, 2015
How To Set Up nginx Virtual Hosts on Ubuntu
View nginx_local_setup.md

taken from here

1: Install nginx:

sudo apt-get install nginx

2: Create a New Directory:

The first step in creating a virtual host is to a create a directory where we will keep the new website’s information.

@suhailvs
suhailvs / gist:6837260
Created Oct 5, 2013
restricting submit per 4seconds.
View gist:6837260
<form method='post' onsubmit="return validateFormOnSubmit(this)" action=''>
....
<input type="submit" value="ok">
</form>
<script>
var allowSubmit = true;
function validateFormOnSubmit(theForm) {
//prevent multiple submit by restricting submit per 4seconds
if (!allowSubmit){