Skip to content

Instantly share code, notes, and snippets.

View djalmabright's full-sized avatar

Djalma Bina djalmabright

View GitHub Profile
from flask import Flask
from flask import request
node = Flask(__name__)
# Store the transactions that
# this node has in a list
this_nodes_transactions = []
@node.route('/txion', methods=['POST'])
def transaction():
pragma solidity ^0.4.18;
/**
* A contract that pays off, if a user is able to produce a valid solution
* for the Fermat's last theorem
*/
contract Fermat {
/**
@djalmabright
djalmabright / pycon-views.py
Created March 24, 2018 20:29 — forked from miguelgrinberg/pycon-views.py
Generate statistics about PyCon 2014 videos
import argparse
import re
from multiprocessing.pool import ThreadPool as Pool
import requests
import bs4
root_url = 'http://pyvideo.org'
index_url = root_url + '/category/50/pycon-us-2014'
@djalmabright
djalmabright / django_admin_mpld3_view.py
Created March 28, 2018 20:35 — forked from leriomaggio/django_admin_mpld3_view.py
Interactive Matplotlib (Bar) Chart with mpld3 in Django Custom Admin View
#----------------------------------------------------------------------------------------
# model.py
#----------------------------------------------------------------------------------------
from django.db import models
from numpy.random import random_sample
class CustomModel(models.Model):
# Put your fields here
def get_data(self):
@djalmabright
djalmabright / capture.py
Created April 9, 2018 22:15 — forked from thearn/capture.py
Screen capture using python PIL
import time
import Image
import ImageGrab
while True:
time.sleep(0.5)
t = str(time.time()).replace('.','-')
tt = time.time()
img=ImageGrab.grab()
img = img.resize((800,600))
@djalmabright
djalmabright / client.cpp
Created November 27, 2018 22:26 — forked from SteveRuben/client.cpp
Multiple streaming in c++ using opencv; OpenCV video streaming over TCP/IP
/**
* OpenCV video streaming over TCP/IP
* Client: Receives video from server and display it
* by Steve Tuenkam
*/
#include "opencv2/opencv.hpp"
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
@djalmabright
djalmabright / flattenerArray.js
Created April 30, 2019 09:29
Javascript Console implementation to flatten an array of arbitrarily nested arrays of integers into a flat array of integers.
'use strict';
// exam if the array is already flattened
// returns true/false
const isArrayFlattened = function($array) {
if (!$array) {
return true;
}
for (const item of $array) {
if (item instanceof Array) {
@djalmabright
djalmabright / walmart.json
Created February 7, 2020 03:38 — forked from scrapehero/walmart.json
Sitemap to extract product data and pricing from Walmart using web scraper.io extension
{
"_id": "walmart",
"startUrl": [
"https://www.walmart.com/browse/home-improvement/electrical/1072864_1067619?povid=1072864+%7C+2018-05-02+%7C+Flyout_Electrical"
],
"selectors": [
{
"id": "product",
"type": "SelectorElementClick",
"parentSelectors": [