Skip to content

Instantly share code, notes, and snippets.

View MaxMorais's full-sized avatar
🏢
Building TechMax Soluções

Maxwell Morais MaxMorais

🏢
Building TechMax Soluções
View GitHub Profile
@drgarcia1986
drgarcia1986 / main.py
Last active August 29, 2015 14:02
[python-brasil] carregar processo independente
>>> import os
>>> programa = r'C:\Program Files (x86)\mongoDB\bin\mongod.exe'
>>> parametros = r'--logpath "C:\Foo\Bar\Base\install.log" --dbpath "C:\Foo\Bar\Base\data\db" --port 1124'
>>> os.path.dirname(programa)
'C:\\Program Files (x86)\\mongoDB\\bin'
>>> os.path.basename(programa)
'mongod.exe'
>>> os.spawnl(os.P_WAIT, os.path.dirname(programa), os.path.basename(programa), parametros)
Traceback (most recent call last):
File "<pyshell#20>", line 1, in <module>
@TheNicholasNick
TheNicholasNick / ishikawa_sha1.js
Created November 25, 2010 01:19
Takanori Ishikawa's JavaScript implementation of the Secure Hash Algorithm 1 (SHA1)
/*
* The JavaScript implementation of the Secure Hash Algorithm 1
*
* Copyright (c) 2008 Takanori Ishikawa <takanori.ishikawa@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
@jbpotonnier
jbpotonnier / gtranslate.py
Created February 12, 2011 18:56
Translate between french and english using google api
# -*- coding: iso-8859-15 -*-
import Tkinter as tkinter
import urllib2, urllib
import json
TRANSLATE_URL = 'http://ajax.googleapis.com/ajax/services/language/translate'
TO_ENGLISH = 'fr|en'
TO_FRENCH = 'en|fr'
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',
@aliles
aliles / context.py
Created February 17, 2014 11:20
Class switching context object to prevent applications for assigning to protected properties. Uses class swizzling.
"Program execution context"
import warnings
class SwizzleContext(object):
"""Type switching context object base class
Supports the context manager protocol to switch the instance from a
MutableContext to the protected Context.
"""
//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() {
@jumbojet
jumbojet / DE.py
Created September 18, 2013 17:18
Dynamic Expression Parsing
''' expressionString = IF Variable_3 > 1000 RETURN VARIABLE_3* VARIABLE_1 END IF Variable_3 < 1000 RETURN VARIABLE_3* VARIABLE_2 END '''
def parse_expression(expressionString):
expressionStringArray = filter(None,expressionString.split("END"))
''' expressionStringArray[0] = IF Variable_3 > 1000 RETURN VARIABLE_3* VARIABLE_1
expressionStringArray[1] = IF Variable_3 < 1000 RETURN VARIABLE_3* VARIABLE_2 '''
for expression in expressionStringArray:
expConditionResult = expression.strip().split("RETURN")
@mknln
mknln / gist:7444512
Created November 13, 2013 06:11
Reading JavaScript Patterns I thought of another way to write the decorator pattern. Not yet sure if this has any pitfalls.
SalesOrder.prototype.decorate = function(decorator) {
var override
for (override in decorator) {
if (decorator.hasOwnProperty(override)) {
var oldfunc = this[override]
var decfunc = decorator[override]
var newfunc = function() {
var args = Array.prototype.slice.call(arguments)
frappe.ui.form.on("Quotation", "refresh", function(frm, doctype, name) {
cur_frm.add_custom_button(__('Add Interaction'), function() {
var d = frappe.prompt([
{label:__("Type of Interaction"), fieldtype:"Select",
options: ["SMS", "Call", "Visit", "Webex"],
fieldname:"type_of_interaction"},
{label:__("Result"), fieldtype:"Select", options: ["Status Quo", "Warmer", "Colder"], fieldname:"result"},
{fieldtype: "Column Break"},
{'fieldname': 'responce_reson', 'fieldtype': 'Data', 'label': 'Responce Reson', 'reqd': 0},
{'fieldname': 'next_date', 'fieldtype': 'Date', 'label': 'Next Action Date', 'reqd': 0},
@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';