Skip to content

Instantly share code, notes, and snippets.

View hzbd's full-sized avatar
I may be slow to respond.

hzbd

I may be slow to respond.
View GitHub Profile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Hadoop 2.6.0 Multinode cluster Setup
From Blog http://www.michael-noll.com/tutorials/running-hadoop-on-ubuntu-linux-multi-node-cluster/
###Machine 1(master).
Prequisite:
java version
java -version
@hzbd
hzbd / addElements.html
Created August 16, 2014 17:40
auto adding a element by js.
<html>
<head>
<title>Testing</title>
<script language="javascript">
fields = 1;
function addInput() {
if (fields < 4) {
document.getElementById('text').innerHTML += "<input type='file'"+ "name=" + "thumdals" + fields + " value=''/><br />";
fields += 1;
} else {
/* ===================================================
* jQuery SelectAll plugin
* ===================================================
* @author: https://gist.github.com/Leegorous
* @license: Licensed under the Apache License, Version 2.0 (the "License"),
* see http://www.apache.org/licenses/LICENSE-2.0
* ===================================================
*
* Example:
*
@hzbd
hzbd / share_tp
Created March 8, 2014 11:07
Django Share button template
{% autoescape on %}
{% with "http://carlosvin.alwaysdate.net" as host %}
{% with "Share in" as share_txt %}
{% with "twitter" as service %}
<a href="http://twitter.com/share?url={{ host }}{{ page_url }}&amp;text={{ title }}" target="_blank" title="{{ share_txt }} {{ service }}">
<img src="http://carlosvin.alwaysdate.net/templates/img/tw.png" alt="{{ share_txt }} {{ service }}"/>
</a>
{% endwith%}
class ImageWithThumbnail(models.Model):
name = models.CharField(max_length = 255)
image = models.ImageField(upload_to=settings.UPLOAD_ROOT,max_length=500,blank=True,null=True)
thumbnail = models.ImageField(upload_to=settings.UPLOAD_ROOT,max_length=500,blank=True,null=True)
def create_thumbnail(self):
# original code for this method came from
# http://snipt.net/danfreak/generate-thumbnails-in-django-with-pil/
#!/usr/bin/env python
import os
from subprocess import check_call
waittime = 5
if len(sys.argv)>1:
waittime = int(sys.argv[1])
# print waittime
@hzbd
hzbd / postgres_backup
Created November 10, 2013 06:16
PostgreSQL database backup script (Python recipe)
#!/usr/bin/env python
import os
import time
username = 'root'
defaultdb = 'postgres'
port = '5433'
backupdir='/www/backup/'
date = time.strftime('%Y-%m-%d')
#!/bin/bash
#script extraido de: http://paulocassiano.wordpress.com/2008/08/29/deixando-o-gedit-com-a-cara-do-textmate/
#tip for better "resolution" here: http://blog.siverti.com.br/2008/05/22/fonte-monaco-no-ubuntugedit/
cd /usr/share/fonts/truetype/
#TODO: put validation if folder already exists
sudo mkdir ttf-monaco
@hzbd
hzbd / haproxy.config
Created May 4, 2013 17:34
Sample HAProxy config with logging.
global
pidfile /var/run/haproxy.pid
log 127.0.0.1 local0 info
ulimit-n 65536
defaults
mode http
clitimeout 600000 # maximum inactivity time on the client side
srvtimeout 600000 # maximum inactivity time on the server side