Skip to content

Instantly share code, notes, and snippets.

diff --git a/plugins/gist_tag.rb b/plugins/gist_tag.rb
index 1620345..39b4bc9 100644
@@ -17,6 +17,8 @@ module Jekyll
@text = text
@cache_disabled = false
@cache_folder = File.expand_path "../.gist-cache", File.dirname(__FILE__)
+ # Only for Octopress
+ @github_user = Jekyll.configuration({})['github_user']
FileUtils.mkdir_p @cache_folder
@creativepsyco
creativepsyco / gist_tag.rb
Created October 4, 2013 06:51
Fix for Octopress installation new gist url
# A Liquid tag for Jekyll sites that allows embedding Gists and showing code for non-JavaScript enabled browsers and readers.
# by: Brandon Tilly
# Source URL: https://gist.github.com/1027674
# Post http://brandontilley.com/2011/01/31/gist-tag-for-jekyll.html
#
# Example usage: {% gist 1027674 gist_tag.rb %} //embeds a gist for this plugin
require 'cgi'
require 'digest/md5'
require 'net/https'
@creativepsyco
creativepsyco / HighlightRadioButton.java
Created October 4, 2013 06:02
HighlightRadionButton with two state list drawable
public class HighlightedImageRadioButton extends RadioButton {
private Drawable buttonDrawable;
public HighlightedImageRadioButton(Context context) {
super(context);
}
@creativepsyco
creativepsyco / ImageRotation.java
Created September 6, 2013 06:42
Getting the orientation and rotating the image properly
private int __getImageOrientation(final String file) throws IOException {
ExifInterface exif = new ExifInterface(file);
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
BBAppLogger.i("EXIF %d", orientation);
switch (orientation) {
case ExifInterface.ORIENTATION_NORMAL:
return 0;
case ExifInterface.ORIENTATION_ROTATE_90:
return 90;
case ExifInterface.ORIENTATION_ROTATE_180:
@creativepsyco
creativepsyco / ImageOrientation.java
Created September 6, 2013 06:41
Gets the image orientation given a file path !
private int __getImageOrientation(final String file) throws IOException {
ExifInterface exif = new ExifInterface(file);
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
BBAppLogger.i("EXIF %d", orientation);
switch (orientation) {
case ExifInterface.ORIENTATION_NORMAL:
return 0;
case ExifInterface.ORIENTATION_ROTATE_90:
return 90;
case ExifInterface.ORIENTATION_ROTATE_180:
@creativepsyco
creativepsyco / GetFilePath.java
Created September 6, 2013 06:39
Allows to read path of camera images. In some devices especially the ones with big RAM, they are not stored on the disk but in a temp location
private String __getFilePathFromURI(ContentResolver cr, Uri photoUri) throws IOException {
if (photoUri.getScheme().equals("file")) {
return photoUri.getPath();
}
String[] queryTerms = {MediaStore.Images.Media.DATA};
Cursor cursor = cr.query(photoUri, queryTerms, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
@creativepsyco
creativepsyco / delete.sh
Created August 21, 2013 06:35
Delete all unadded files from svn repository
svn status | awk -F' ' '{ print $2 }' | xargs rm -rf
# output of svn status
# ? pygeoip-0.2.2
# ? Django-1.4
@creativepsyco
creativepsyco / BBChatViewHost.java
Created July 31, 2013 02:23
How to scroll Android Listview to the bottom always
public void scrollBottom() {
// scroll bottom requires posting a runnable to the listView
// in the case of items loading by themselves dynamically
// there may be sync issues and scrolling won't be proper
m_bNeedScrollToBottom = false;
if (m_listView.getLastVisiblePosition()-m_listView.getFirstVisiblePosition() <= m_listView.getCount())
m_listView.setStackFromBottom(false);
else
m_listView.setStackFromBottom(true);
BBUILoop.getInstance().delayPost(new Runnable() {
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "key.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
@creativepsyco
creativepsyco / CommandFragment.java
Created April 29, 2013 05:47
Creating Listeners in an Android App
private void setUpListeners() {
Button first = (Button) getView().findViewById(R.id.button);
first.setOnClickListener(new View.OnClickListener(){
public void onClick(View v)
{
firstCommandFired();
}
});
Button second = (Button) getView().findViewById(R.id.button1);