Skip to content

Instantly share code, notes, and snippets.

View marioidival's full-sized avatar
😶‍🌫️

Mario Idival marioidival

😶‍🌫️
  • Self Employed ;)
  • Campina Grande, Paraíba, Brazil
  • 02:35 (UTC -03:00)
  • X @marioidival
View GitHub Profile
@gilbert
gilbert / view-model-example.js
Last active October 6, 2019 23:39
Mithril View-Model Example
var Comment = {]
Comment.create = function (attrs) {
return m.request({ method: 'POST', url: '/comments', data: attrs })
}
// A view-model is basically a temporary, disposable copy of a model.
// It allows the user can either commit or cancel the changes they make.
Comment.vm = function (attrs) {
attrs = attrs || {}
@stummjr
stummjr / BSTNode.py
Last active April 27, 2024 23:38
BSTNode.py - Binary Search Tree
# -*- encoding:utf-8 -*-
from __future__ import print_function
class BSTNode(object):
def __init__(self, key, value=None, left=None, right=None):
self.key = key
self.value = value
self.left = left
#traduzido e adaptado de http://blog.trinket.io/writing-poetry-in-python/
from random import choice, randint
adjetivos = '''compreensivo temperamental confiável confiável honesto desonesto
interessante chato carinhoso simpático amigável generoso ciumento invejoso
inseguro ambicioso ansioso bondoso sensato sensível teimoso preguiçoso
trabalhador calmo paciente inteligente esperto espirituoso astuto neurótico
ousado apático cínico sarcástico irônico cético alegre conservador pessimista
otimista tolerante corajoso educado mal-educado determinado sociável
solidário arrogante maldoso desajeitado burro independente confiável dependente
@kachayev
kachayev / concurrency-in-go.md
Last active January 6, 2025 22:43
Channels Are Not Enough or Why Pipelining Is Not That Easy
@JulienPalard
JulienPalard / curry.py
Created August 1, 2014 10:51
KISS Python curry
#!/usr/bin/env python
def curry(func):
"""
Decorator to curry a function, typical usage:
>>> @curry
... def foo(a, b, c):
... return a + b + c

Porting an Existing Application to Pyramid

Porting an application across platforms is never particularly easy, nor very interesting. In fact, it's usually a terrible idea: in general, if it ain't broke, don't fix it. But sometimes you have to do it. Maybe a new platform has a feature you believe you can't live without, or the project scope is expanding in directions that make you feel like your original platform choice might not have been the best, or maybe it's just necessary to port for political reasons. Whatever.

@takanuva
takanuva / Commands to compile:
Created March 1, 2014 05:40
Integrating Java and C++ with GCC/CNI :)
#!/bin/bash
# Compile Main for Java bytecode
gcj -C Main.java
# Compile Main for native
gcj -findirect-dispatch -fno-indirect-classes -fpic -c Main.class -o java.o
# Generate header file
gcjh -cp . Main
@xuncheng
xuncheng / spec_has_many_through.rb
Created July 2, 2013 10:30
rspec testing has_many :through association
# video.rb
class Video < ActiveRecord::Base
has_many :categorizations
has_many :categories, through: :categorizations
end
# category.rb
class Category < ActiveRecord::Base
has_many :categorizations
has_many :videos, through: :categorizations
@cespare
cespare / gist:2402610
Created April 17, 2012 00:45
Coffeescript function with multiple callbacks
foo = (f1, f2) ->
f1()
f2()
# Doesn't work -- syntax error
# foo(-> console.log("hi from f1"), -> console.log("hi from f2"))
# Simplest way I've found to do it -- newlines added for clarity
foo(
(-> console.log("hi from f1")),
@kennethreitz
kennethreitz / mongo.py
Created March 13, 2012 22:54 — forked from lstoll/mongo.py
MongoHQ w/ pymongo on Heroku
import os
import pymongo
MONGO_URL = os.environ.get('MONGOHQ_URL')
if MONGO_URL:
# Get a connection
conn = pymongo.Connection(MONGO_URL)
# Get the database