Skip to content

Instantly share code, notes, and snippets.

Jeff Tchang tachang

Block or report user

Report or block tachang

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tachang
tachang / gist:2629805
Created May 7, 2012
ImageKit Save Method
View gist:2629805
# Image inherits from imagekit.models.ImageModel
class Image(ImageModel):
def retrieve_upload_path(image, filename):
fname, dot, extension = filename.rpartition('.')
return "images/%s.%s" % ( image.uuid, extension)
name = models.CharField(max_length=100, blank=True)
image = models.ImageField(upload_to=retrieve_upload_path)
num_views = models.PositiveIntegerField(editable=False, default=0)
@tachang
tachang / gist:3907876
Created Oct 17, 2012
showCanvas KnockoutJS
View gist:3907876
<canvas class="event-image-canvas" width="150" height="140" data-bind="drawCanvas: showImage"></canvas>
View gist:5421436
display_meeting_instructions = False
if user_can_edit:
display_meeting_instructions = True
if request.user.is_authenticated() and Ticket.objects.filter(event=event, user=request.user).exists():
display_meeting_instructions = True
{% if display_meeting_instructions and event.meeting_instructions %}
{{ event.meeting_instructions }}
{% endif %}
@tachang
tachang / fabfile.py
Created Apr 21, 2013
Fabfile to setup a new application server
View fabfile.py
from fabric.api import *
from fabric.context_managers import *
from fabric.contrib.files import *
import fabtools.require.git
import fabtools
def install_packages():
packages = ['build-essential','git-core','python-dev']
with settings(user='root', key_filename='./root-deploy.key'):
View gist:3270458acea40deca6ae
### Keybase proof
I hereby claim:
* I am tachang on github.
* I am tachang (https://keybase.io/tachang) on keybase.
* I have a public key whose fingerprint is A6A3 C419 9CBD 8EDF 649C 934B 451E 9BC4 9FA8 2390
To claim this, I am signing this object:
@tachang
tachang / CameraToMpegTest.java
Created Jun 17, 2014
CameraToMpegTest.java
View CameraToMpegTest.java
/*
* Copyright 2013 The Android Open Source Project
*
* Licensed 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
*
* Unless required by applicable law or agreed to in writing, software
View gist:401daae7a41802311341
/**
* Generates a frame of data using GL commands.
*/
private void generateSurfaceFrame(int frameIndex) {
frameIndex %= 8;
int startX, startY;
if (frameIndex < 4) {
// (0,0) is bottom-left in GL
startX = frameIndex * (mWidth / 4);
startY = mHeight / 2;
@tachang
tachang / SassMeister-input.scss
Created Aug 19, 2014
Generated by SassMeister.com.
View SassMeister-input.scss
// ----
// Sass (v3.3.14)
// Compass (v1.0.0.rc.1)
// ----
fdsaf
View gist:8ed00d576494999a07c6
Option 1)
<div>
<h3>Header</h3>
</div>
- Use position relative on h3. Problem is that it looks on the outside but the markup is on the inside.
@tachang
tachang / network-restart.sh
Created Apr 10, 2015
Cleanly restart the default libvirt network
View network-restart.sh
#!/bin/bash
#
# Yury V. Zaytsev <yury@shurup.com> (C) 2011
#
# This work is herewith placed in public domain.
#
# Use this script to cleanly restart the default libvirt network after its
# definition have been changed (e.g. added new static MAC+IP mappings) in order
# for the changes to take effect. Restarting the network alone, however, causes
# the guests to lose connectivity with the host until their network interfaces
You can’t perform that action at this time.