Skip to content

Instantly share code, notes, and snippets.

View nguyenbathanh's full-sized avatar

Thanh Nguyen nguyenbathanh

View GitHub Profile
@nebiros
nebiros / IndexController.php
Created January 28, 2010 13:13
Export data to excel on Zend Framework
<?php
class IndexController extends Zend_Controller_Action
{
public function exportXlsAction()
{
set_time_limit( 0 );
$model = new Default_Model_SomeModel();
$data = $model->getData();
@wrunk
wrunk / jinja2_file_less.py
Last active September 19, 2023 15:05
python jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#
@jeromer
jeromer / compassbearing.py
Last active February 21, 2024 13:31
compass bearing between two points in Python
# LICENSE: public domain
def calculate_initial_compass_bearing(pointA, pointB):
"""
Calculates the bearing between two points.
The formulae used is the following:
θ = atan2(sin(Δlong).cos(lat2),
cos(lat1).sin(lat2) − sin(lat1).cos(lat2).cos(Δlong))
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@lsauer
lsauer / gist:2838503
Created May 30, 2012 19:43
comprehensive list of MIME types / subtypes as a tab-separated flatfile
//lsauer.com 2012
//description: comprehensive list of MIME types / subtypes as a tab-separated flatfile
//source: W3C
extension mime
.3dm x-world/x-3dmf
.3dmf x-world/x-3dmf
.a application/octet-stream
.aab application/x-authorware-bin
.aam application/x-authorware-map
@ibeex
ibeex / foo.log
Created August 4, 2012 13:46
Flask logging example
A warning occurred (42 apples)
An error occurred
@mindlace
mindlace / middleware.py
Created October 19, 2012 13:43
Add user created/modified to every model
"""Add user created_by and modified_by foreign key refs to any model automatically.
Almost entirely taken from https://github.com/Atomidata/django-audit-log/blob/master/audit_log/middleware.py"""
from django.db.models import signals
from django.utils.functional import curry
class WhodidMiddleware(object):
def process_request(self, request):
if not request.method in ('GET', 'HEAD', 'OPTIONS', 'TRACE'):
if hasattr(request, 'user') and request.user.is_authenticated():
user = request.user
@kapkaev
kapkaev / gist:4619127
Created January 24, 2013 09:30
MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error. Resque
$ redis-cli
> config set stop-writes-on-bgsave-error no
@ronelliott
ronelliott / bash_aliases_django.sh
Last active October 3, 2022 11:56
Helpful Bash Aliases for Django
alias dj="python manage.py"
alias djdd="python manage.py dumpdata"
alias djld="python manage.py loaddata"
alias djm="python manage.py migrate"
alias djsh="python manage.py shell"
alias djsm="python manage.py schemamigration"
alias djs="python manage.py syncdb --noinput"
alias djt="python manage.py test"
alias djrs="python manage.py runserver"
@jbub
jbub / squash-commits.sh
Created June 12, 2013 15:31
git squash last two commits into one
git rebase --interactive HEAD~2
# we are going to squash c into b
pick b76d157 b
pick a931ac7 c
# squash c into b
pick b76d157 b
s a931ac7 c