Skip to content

Instantly share code, notes, and snippets.

View MaxMorais's full-sized avatar
🏢
Building Solutions in Tech

Maxwell Morais MaxMorais

🏢
Building Solutions in Tech
View GitHub Profile
@MaxMorais
MaxMorais / maskedentry.py
Last active October 24, 2023 12:06
Masked Entry Widget for TkinterFormWidget for Tkinter - Like web2py FormWidget, with label, entry and tooltipTo future, ensure validation.
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#-------------------------------------------------------------------------------
# Name: maskedit.py
# Purpose:
#
# Author: Maxwell Morais ([email protected])
#
# Created: 10/04/2013
@vseventer
vseventer / callable-object.js
Last active July 10, 2016 10:31
Create a callable object in JavaScript which returns an isolated clone of itself. This is *not* a class, hence using the new keyword has no effect.
// How to define:
// --------------
var callableObjectFn = function() {
// Use CallableObject as name in constructor function, but also when setting property below.
var CallableObject = (function(CallableObject) {
return function() {
return CallableObject();
};
}(callableObjectFn));
CallableObject.property = 'value';
//Superseeded: https://gist.github.com/devinrhode2/4705947
/**
* Keep a histroy array of console log's
* See example at bottom
*/
window.originalConsole = window.console;
window.originalLog = window.console.log;
window.logWithHistory = function logWithHistoryFn() {
@devinrhode2
devinrhode2 / TraceKitSupplement.js
Last active October 23, 2023 12:49
Stuff I've added to my error reporting/handling stuff in addition to TraceKit.js, ideally in a few months I don't write any of this code
function exceptionalException(message) {
'use strict';
if (exceptionalException.emailErrors !== false) {
exceptionalException.emailErrors = confirm('We had an error reporting an error! Please email us so we can fix it?');
}
}
//test
//exceptionalException('try 1!');
//exceptionalException('try 2!');
@naholyr
naholyr / _service.md
Created December 13, 2012 09:39
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@rmehta
rmehta / gist:3866677
Created October 10, 2012 16:20
client event trigger example
// add a trigger on field "custom_field1"
cur_frm.cscript.custom_field1 = function(doc, cdt, cdn) {
// update a new field "custom_field3"
doc.custom_field3 = flt(doc.custom_field1)*flt(doc.custom_field2)/1000;
// refresh in form
refresh_field('custom_field3');
}
@lsbardel
lsbardel / async.py
Created May 8, 2012 16:15
A micro-asyncronous script derived from twisted
'''A micro-asyncronous script derived from twisted.'''
import sys
import traceback
from collections import deque
__all__ = ['Deferred', 'MultiDeferred']
def iterdata(stream):
@glenrobertson
glenrobertson / white_noise_image.py
Created April 3, 2012 00:05
get PIL white noise image
from PIL import Image
def get_white_noise_image(width, height):
pil_map = Image.new("RGBA", (width, height), 255)
random_grid = map(lambda x: (
int(random.random() * 256),
int(random.random() * 256),
int(random.random() * 256)
), [0] * width * height)
pil_map.putdata(random_grid)
@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
var TinyORM = (function(options) {
/* a hash containing all the available models */
var Models = {};
var connection = null;
var config = _.extend({
/* The name of the database which Ti will open. The local db is located at:
~/Library/Application Support/iPhone Simulator/4.2/Applications/APP_ID/Library/Application Support/database/dbname
*/
dbname: 'add.db',