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
#!/usr/bin/env ruby -w
# brew-services(1) - Easily start and stop formulas via launchctl
# ===============================================================
#
# ## SYNOPSIS
#
# [<sudo>] `brew services` `list`<br>
# [<sudo>] `brew services` `restart` <formula><br>
# [<sudo>] `brew services` `start` <formula> [<plist>]<br>
@neara
neara / JavaScript_Utils
Last active August 29, 2015 14:12
General utilities methods
/**
* UTILS module - contains a number of general methods.
* Inspired by http://javascript.crockford.com/remedial.html
* */
var UTILS = (function (utils, $) {
"use strict";
/**
* Improved typeof method, distinguishes <array> and <null> from object
*/
// 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.
# 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) ->
@zed = @zed ? {}
@zed.info = do ->
#private
name = ""
getName = -> name
setName = (value) -> name = value
age = 0
getAge = -> age
@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
-- 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 / 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')
@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',

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