Skip to content

Instantly share code, notes, and snippets.

View neara's full-sized avatar
🏠
Working from home

Ana neara

🏠
Working from home
View GitHub Profile
@neara
neara / gist:7432429
Last active December 28, 2015 02:59
Wrapper Func for extracting function args and kwargs
class MyClassWrapper(object):
def __init__(self, f, myarg):
self.myarg = myarg
self.args = ''
self.kwargs = ''
self.func = f
def __call__(self, *args, **kwargs):
self.args = args
$('.fs-about').click(function(event) {
var aboutRect, eleRect;
event.preventDefault();
eleRect = this.getBoundingClientRect();
aboutRect = {
top: eleRect.bottom,
left: eleRect.right - $('#about').outerWidth()
};
$(this).addClass('selected');
$('#about').show().offset({

DataURI.py

Data URI manipulation made easy.

This isn't very robust, and will reject a number of valid data URIs. However, it meets the most useful case: a mimetype, a charset, and the base64 flag.

Parsing

@neara
neara / base64.py
Created February 6, 2014 07:54 — forked from karmadonov/base64.py
import base64
import cStringIO
from django.core.files.uploadedfile import InMemoryUploadedFile
# ...
if request.POST.get('file') and request.POST.get('name'):
file = cStringIO.StringIO(base64.b64decode(request.POST['file']))
image = InMemoryUploadedFile(file,
field_name='file',
@neara
neara / Social_Buttons
Last active August 29, 2015 13:56
Dynamic social buttons: twitter, facebook, google plus
$socialBtnsWrapper = $('<div>').addClass('row col-xs-12')
$twitterContainer = $('<div>').addClass('col-xs-4 social-btn')
$twitterShareBtn = $('<a>').attr('href', 'https://twitter.com/share')
.addClass('twitter-share-button')
.attr('data-count', 'vertical')
.attr('data-via', 'fanwaze')
.attr('data-url', urlToShare)
.attr('data-text', 'Discover the world of sports')
.text('Share on Twitter')
-- http://stackoverflow.com/questions/1124603/grouped-limit-in-postgresql-show-the-first-n-rows-for-each-group
-- http://www.postgresql.jp/document/9.2/html/tutorial-window.html
CREATE TABLE empsalary (
depname varchar(10) not null
, empno integer not null
, salary integer not null
);
INSERT INTO empsalary (depname, empno, salary) VALUES ('develop', 11, 5200);
@neara
neara / Procfile
Created April 23, 2014 13:21
Celery Multiple Queues Setup
web: run-program gunicorn arena.wsgi
celery_beat: run-program celery -A arena beat -l info
celery1: run-program celery -A arena worker -Q default -l info --purge -n default_worker
celery2: run-program celery -A arena worker -Q feeds -l info --purge -n feeds_worker
@zed = @zed ? {}
@zed.info = do ->
#private
name = ""
getName = -> name
setName = (value) -> name = value
age = 0
getAge = -> age
# A class-based template for jQuery plugins in Coffeescript
#
# $('.target').myPlugin({ paramA: 'not-foo' });
# $('.target').myPlugin('myMethod', 'Hello, world');
#
# Check out Alan Hogan's original jQuery plugin template:
# https://github.com/alanhogan/Coffeescript-jQuery-Plugin-Template
#
(($, window) ->
// Intercepting HTTP calls with AngularJS.
angular.module('MyApp', [])
.config(function ($provide, $httpProvider) {
// Intercept http calls.
$provide.factory('MyHttpInterceptor', function ($q) {
return {
// On request success
request: function (config) {
// console.log(config); // Contains the data about the request before it is sent.