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 os | |
| os.environ['DJANGO_SETTINGS_MODULE'] = 'ares.settings' | |
| import django | |
| django.setup() | |
| import datetime | |
| from django.conf import settings | |
| from django.contrib.auth import logout |
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
| require 'yard' | |
| require 'fileutils' | |
| YARD::Rake::YardocTask.new do |t| | |
| dynamic_dir = File.join('lib', 'ansa', 'docs') | |
| dynamic_file = File.join(dynamic_dir, 'dynamic_docs.rb') | |
| FileUtils.mkdir_p dynamic_dir | |
| f = File.new(dynamic_file, 'w') | |
| f.write("module Ansa") | |
| Ansa::LINKS.each do |category, url| |
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
| module Ansa | |
| generate_get_news 'homepage', 'http://www.ansa.it/sito/ansait_rss.xml' | |
| generate_get_news 'news', 'http://www.ansa.it/sito/notizie/cronaca/cronaca_rss.xml' | |
| generate_get_news 'politics', 'http://www.ansa.it/sito/notizie/politica/politica_rss.xml' | |
| generate_get_news 'world', 'http://www.ansa.it/sito/notizie/mondo/mondo_rss.xml' | |
| generate_get_news 'economy', 'http://www.ansa.it/sito/notizie/economia/economia_rss.xml' | |
| generate_get_news 'soccer', 'http://www.ansa.it/sito/notizie/sport/calcio/calcio_rss.xml' | |
| generate_get_news 'sport', 'http://www.ansa.it/sito/notizie/sport/sport_rss.xml' | |
| end |
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
| module Ansa | |
| private | |
| # @!macro [attach] generate_get_news | |
| # @method get_$1_news | |
| # @!scope class | |
| # @note This method is autogenerated | |
| # Get news for "$1" category. | |
| # @raise [Ansa::AnsaError] when errors occour fetching news | |
| # @return [Array<Ansa::News>] all the news of category "$1". | |
| def self.generate_get_news(category, url) |
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
| module Ansa | |
| # .... | |
| private | |
| def self.generate_get_news(category, url) | |
| define_singleton_method("get_#{category}_news") do | |
| get_news_by_url(url) | |
| end | |
| end | |
| public |
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
| require 'ansa' | |
| puts "\n⚽️ SOCCER NEWS ⚽️\n\n" | |
| begin | |
| Ansa::get_soccer_news.each do |news| | |
| puts "🥅 [#{news.date.strftime("%d/%m %H:%M:%S")}] #{news.title}" | |
| puts news.description | |
| puts "\n" | |
| end |
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
| #define Py_LIMITED_API | |
| #include <Python.h> | |
| #include "libnewmath.h" | |
| PyObject *sum_wrapper(PyObject *obj, PyObject *args) { | |
| const long a, b; | |
| if (!PyArg_ParseTuple(args, "LL", &a, &b)) | |
| return NULL; |
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
| package main | |
| import "C" | |
| //export sum | |
| func sum(a, b int) int { | |
| return (a + b) | |
| } |
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 <Python.h> | |
| // ... | |
| int is_a_long(PyObject * p) { | |
| return PyLong_Check(p); | |
| } |
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
| #define Py_LIMITED_API | |
| #include <Python.h> | |
| int PyArg_ParseTuple_LL( | |
| PyObject * args, | |
| long long * a, | |
| long long * b | |
| ) { | |
| return PyArg_ParseTuple(args, "LL", a, b); | |
| } |