Skip to content

Instantly share code, notes, and snippets.

View stav's full-sized avatar
💭
c0d1ng

Steven Almeroth stav

💭
c0d1ng
View GitHub Profile
@markjaquith
markjaquith / activate-deactivate-uninstall-example.php
Created March 6, 2011 17:27
Example code for doing activate/deactivate/uninstall hooks in a WordPress plugin
<?php
// Change /*CUSTOMIZE_THIS*/ to a unique name (two places). Go ahead, make it long.
// Like, your initials, and your full plugin name.
// e.g. MTJ_Some_Awesome_Plugin_Controller
/*CUSTOMIZE_THIS*/_Controller::init();
class /*CUSTOMIZE_THIS*/_Controller {
function init() {
spider_count = 0
# Get a signal that a crawler has finished its job, start another crawler
def spider_closed(spider, reason):
spider_count += 1
#Only starts another crawler if available
if spider_count < len(spiders):
reactor.callLater(0, start_crawler, spider=spiders[spider_count])
else:
@madjar
madjar / scrapper.py
Last active March 5, 2023 15:02
A example of scrapper using asyncio and aiohttp
import asyncio
import aiohttp
import bs4
import tqdm
@asyncio.coroutine
def get(*args, **kwargs):
response = yield from aiohttp.request('GET', *args, **kwargs)
return (yield from response.read_and_close(decode=True))
@prschmid
prschmid / open_sftp.py
Last active January 27, 2023 08:35
python open_sftp() context manager for sftp read and writing of files with similar behavior to open()
from contextlib import contextmanager
from urlparse import urlparse
from paramiko import AuthenticationException
import pysftp
@contextmanager
def open_sftp(url, mode='r', n_retries=5, retry_sleep_time=5):
"""Context manager to read/write a file via SFTP
@unitycoder
unitycoder / node-presskey-console.js
Created December 21, 2017 05:18
node.js Wait For KeyPress in console
// node.js get keypress
var stdin = process.stdin;
// without this, we would only get streams once enter is pressed
//stdin.setRawMode( true );
// resume stdin in the parent process (node app won't quit all by itself
// unless an error or process.exit() happens)
stdin.resume();
// i don't want binary, do you?