Skip to content

Instantly share code, notes, and snippets.

@njligames
njligames / External_GTest.cmake
Created April 30, 2019 01:40 — forked from ClintLiddick/External_GTest.cmake
CMake ExternalProject_Add for Google Mock (gmock) and Google Test (gtest) Libraries
find_package(Threads REQUIRED)
ExternalProject_Add(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
UPDATE_COMMAND ""
INSTALL_COMMAND ""
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON)
@njligames
njligames / producer_consumer.py
Created March 4, 2019 01:30 — forked from cristipufu/producer_consumer.py
Producer-consumer problem in python
import sys
import random
import time
from threading import *
class Producer(Thread):
def __init__(self, items, can_produce, can_consume):
Thread.__init__(self)
self.items = items
self.can_produce = can_produce
@njligames
njligames / rest-server.py
Created February 10, 2019 03:53 — forked from miguelgrinberg/rest-server.py
The code from my article on building RESTful web services with Python and the Flask microframework. See the article here: http://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask_httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'miguel':
@njligames
njligames / validate_rfc_2822_email.function.php
Created April 11, 2018 12:09 — forked from felds/validate_rfc_2822_email.function.php
Checks if an email is a valid RFC 2822 email address
<?php
/**
* Checks if an email is a valid RFC 2822 email address
*
* Examples:
* <code>
* <?php
* validate_email('dev@felds.com.br'); // returns true
* validate_email('Felds Liscia <dev@felds.com.br>'); // returns false