Skip to content

Instantly share code, notes, and snippets.

View robotlolita's full-sized avatar
🐴
everything happens so much oh no

Quil robotlolita

🐴
everything happens so much oh no
View GitHub Profile
import sys
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtWebKit import *
class Everything(QObject):
@Slot(result=int)
def answer(self):
return 42
(function(){
var interval
, count = 0
interval = setInterval(function(){ console.log(++count) }, 1000)
setTimeout(function(){ clearInterval(interval) }, 5000)
})();
// should count up to 4/5 and stop
def raiz_quadrada(numero):
"""Retorna a raiz quadrada do número passado como parâmetro.
"""
for chute in chute_uns_numeros(numero):
if chute_esta_bom(chute, numero):
return chute
def chute_esta_bom(chute, numero):
"""Retorna se o chute é uma aproximação boa o suficiente da raiz quadrada.
function contains(obj, value) {
return obj && obj.indexOf(value) != -1
}
var checked = contains(sd_o, sd[i].id) // must be false or null to disable
var formElm = new Element('input', {'type': 'checkbox'
,'name': 'sideDish[]'
,'id': 'sideDish_' + sd[i].id
,'value': sd[i].id
,'checked': checked})
function isNumeric(v) {
return !isNaN(+v) // implicit typecasting to Number, taking advantage of JavaScript's type coercion
}
function checkForm() {
var elms_to_test = ['coupon', 'ins', 'quantity', 'ref', 'dr']
, el, i
for (i = elms_to_test.length; i--; ) {
// use getElementById to get a reference to the element with the given ID.
def lowercased(fn):
fn.__name__ = fn.__name__.lower()
return fn
class Stuff(object):
@lowercased
def CamelCasedMethod():
pass
print dir(Stuff)
# -------------------------------------------------------------------------
def indexPage(self, ctx):
scope = self
class IndexPage(Conditional):
def item(self):
return scope.page if scope.page.index else None
return IndexPage(ctx)
var http = require('http');
var fs = require('fs');
var url = require('url');
var settingsPath='settings2.json';
var Server = function(path){
this.readSettings(path);
}
#!/usr/bin/python
import time
from collections import defaultdict
class IdleProcess(object):
"""Process data when CPU is idle
"""
def __init__(self):
self.poll = []
# -*- coding: utf-8 -*-
#!/usr/bin/python
from collections import defaultdict
class Eventful(object):
"""Any class that can respond to events.
"""
def __init__(self):
self.listeners = defaultdict(list)