Skip to content

Instantly share code, notes, and snippets.

View danielSanchezQ's full-sized avatar
🦀

Daniel Sanchez danielSanchezQ

🦀
View GitHub Profile
@sebpiq
sebpiq / gist:4128537
Last active April 22, 2024 15:20
Python implementation of the Goertzel algorithm for calculating DFT terms
# Copyright © 2020 Sébastien Piquemal [email protected]
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See the license text below for more details.
#
# --------------------------------------------------------------------
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
@kvalle
kvalle / progress.py
Created November 21, 2012 22:14
Demo of python "progress bar"
import time
import sys
total = int(sys.argv[1]) if len(sys.argv) > 1 else 100
def status_line(num, total):
line = "> processed %d of %d files" % (num, total)
sys.stdout.write(line)
sys.stdout.flush()
sys.stdout.write("\b" * (len(line)))
@codesaler
codesaler / crawl.py
Created October 14, 2012 13:55 — forked from jonhurlock/crawl.py
Python Web Crawler - jonhurlock
#!/usr/bin/env python
"""
Simple Indexer
=================================
Author: Jon Hurlock, October 2011
This script basically crawls a domain (not just a page) and
then extracts all links <a href=""></a>, and finds all links
on that domain it also is able extract different file types
@jpanganiban
jpanganiban / gist:3844261
Created October 6, 2012 07:05
Pygame + OpenCV Real-time Face Detection
#!/usr/bin/env python
from pygame import camera
import pygame
import time
import cv
import os
# Recognition
@bibiboot
bibiboot / pycurses.py
Created August 6, 2012 07:28
Running the python curses
with curses_screen() as stdscr:
"""
Execution of the curses begins here.
"""
# Retrieve the size of the terminal currently open.
SCREEN_HEIGHT, SCREEN_WIDTH = stdscr.getmaxyx()
# Create the pad
mypad = curses.newpad(SCREEN_HEIGHT, SCREEN_WIDTH)
# Refresh the pad
@bibiboot
bibiboot / pycurses.py
Created August 6, 2012 07:01
Hello world python curses
import curses
SCREEN_WIDTH, SCREEN_HEIGHT = 100, 100
class curses_screen:
def __enter__(self):
"""Initialize"""
self.stdscr = curses.initscr()
curses.cbreak()
curses.noecho()
@Vincentxiaojie
Vincentxiaojie / gist:3188718
Created July 27, 2012 15:36 — forked from zeuxisoo/gist:1205467
Mini Fake DNS server (Python recipe)
## {{{ http://code.activestate.com/recipes/491264/ (r4)
import socket
class DNSQuery:
def __init__(self, data):
self.data=data
self.dominio=''
tipo = (ord(data[2]) >> 3) & 15 # Opcode bits
if tipo == 0: # Standard query
@leppie
leppie / gist:3187332
Created July 27, 2012 10:29
Binary period
(define (>> n i) (bitwise-arithmetic-shift n (- i)))
(define << bitwise-arithmetic-shift-left)
(define & bitwise-and)
(define (split n p)
(let* ((bc (bitwise-length n))
(mid (div bc 2)))
(define (get-bit-seq s c)
(let ((rs (- bc s c))
(m (- (<< 1 c) 1)))
@rogerallen
rogerallen / insulter.py
Created July 23, 2012 18:52
Shakespeare Insulter in Python
#!/usr/bin/env python3
#
# http://www.pangloss.com/seidel/shake_rule.html
# Shakespeare Insult Kit
#
# Combine one word from each of the three columns below, prefaced with "Thou":
#
import random
Column_1 ="""artless bawdy beslubbering bootless churlish cockered
@cmthakur
cmthakur / sql commands
Created July 19, 2012 14:18
sql commands
#restore .sql file to the database
mysql target-db-name < sql-file-name.sql -uuser -p
# [mysql dir]/bin/mysql -h hostname -u root -p
Create a database on the sql server.
mysql> create database [databasename];
List all databases on the sql server.
mysql> show databases;