Skip to content

Instantly share code, notes, and snippets.

@chimeno
chimeno / replace s3
Created February 28, 2018 14:00
replace files in s3 example with bzip2
aw3 s3 sync s3://bucket .
for i in [pattern]
bzip2 $i
aw3 s3 sync . s3://bucket --dryrun --delete
@chimeno
chimeno / script.py
Last active May 27, 2017 15:57
averages carto
import asyncio
import urllib.parse
import sys
@asyncio.coroutine
def count_things(url):
url = urllib.parse.urlsplit(url)
if url.scheme == 'https':
connect = asyncio.open_connection(url.hostname, 443, ssl=True)
else:
SELECT post_id, meta_value, post_date, post_modified, post_title, post_name, guid, post_mime_type
FROM `wp_postmeta`
INNER JOIN `wp_posts`
ON `wp_postmeta` .`post_id`=`wp_posts`.`ID`
WHERE `post_type`='attachment' and `meta_key`= '_wp_attachment_image_alt'
ORDER BY `wp_posts`.`post_modified` ASC
@chimeno
chimeno / page-template.php
Created April 21, 2015 16:24
Show content from a page in another - wordpress
$the_query = new WP_Query( 'page_id=305' );
while ( $the_query->have_posts() ) :
$the_query->the_post();
the_content();
endwhile;
wp_reset_postdata();
@chimeno
chimeno / down.py
Created June 11, 2014 13:54
download pycon2014 videos
import requests
from lxml import etree
from subprocess import call
req = requests.get('http://pyvideo.org/category/50/pycon-us-2014/rss')
xml_tree = etree.fromstring(req.content)
@chimeno
chimeno / dos2unix
Created November 7, 2012 09:42
convert dos2unix script
find ./ -type f -exec dos2unix {} \;
@chimeno
chimeno / .htaccess
Created November 5, 2012 00:10 — forked from leebyron/.htaccess
Options +FollowSymlinks
RewriteEngine on
# No intersticial for direct reference and self-reference
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://box.leebyron.com/.*$ [NC]
# Add a line item for every website you don't need an intersticial for
# I've added my own website, gmail and facebook
RewriteCond %{HTTP_REFERER} !^http(s)?://([^\.]*.)?leebyron.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://mail.google.com/.*$ [NC]
@chimeno
chimeno / gist:3694607
Created September 10, 2012 23:03 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@chimeno
chimeno / gist:3694590
Created September 10, 2012 23:00
Given a secuencia of integer numbers through stdin returns its sum through stdout
#! /usr/bin/env python
#sample.py
#Given a secuencia of integer numbers through stdin
#returns its sum through stdout
#@author Daniel Chimeno <[email protected]>
import sys
import re
num=0