Skip to content

Instantly share code, notes, and snippets.

View bigbn's full-sized avatar

Pavel Shabardin bigbn

View GitHub Profile
var actionUtil = require('sails/lib/hooks/blueprints/actionUtil');
module.exports = function getCount (req, res) {
var Model = actionUtil.parseModel(req)
, criteria = actionUtil.parseCriteria(req);
Model.count(criteria, function(error, response) {
if (error) {
return res.serverError('database_error', error);
@tauren
tauren / isNotColletion.js
Created March 13, 2014 02:38
Sails.js policy that enforces current user as creator of models
module.exports = function(req, res, next) {
// Make sure request is for a single entity, not for a collection of entities
if (!req.params.id) {
return res.forbidden('error.noPermission');
}
return next();
};
@RunnerRick
RunnerRick / .sails-and-passport.md
Last active December 3, 2023 05:01 — forked from theangryangel/AuthController.js
How To Integrate Sails and Passport
@hogelog
hogelog / pyside.py
Created April 8, 2013 17:53
QSystemTrayIcon Example
#!/usr/bin/python
# Import PySide classes
import sys
from PySide.QtCore import *
from PySide.QtGui import *
class App:
def __init__(self):
@gourneau
gourneau / downloadChunks.py
Created December 4, 2011 18:33
Download large files with Python urllib2 to a temp directory
import os
import urllib2
import math
def downloadChunks(url):
"""Helper to download large files
the only arg is a url
this file will go to a temp directory
the file will also be downloaded
in chunks and print out how much remains
@ederwander
ederwander / gist:1342497
Created November 6, 2011 05:01
Accessing the Google Speech API + Python
# Copyright (c) 2011, Eng Eder de Souza
# ___ _ _ ___
# | __|__| |___ _ _ __| |___ / __| ___ _ _ _____ _
# | _|/ _` / -_) '_| / _` / -_) \__ \/ _ \ || |_ / _` |
# |___\__,_\___|_| \__,_\___| |___/\___/\_,_/__\__,_|
#Accessing the Google API for speech recognition!
#Open a file type Wav to speech recognition
#This source does not require any external programs to perform audio conversions :-)
#http://ederwander.wordpress.com/2011/11/06/accessing-the-google-speech-api-python/
#Eng Eder de Souza