Skip to content

Instantly share code, notes, and snippets.

View vshjxyz's full-sized avatar
🌀

Luca Del Bianco vshjxyz

🌀
View GitHub Profile
@vshjxyz
vshjxyz / Tastypie datatables with pagination.coffee
Last active February 28, 2019 06:23
This is a simple example of a working datatable using tastypie. I also Implemented the fnServerData so the datatable can paginate, search (via a query parameter configured in tastypie in the apply_filter method of the OrderResource), and sort columns using custom logics via the order_by parameter of tastypie.
@orders_table = $('#orders-table', element).dataTable
bProcessing: true
bServerSide: true
sAjaxSource: ORDERFULL_API
sAjaxDataProp: "objects"
aoColumns: [
# Put the resource name that corresponds to each table column
{
"mData": "id"
"sClass": "order-id"
@vshjxyz
vshjxyz / Appfog django south migrate.py
Last active December 13, 2015 23:58
This is the content of my __init__.py to perform migrations on appfog I needed this because the django-allauth package need to do some migrations initially to work. The Appfog's lack of post-deploy scripts forced me to create a script that I had to put inside one of the apps in my project django_project/appname/management/__init__.py should make…
from django.core.exceptions import ImproperlyConfigured
from django.core.management import call_command
from django.db.models.signals import post_syncdb
from south.models import MigrationHistory
import pizzanuvola_teaser.settings as settings
def migration_exists(appname, migrationnumber):
appname = appname.split('.')[-1]
return MigrationHistory.objects.filter(app_name=appname, migration__icontains=migrationnumber).exists()
@vshjxyz
vshjxyz / _settings.scss
Created October 28, 2013 12:16
SCSS variables of FlatUIColors
$turquoise : #1abc9c;
$emerland : #2ecc71;
$peterriver : #3498db;
$amethyst : #9b59b6;
$wetasphalt : #34495e;
$greensea : #16a085;
$nephritis : #27ae60;
$belizehole : #2980b9;
$wisteria : #8e44ad;
$midnightblue: #2c3e50;
@vshjxyz
vshjxyz / auth.py
Last active January 4, 2016 21:59
Code examples
from django.contrib.auth.models import User
from django.contrib.sessions.models import Session
from tastypie.authorization import Authorization
from tastypie.exceptions import Unauthorized
from django.db.models import Q
from apps.authorization.models import UserType
from apps.pos.models import Pos
class SubdomainAuthorization(Authorization):
@vshjxyz
vshjxyz / getJSON.coffee
Created January 31, 2014 10:53
Node.js examples
http = require "http"
https = require "https"
###
getJSON: REST get request returning JSON object(s)
@param options: http options object
@param callback: callback to pass the results JSON object(s) back
###
exports.getJSON = (options, onResult) ->
console.log "---> #{options.method} ~ #{options.host}:#{options.port}#{options.path}"
# Path to your oh-my-zsh installation.
export ZSH=/Users/developer/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="gianu"
# Uncomment the following line to use case-sensitive completion.
@vshjxyz
vshjxyz / Fibonacci ES6.js
Created November 12, 2015 12:50
just a test function to see how recursive generators works in ES6
function *fib(iterations=10, val1=0, val2=1) {
if (iterations > 0) {
let sum = val1 + val2;
yield sum;
yield *fib(iterations - 1, val2, sum);
}
}
[...fib()].map((val) => console.log(val));
const handler = (request, response) => response('Hello, World!');
const routes = {
home: handler,
foo: {
bar: handler,
baz: handler,
qux: handler
},
ids: {
1: handler,
### Keybase proof
I hereby claim:
* I am vshjxyz on github.
* I am delbianco (https://keybase.io/delbianco) on keybase.
* I have a public key whose fingerprint is 0058 0111 18B8 C588 2A4A C699 87E9 D63E F220 B01A
To claim this, I am signing this object:
const input = [[1,2,[3]],4];
const output = [1,2,3,4];
function *flatten(arr) {
for (value of arr) {
if (Array.isArray(value)) {
yield *flatten(value);
} else {
yield value;
}