Skip to content

Instantly share code, notes, and snippets.

View toaco's full-sized avatar
🎯
Focusing

toaco toaco

🎯
Focusing
View GitHub Profile
@toaco
toaco / get_all_resources.py
Created July 18, 2017 09:11
list all resource requested by a request
# list all resource requested by a request
from ghost import Ghost
ghost = Ghost()
def get_all_resources(url):
with ghost.start() as session:
page, extra_resources = session.open(url)
for extra_resource in extra_resources:
@quachngocxuan
quachngocxuan / learnenough-flask.md
Last active January 8, 2018 06:57
Learn enough to be dangerous - Flask

Learn enough to be dangerous - Flask

Based on Tutorialspoint - Flask.

CORE CONCEPTS

Intro

  • Flask is a web application framework written in Python.
  • Flask is based on Werkzeug WSGI toolkit and Jinja2 template engine.
  • Flask is often referred to as a micro framework. It aims to keep the core of an application simple yet extensible. Flask does not have built-in abstraction layer for database handling, nor does it have form a validation support. Instead, Flask supports the extensions to add such functionality to the application. Some of the popular Flask extensions are discussed later in the tutorial.
@Ignavia-Snippets
Ignavia-Snippets / timeit.c
Created December 28, 2013 14:31
C: Timeit
#include <time.h>
#include <sys/time.h>
#include "timeit.h"
double timeit(void (*f)()) {
struct timespec start, end;
clock_gettime(CLOCK_MONOTONIC, &start);
(*f)();
@umidjons
umidjons / zip-folder.sh
Created November 21, 2013 11:04
Linux: zip/unzip folder on linux terminal
# compress
zip -9 -r myfolder.zip myfolder/
# uncompress/extract
unzip myfolder.zip
unzip myfolder.zip -d targetfolder/
# Java
*.class
*.jar
*.war
*.ear
# Eclipse
.project
.classpath
.settings
@nmarley
nmarley / README.md
Last active May 13, 2020 21:46
Python JSON Schema validation example

test json schema validation

Setup Virtualenv

$ virtualenv ./venv
$ ./venv/bin/pip install -r requirements.txt

Test/Play:

$ ./venv/bin/python ./v.py

@xlab
xlab / bytes_split.go
Last active April 4, 2022 17:21
Golang split byte slice in chunks sized by limit
func split(buf []byte, lim int) [][]byte {
var chunk []byte
chunks := make([][]byte, 0, len(buf)/lim+1)
for len(buf) >= lim {
chunk, buf = buf[:lim], buf[lim:]
chunks = append(chunks, chunk)
}
if len(buf) > 0 {
chunks = append(chunks, buf[:len(buf)])
}
@techniq
techniq / view.py
Created March 16, 2013 01:06
SQLAlchemy View support
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.sql.expression import Executable, ClauseElement
from sqlalchemy.schema import DDLElement, DropTable
from sqlalchemy.sql import table
from sqlalchemy.orm import Query
from . import db
class CreateView(DDLElement):
@rtv
rtv / cond.c
Created February 19, 2013 19:56
An example of using pthread's condition variables, showing how to block a main thread while waiting for worker threads to finish their work, without joining the threads. This could be useful if you want to loop the threads, for example.
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
/* Compile like this:
gcc --std=c99 -lpthread cond.c -o cond
package main
import (
"fmt"
"sync"
)
var messages = [][]string{
{
"The world itself's",