Skip to content

Instantly share code, notes, and snippets.

View frankV's full-sized avatar
🦑
Work Hard. Cuttlesoft.

Frank Valcarcel frankV

🦑
Work Hard. Cuttlesoft.
View GitHub Profile
@mdamien
mdamien / 0readme.md
Last active February 22, 2024 12:11
404 link detector with scrapy

List all the broken links on your website

Requirements:

python3 and scrapy (pip install scrapy)

Usage

  • scrapy runspider -o items.csv -a site="https://yoursite.org" 1spider.py
  • python3 2format_results.py
@ivanleoncz
ivanleoncz / flask_app_logging.py
Last active May 23, 2021 07:25
Demonstration of logging feature for a Flask App.
#/usr/bin/python3
""" Demonstration of logging feature for a Flask App. """
from logging.handlers import RotatingFileHandler
from flask import Flask, request, jsonify
from time import strftime
__author__ = "@ivanleoncz"
import logging
@nelsonomuto
nelsonomuto / .js
Last active December 28, 2016 14:12
'use strict';
var gulp = require('gulp');
var gutil = require('gulp-util');
var browserSync = require('browser-sync');
var notify = require('gulp-notify');
var less = require('gulp-less');
var autoprefix = require('gulp-autoprefixer');
var minifyCSS = require('gulp-minify-css');
var exec = require('child_process').exec;
@faustomorales
faustomorales / angular-tableau.js
Created March 6, 2016 05:03
Angular directive to embed Tableau dashboards
/* Using this directive is as easy as 1, 2, 3.
1. Grab the Tableau API JavaScript library as well as this module.
a. <script src="path/to/tableau-2.0.0.min.js"></script>
b. <script src="path/to/angular-tableau.js"></script>
2. Import the module into your app by adding 'angular-tableau' to your dependencies.
3. Use the directive like this:
<tableau-viz height="'500px'"
url="path/to/tableau-dashboard"
filters={'field1':['item1', 'item2'], 'dateField':{'min':startDate, 'max':endDate}}">
</tableau-viz>
@jeremyjbowers
jeremyjbowers / actions.py
Created November 24, 2015 21:47
Export to CSV for Django admin
import csv
from django.http import HttpResponse
def export_as_csv_action(description="Export selected objects as CSV file", fields=None, exclude=None, header=True):
"""
This function returns an export csv action
'fields' and 'exclude' work like in django ModelForm
'header' is whether or not to output the column names as the first row
"""
def export_as_csv(modeladmin, request, queryset):
@chadselph
chadselph / flaskwithcron.py
Last active April 21, 2022 10:20
flask with "cron"-like loop
from flask import Flask, render_template, jsonify, request
from threading import Timer, Thread
from time import sleep
app = Flask(__name__)
@app.route("/api/<method>")
def api(method):
data = {
@mmautner
mmautner / app.py
Last active October 22, 2019 18:09
Example of caching API results w/ Flask-Restless
import json
import hashlib
import flask
import flask.ext.sqlalchemy
import flask.ext.restless
from flask.ext.restless import ProcessingException
app = flask.Flask(__name__)
app.config['DEBUG'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
@my-slab
my-slab / get_posts.py
Last active May 10, 2018 17:32
Basic example of using the Python for Facebook SDK to get all the posts on a user's timeline.
import facebook
import requests
def some_action(post):
""" Here you might want to do something with each post. E.g. grab the
post's message (post['message']) or the post's picture (post['picture']).
In this implementation we just print the post's created time.
"""
print post['created_time']
@mattupstate
mattupstate / module.sublime-snippet
Created July 19, 2013 13:55
A simple Python module header snippet for Sublime Text
<snippet>
<tabTrigger>module</tabTrigger>
<scope>source.python</scope>
<description>Module</description>
<content><![CDATA[# -*- coding: utf-8 -*-
"""
${1:name}
${1/./~/g}
@legege
legege / mjpeg-directives.html
Created April 3, 2013 14:02
This is an AngularJS directive for MJPEG streams. This directive uses an iframe to stop the browser from loading the MJPEG stream. This is useful for Chrome: https://code.google.com/p/chromium/issues/detail?id=73395
<mjpeg url="videoUrl"></mjpeg>