This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> data = ['aa', 'bb', 'ab', 'bc'] | |
>>> def _filter_native(data): | |
... sts = ['a', 'b'] | |
... rets = [] | |
... for st in sts: | |
... rets.append((st, filter(lambda x: x.startswith(st), data))) | |
... return rets | |
... | |
>>> rdds = _filter_native(data) | |
>>> for st, rdd in rdds: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _filter(st): | |
return filter(lambda x: x.startswith(st), ['aa', 'bb', 'ab', 'cc']) | |
fa = _filter('a') | |
print(next(fa)) # aa | |
print(next(fa)) # ab | |
fa = _filter('a') | |
st = 'b' | |
print(next(fa)) # aa |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r1 = (u'1', 'a1') | |
r2 = (u'1', 'a2') | |
r3 = (u'2', 'a3') | |
r4 = (u'2', 'a4') | |
r5 = (u'2', 'a5') | |
r6 = (u'2', 'a6') | |
r7 = (u'4', 'a7') | |
r8 = (u'4', 'a8') | |
r9 = (u'3', 'a9') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> impostos = ['MEI', 'Simples'] | |
>>> for imposto in impostos: | |
... if imposto.startswith('S'): | |
... print(imposto) | |
... | |
Simples | |
>>> impostos = ['MEI', 'Simples'] | |
>>> for imposto in impostos: | |
... print(imposto.startswith('S')) | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; | |
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; | |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Author: felipe cruz [email protected] | |
*/ | |
#include <iostream> | |
#include <cmath> | |
#include <cstdio> | |
#include <vector> | |
#include <algorithm> | |
#include <map> | |
#include <random> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <numeric> | |
using namespace std; | |
class Perceptron { | |
vector<double> w; | |
double learning_rate; | |
bool error; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Profit é o lucro total e não lucro da operação. | |
Buy 5000 PETRF20 at: 0.140000 | |
Buy 1000 PETRF18 at: 0.200000 | |
Sell 1000 PETRF18 at: 0.220000 | |
Profit: -20.000000 | |
Buy 1200 PETRF18 at: 0.220000 | |
Sell 5000 PETRF20 at: 0.230000 | |
Profit: 390.000000 | |
Buy 1300 PETRF16 at: 0.770000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cffi | |
GRB_EQUAL = 61 | |
ffi = cffi.FFI() | |
ffi.cdef(''' | |
typedef ... GRBenv; | |
typedef ... GRBmodel; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bind_local_names(params): | |
'''create outer scope vars from a dict''' | |
import sys | |
for k, v in params.items(): | |
sys._getframe(1).f_locals[k] = v | |
params = dict(b='test', c=10) | |
bind_local_names(params) |