This file contains 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
web3.toWei(Decimal('0.000000005'), 'ether') | |
# returns 5000000000 |
This file contains 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
w3.fromWei(3841357360894980500000001, 'ether') | |
# returns Decimal('3841357.360894980500000001') |
This file contains 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 ctypes | |
cmodule = ctypes.cdll.LoadLibrary('./my_c_library.so') |
This file contains 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
# load c library | |
cmodule = load_module() | |
# define source and target strings | |
source = "levenshtein" | |
target = "levenstein" | |
# define edition costs | |
insert_cost = 1 | |
delete_cost = 1 | |
replace_cost = 2 | |
# call c function |
This file contains 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 load_module(): | |
# load library | |
cmodule = ctypes.cdll.LoadLibrary('./levenshtein.so') | |
# define arguments type | |
cmodule.levenshtein.argtypes = [ctypes.c_char_p, | |
ctypes.c_char_p, | |
ctypes.c_int, | |
ctypes.c_int, | |
ctypes.c_int] | |
# define return type |
This file contains 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
CFLAGS = -fpic -lm -std=gnu99 -O3 -march=native -DCONJUGRAD_FLOAT=64 | |
all: levenshtein.so | |
m.PHONY : clean | |
levenshtein.so: levenshtein.o | |
gcc -shared -o $@ $^ | |
%.o: %.c |
This file contains 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 <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#define MIN3(a, b, c) ((a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c))) | |
int levenshtein(char *source, char *target, int ins_cost, int del_cost, int rep_cost) | |
{ | |
/* | |
Input: | |
source: a string corresponding to the string you are starting with |
This file contains 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 <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#define MIN3(a, b, c) ((a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c))) | |
int* min_edit_distance_tab(char *source, char *target, int ins_cost, int del_cost, int rep_cost) | |
{ | |
/* | |
Input: | |
source: a string corresponding to the string you are starting with |
This file contains 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
[Unit] | |
Description=Current IP email sender timer | |
[Timer] | |
OnCalendar=hourly | |
Unit=sendip.service | |
[Install] | |
WantedBy=multi-user.target |
This file contains 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
[Unit] | |
Description=Current IP email sender | |
After=multi-user.target network.target | |
[Service] | |
User=guillaume | |
Group=guillaume | |
Type=simple | |
ExecStart=/home/guillaume/miniconda3/envs/ipsender/bin/python /home/guillaume/src/ipsender/send.py |
NewerOlder