Skip to content

Instantly share code, notes, and snippets.

@PirosB3
PirosB3 / error
Created August 3, 2011 14:14
Functional test failing on post :create! TypeError: expected numeric or date
1) UsersController create action should destroy session if is present
Failure/Error: post :create
TypeError:
expected numeric or date
# ./app/models/user.rb:48:in `user_bigger_than_18'
# ./app/controllers/users_controller.rb:11:in `create'
# ./spec/controllers/users_controller_spec.rb:67:in `block (2 levels) in <top (required)>'
require "net/http"
request = Net::HTTP.new("grooveshark.com")
path = '/more.php?getCountry'
data = '{"method":"getCountry"}'
headers = {'Host' => 'grooveshark.com',
'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0.1) Gecko/20100101 Firefox/5.0.1',
'Accept-Encoding' => 'gzip, deflate',
'Accept-Charset' => 'utf-8',
@PirosB3
PirosB3 / gist:1868524
Created February 20, 2012 09:15
differences? when should I use one or the other?
function TestMe(name) {
this.name = name;
}
TestMe.prototype.sayHello = function() {
return "Hello my name is " + this.name;
}
testme = function(name) {
return {
@PirosB3
PirosB3 / gist:1975166
Created March 4, 2012 22:34
what would you tell me of this code?
#Function is called with a string
def isAnagramOfPalindrome ( S ):
# Check length if length even then all need to be two
# if not even there must be a -1
dic = {}
for c in S:
if dic.__contains__(c):
dic[c] += 1
{% block scripts %}
<script src="{{ STATIC_URL }}js/libs/jquery.easing.1.3.min.js"></script>
<script src="{{ STATIC_URL }}js/libs/jquery.activity-indicator-1.0.0.min.js"></script>
<script src="{{ STATIC_URL }}js/intro-animation.min.js"></script>
<script src="{{ STATIC_URL }}js/libs/jquery.colorbox-min.js"></script>
<script type="text/javascript">
// Piccolo script inline per modale
$(function() {
$('#gnammo-modal-internal-close').click(function() {
$.colorbox.close()
@PirosB3
PirosB3 / z
Created October 31, 2012 00:26
new
function SidebarController($scope, $http) {
$http.get('api/factions').success(function(data) {
$scope.factions = data;
});
$http.get('api/countries').success(function(data) {
$scope.countries = data;
});
}
function MepListController($scope, $http, $routeParams) {
angular.module('TweetYourMep', []).
config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/name/:name/country/:country/localParty/:localParty/faction/:faction', { templateUrl: "/partials/main.html", controller: RootView} );
$routeProvider.otherwise({redirectTo: '/name/all/country/all/localParty/all/faction/all'});
}]);
from fabric.context_managers import settings
from fabric.operations import local
def run_unix_command(command):
with settings(warn_only= True):
return local('ls', capture= True)
res = run_unix_command('ls -lah')
print res.return_code
print res.stdout
import re
LIST_RE = re.compile('^\s-\s')
DICT_RE = re.compile('^.+\s\|\s.+$')
filter_non_empty = lambda x: filter(lambda y: len(y) > 0, x)
def _parse_dict(lines):
res = {}
for line in filter_non_empty(lines):
@PirosB3
PirosB3 / datafile
Created December 4, 2012 14:54
script
Blog china kids music yahoo want wrong service tech saying lots had address working following years didn internet wants photos former technology being traffic small past full november experience door company learn paper research sell self sometimes couple video makes next process books could stuff audio web become problem details worth provide feeds another john away hand thanks night test update guy cost product still non drop year tried america amp start podcast month advertising ask almost systems american culture close pictures smart showing popular application e dvd camera links including during university special times party home display star likely room before personal digg yes yet save deal magazine down weekend international box visit making interesting morning enough sound images released again u hour days needs coming through services point cut source though planet entire access turn happens development school however news conference n gave level posts goes sure later case director without list ver